I have followed the steps on Google's site to support in app updates. However I remain confused on how I specify which updates are "immediate" and which updates are "flexible". I do not see a flag anywhere in the Google Play Developer Console. Or am I supposed to write my own API to check on my server based on version code?
Here is my implementation:
appUpdateManager.appUpdateInfo.addOnSuccessListener { updateInfo ->
Log.e("launcher", "appUpdateInfo $updateInfo")
Log.e("launcher", "updateAvailablility ${updateInfo.updateAvailability()}")
Log.e("launcher", "availableVersion ${updateInfo.availableVersionCode()}")
if (updateInfo.updateAvailability()
== UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
// If an in-app update is already running, resume the update.
appUpdateManager.startUpdateFlowForResult(
updateInfo,
IMMEDIATE,
this,
REQUEST_UPDATE);
} else if (updateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && updateInfo.isUpdateTypeAllowed(IMMEDIATE)) {
appUpdateManager.startUpdateFlowForResult(updateInfo, IMMEDIATE, this, REQUEST_UPDATE)
} else if (updateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && updateInfo.isUpdateTypeAllowed(FLEXIBLE)) {
dialog(getString(R.string.update_recommended_title), getString(R.string.update_required_content), getString(R.string.update_required_positive), {
appUpdateManager.startUpdateFlowForResult(updateInfo, FLEXIBLE, this, REQUEST_UPDATE)
}, getString(R.string.update_recommended_negative), {
})
}
}
Today, you need to use your own API or encode it in the versionCode.