Skip to main content

User Authentication

Restrict apps' distribution only for selected users


There are many circumstances in which you would like to restrict apps' distributions to select users for testing.

With deverloper role, apps on Android devices can be accessed by anyone without root permissions, so it is not possible to protect apps just by restricting file distribution. However, by using DeployGate SDK, it’s possible to control app use permissions.

For example, entering the following code into Activity#onCreate will prevent unauthorized users from launching apps.

Java
DeployGate.registerCallback(new DeployGateCallback() {
@Override
public void onInitialized(boolean isServiceAvailable) {
if (!isServiceAvailable) {
Toast.makeText(this, "DeployGate is not available", Toast.LENGTH_SHORT).show();
finish();
}
}

@Override
public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) {
if (!isAuthorized) {
Toast.makeText(this, "This device is not authorized to use this app", Toast.LENGTH_SHORT).show();
finish();
}
}

Additionally, DeployGate SDK provides several functions to check if a user has permission to use an app. For example, it’s possible to see if an app is on the list of apps approved for use by a particular user.

DeployGate.isDeployGateAvailable(); // True if Deploygate has been installed
DeployGate.isAuthorized(); // True if app is avairable for current user
DeployGate.getLoginUsername(); // Current login username
DeployGate.getAuthorUsername(); // App developer username

See JavaDoc or GitHub - DeployGate/deploygate-android-sdk for details.