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

后端 未结 4 1961
情歌与酒
情歌与酒 2020-12-31 04:54

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.isUpdat         


        
4条回答
  •  别那么骄傲
    2020-12-31 05:01

    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.

提交回复
热议问题