In-app updates check whether it is AppUpdateType.FLEXIBLE or AppUpdateType.IMMEDIATE

Viewed 2698

Is there any option available in the playstore console to configure this value?

Here is the official doc. code:

// Creates instance of the manager.
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(context);

// Returns an intent object that you use to check for an update.
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();

// Checks that the platform will allow the specified type of update.
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
    if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
          // For a flexible update, use AppUpdateType.FLEXIBLE
          && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
              // Request the update.
    }
});

How do we know about:

appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)

Where to configure the above type? There is no relevant description available on the official doc.

In the AppUpdateInfo.class:

public final boolean isUpdateTypeAllowed(int var1) {
        if (var1 == 0) {
            return this.f != null;
        } else if (var1 == 1) {
            return this.e != null;
        } else {
            return false;
        }
    }

Where f and e are the PendingIntent and method returns true or false based on their value.

3 Answers

What is the use of appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)?

This is a very common question.

Many (myself included) interpreted this as a value that could be set somewhere dynamically, e.g. in the Google Play Console.

However that appears to not be the case. This is a local check that determines whether conditions on the device have been met to show the dialog.

If you want to dynamically configure whether to show Immediate or Flexible updates, you will need to provide it yourself, e.g. from your backend.

For more info: https://medium.com/@jplipata/undocumented-android-in-app-updates-a95efb9b7bd8?source=friends_link&sk=e8085150daa555ea80d07e8419b5341e

The update type (IMMEDIATE or FLEXIBLE) are set inside the app, not the play console.

Only an app update availibility check is necessary in the first place:

appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
    if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE

If this check succeeds, you need to start the update flow by yourself

appUpdateManager.startUpdateFlowForResult(appUpdateInfo, AppUpdateType.IMMEDIATE,

or

appUpdateManager.startUpdateFlowForResult(appUpdateInfo, AppUpdateType.FLEXIBLE,

regarding this type, the update will be installed in the background or in a blocking view by an play store overlay.

When an flexible app update is triggered and the user leaves the app, you need to check on the next launch if an flexible update is running in the background or finished.

https://developer.android.com/guide/app-bundle/in-app-updates

appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)

appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)

I have tried for multiple times to lower down the versionCode as compared to the Live App on Play Store.

Maybe in the next update, Google will explain about the isUpdateTypeAllowed because right now it's an only ambiguous call.

It is up to the developer to choose which type of update is invoked.

The mode is determined by the app in code.

Please see for further reference https://developer.android.com/guide/app-bundle/in-app-updates#start_update

Related