What purpose does appUpdateInfo.isUpdateTypeAllowed (AppUpdateType.IMMEDIATE) serve in Android In-App Update API?
Asked Answered
V

5

26

I have been following In-App update API in Android for quite some time now and I am unable to find any relevance of the following line:

appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)

--

appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)

This isUpdateTypeAllowed() method has been used in the code snippet below in Android Documentation: https://developer.android.com/guide/app-bundle/in-app-updates#update_readiness. Moreover, the above two method calls return true in all the cases and I am unable to find a case for which any of the above two method calls return false.

Vintage answered 30/5, 2019 at 12:0 Comment(3)
Does it also return true if the update is in progress? Might this be a reason?Vidovic
Hi! Is there any news about your request?Goalie
@Goalie , what do you mean ?Vintage
V
9

I had already raised this issue in Google Issue Tracker here and I did receive response from the Google Developers as follows :

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 https://developer.android.com/guide/app-bundle/in-app-updates#start_update

I have already integrated in-app update api in GoIbibo Mobile Application and It is running all perfect now. The documentation had this ambiguity. So you should write your own logic whether you want Flexible or Immediate Update.

Vintage answered 16/7, 2019 at 9:35 Comment(3)
Actually there is another ambiguity. Let me explain with an example. Let's say you pushed an app version A, which had some serious security flaws. To save users from that flaw you released a version B with all bugs fixed. Now there should be an option in version B to tell the Version A that there has been some serious issue so the In-App-Update UI should be IMMEDIATE. Which I can't find anywhere in Google Play Console, nor the AppUpdateManager is allowing anything similar. Please let me know if you find some solution for it.Passenger
Speculative documentation from Google? For me is working perfectly without that check and deciding when to trigger a mandatory update based in semantic versioning. IMHO this function is for something that might be supported in the future, for that reason the documentation is not clear about his utilityFunke
@max-cruz Sorry for a necrocomment. You can use updatePriority to determine it. Here is the official docs and also there is a way to set this up through Fastlane - you just write in terminal bundle exec fastlane deploy --in_app_update_priority 3 (priority can be from 0 to 5, and a default being 0. Sadly, I didn't find a way to set this up directly in the Google Play ConsoleReifel
C
8

These methods will always return true when there is a new update on playstore and current app version on device is less than the app version on playstore. To identify whether update is Flexible or Immediate we need to set a flag for FLEXIBLE or IMMEDIATE UPDATE in Remote Config like {"upgradeType":0/1} where 0 = FLEXIBLE and 1 = IMMEDIATE. For now we don't have any option in playstore console to set a flag for FLEXIBLE or IMMEDIATE update while releasing a build so for now we can set flag using remote config and identify whether update is FLEXIBLE or IMMEDIATE, might be in future playstore will give an option to set flag to identify for type of update.

Code:

val jsonObject=JSONObject(FirebaseConfig().getStringConfig(RemoteConfigConstants.KEY_APP_UPGRADE))
updateFlag = jsonObject.getInt(JsonConstants.UPGRADE_TYPE)

private fun checkForInAppUpdate() {
        appUpdateManager = AppUpdateManagerFactory.create(this)
        appUpdateManager.appUpdateInfo.addOnSuccessListener {
            if ((it.updateAvailability() === UpdateAvailability.UPDATE_AVAILABLE)) 
        {
                if (updateFlag == 0 && it.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
                    requestUpdate(it)
                    appUpdateManager.registerListener(this@HomeActivity)
                } else if (it.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
                    requestUpdate(it, AppUpdateType.IMMEDIATE)
                }
            }
        }
    }

Here updateFlag value is the value we are getting from remote config for particular type of update.

Commanding answered 28/6, 2019 at 12:9 Comment(3)
Better, easy and. clean way for this would be to pass update priority developer.android.com/guide/playcore/in-app-updates/…Osteoblast
@Osteoblast but where to pass this?Silverweed
is there a built-in Android's requestUpdate() function, that shows the popup like they show in the docs, and handles the update?Monotint
H
7

I have encountered appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE) or appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE) returning false even though update is available, when there is no network connection on my device.

Hooky answered 27/10, 2020 at 5:48 Comment(0)
M
1

I faced the one case when isUpdateTypeAllowed returns false. Its when there is not enaugh space on device to update app. for me it was 140mb space left and 60mb to update app. When i free up spece then isUpdateTypeAllowed returns true.

Mice answered 23/12, 2022 at 8:37 Comment(0)
Z
-4

These methods could return true if your UpdateAvailability is UPDATE_AIVALABLE. Please ensure this is true first:

appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE

Zealous answered 4/6, 2019 at 15:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.