I have implemented Google's library for providing In-App updates
and I am able to receive In-App updates
from Google Play store. I want to implement both Immediate update
and Flexible update
in a single app. But I can't find a way to do so. In-App update library performs a check based on on the VersionCode which is just an Integer. Is there any way I can build a strategy to decide whether to go with Flexible or Immediate Update?

- 24,761
- 25
- 106
- 174
-
You always can. For example you can have method, which requests to server version number after which one there should be "Immediate update". By that you can tell if you need to update immediately, cause there was crucial changes. But if there is no such version or if it is lower than yours, you can run Flexible update. – Andris Dec 19 '19 at 09:00
-
@Andris We will soon have a better way to handle this. Check my answer. :) – Chintan Soni Dec 19 '19 at 10:11
1 Answers
So, they have heard us and they are soon coming up with the solution as heard from Android Dev Summit '19.
Problem:
appUpdateManager.appUpdateInfo.addOnSuccessListener{ info ->
if(info.updateAvailability == UpdateAvailability.UPDATE_AVAILABLE){
// Which trigger should I trigger: Flexible or Immediate
}
}
As developers, we have 2 signals to decide our strategy:
1. Priority Signal: represents how important an update is. The priority value is defined by us while making a release. This priority value is then exposed to our app via Play Core Api.
Example:
appUpdateManager.appUpdateInfo.addOnSuccessListener{ info ->
if(info.updateAvailability == UpdateAvailability.UPDATE_AVAILABLE){
if(info.updatePriority() > 3 && info.isUpdateAllowed(AppUpdateType.IMMEDIATE)){
// trigger Immediate flow
}
else if(info.isUpdateAllowed(AppUpdateType.FLEXIBLE)){
// trigger Flexible flow
}
}
}
While we make a release we set priority valued as Integer, lets say between 0-5. In our app, we set a threshold lets say 3 and build a decision tree like if priority is greater than 3, then trigger Immediate update, else trigger Flexible update.
2. Staleness Signal: represents how long the device has known about the update.
Example:
appUpdateManager.appUpdateInfo.addOnSuccessListener{ info ->
if(info.updateAvailability == UpdateAvailability.UPDATE_AVAILABLE){
if(info.clientVersionStalenessDays() > 90 && info.isUpdateAllowed(AppUpdateType.IMMEDIATE)){
// trigger Immediate flow
}
else if(info.clientVersionStalenessDays() > 30 && info.isUpdateAllowed(AppUpdateType.FLEXIBLE)){
// trigger Flexible flow
}
}
}
They said this feature will be available soon.
Check full video here: https://youtu.be/_o_q6hatcIs?t=566

- 24,761
- 25
- 106
- 174
-
1
-
@Shikhar Hello! Yes, it is: https://developer.android.com/reference/unity/class/Google/Play/AppUpdate/AppUpdateInfo – Arthur Khazbs Jun 27 '22 at 11:40
-
-
-
@MDEV If so, then while pushing a new update, how can I specifically mention that this particular update should be flexible/immediate? – Shikhar Jul 11 '22 at 06:04
-
@Shikhar You can set an update priority using Google Play Developer Publishing API, as discussed here: https://stackoverflow.com/questions/61115215/how-to-set-update-priority-for-a-new-android-release In your app's code, you can query the `AppUpdateManager` for `AppUpdateInfo` and look at `UpdatePriority` and `ClientVersionStalenessDays` to decide whether to offer a flexible update or require an immediate update. – Arthur Khazbs Jul 11 '22 at 13:24
-
1@ArthurKhazbs The most rated answer in the link that you shared itself says "Currently there is no way to set it using Play Console but there is a plan to integrate in Play Console". Hence my question remains the same. Have you tried this personally in any of your projects? – Shikhar Jul 12 '22 at 00:43
-
@Shikhar Please read my comment carefully again. If you cannot set an update priority using Google Play Console, it doesn't mean you cannot do it at all. I haven't tried this myself, but I can still see how sending a request to the said API can solve the problem. – Arthur Khazbs Jul 13 '22 at 11:25
-
@ArthurKhazbs the api you are talking about is a simple check for the client end to know whether and how to offer the next update...but my question is from server end, that is while pushing a new update how will I specifically mention that the type of this particular update should flexible or mmediate. Based on this only AppUpdateInfo of the AppUpdateManager fetches the info for us to decide. – Shikhar Jul 14 '22 at 09:42
-
@Shikhar "Set the priority using the Google Play Developer API, as described in the [Play Developer API documentation](https://developers.google.com/android-publisher/tracks#apk_workflow_example). Specify in-app update priority in the [`Edit.tracks`](https://developers.google.com/android-publisher/api-ref/rest/v3/edits.tracks) resource passed in the `Edit.tracks: update` method. The following example demonstrates releasing an app with version code 88 and `inAppUpdatePriority` 5: `{"releases":[{"versionCodes":["88"],"inAppUpdatePriority":5,"status":"completed"}]}`." – Arthur Khazbs Jul 15 '22 at 13:41
-
From https://developer.android.com/guide/playcore/in-app-updates/native#update-priority – Arthur Khazbs Jul 15 '22 at 13:41