Downgrading updatePriority not being respected - android

We are using the Triple-T library to publish our app.
We successfully used the updatePriority as mentioned in the documentation to trigger a high priority update.
https://github.com/Triple-T/gradle-play-publisher
The problem is, the following release, we reduced it to 1, but we are still seeing 4 come back on the callbacks.
The code is as per the documentation:
https://developer.android.com/guide/playcore/in-app-updates/kotlin-java.
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE &&
appUpdateInfo.updatePriority() >= 4 &&
appUpdateInfo.isUpdateTypeAllowed(IMMEDIATE)
) {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
IMMEDIATE,
this#MyActivity,
UPDATE_RESPONSE_CODE
)
}
}
Our gradle is as follows for the release:
play {
updatePriority.set(1)
}
Is there a step I have missed here that is required to reduce the update priority?

Related

Popup for Google Play Store Update is not showing on Tablet?

I have a strange behavior in my Android application. I want to create a popup if a new update is available on Google Play Store. On my Smartphone it is shown without any problems. But on my Samsung Tablet (Galaxy Tab S7), the popup does not show up. I cannot figure out why this happens. I tried it also some hours later.
I tried to clear the cache of the play store. WiFi is enabled and the Android version is Android 11.
My code:
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(this);
// 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
// This example applies an immediate update. To apply a flexible update
// instead, pass in AppUpdateType.FLEXIBLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
try {
appUpdateManager.startUpdateFlowForResult(
// Pass the intent that is returned by 'getAppUpdateInfo()'.
appUpdateInfo,
// Or 'AppUpdateType.FLEXIBLE' for flexible updates.
AppUpdateType.IMMEDIATE,
// The current activity making the update request.
this,UPDATE_APP
// Include a request code to later monitor this update request.
);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
});
Do you have any idea why the popup for an update is not showing up? In the google play store, there is an update button if I open the app.

Using InApp Update API mode Flexible

I was using In App Update API with update type as Flexible using below code
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.FLEXIBLE,
this,
APP_UPDATE_REQUEST_CODE)
Where the update type is provided as AppUpdateType.FLEXIBLE.
It showcases the correct UI where it provides option for users to either select Update or No Thanks.
As showcased in below image.
However clicking on Update actually showcases a fullscreen UI with progressbar generally associated with Immediate updated instead of performing the update in background.
Using play code SDK version 1.8.X
// Rate this app
// So, make sure you also include that repository in your project's build.gradle file.
implementation 'com.google.android.play:core:1.8.0'
// For Kotlin users also import the Kotlin extensions library for Play Core:
implementation 'com.google.android.play:core-ktx:1.8.1'
Does anyone has a idea why this would be happening?
Thanks in Advance.
Maybe your problem is
override fun onResume() {
super.onResume()
appUpdateManager
.appUpdateInfo
.addOnSuccessListener {
// If an in-app update is already running, resume the update.
if (it.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS)
startUpdate(it, AppUpdateType.IMMEDIATE) // <<-- !!HERE!!
// If the update is downloaded but not installed, notify the user to complete the update.
if (it.installStatus == InstallStatus.DOWNLOADED) {
nav_progress_download.hide()
popupSnackbarForCompleteUpdate()
}
}
}
When you click Update button, onResume is called.
And updateAvailability() of AppUpdateType.FLEXIBLE is same as UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS
Check this...
How to know the AppUpdateType at the origin of the DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS update availability?
https://issuetracker.google.com/issues/153785560

Google InApp Update Not working - Always returns UPDATE_NOT_AVAILABLE

I am not able to see the Google In-App Updates working in my application. Here is the way I have implemented my code, but it appUpdateInfo always returns UPDATE_NOT_AVAILABLE (1).
onCreate Method
appUpdateManager = AppUpdateManagerFactory.create(this)
appUpdateManager.registerListener(this)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener {appUpdateInfo ->
try {
if(appUpdateInfoTask.isComplete){
if (appUpdateInfo.updateAvailability() == UPDATE_AVAILABLE) {
ToastUtils.showShort("Update Available" + appUpdateInfo.isUpdateTypeAllowed(FLEXIBLE))
if(appUpdateInfo.isUpdateTypeAllowed(FLEXIBLE)){
ToastUtils.showShort("Flexi Update")
requestAppUpdate(appUpdateManager.appUpdateInfo.getResult(), FLEXIBLE)
}else if(appUpdateInfo.isUpdateTypeAllowed(IMMEDIATE)){
ToastUtils.showShort("Immediate Update")
requestAppUpdate(appUpdateManager.appUpdateInfo.getResult(), IMMEDIATE)
}
}
}
} catch (e: Exception) {
Log.e("Update Exception", e.message)
}
}
onResume Method
override fun onResume() {
super.onResume()
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnCompleteListener {
Log.e("Update Complete", "Complete")
}
appUpdateInfoTask.addOnSuccessListener {
if(appUpdateInfoTask.isComplete){
if (it.installStatus() == DOWNLOADED) {
showUpdateSnackbar()
}
}
}
}
onDestroy Method
override fun onDestroy() {
super.onDestroy()
appUpdateManager.unregisterListener(this)
}
onActivityResult Method
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_CODE_TO_FETCH_UPDATES) {
when (resultCode) {
Activity.RESULT_OK -> {
ToastUtils.showShort("Access to Update Granted")
}
Activity.RESULT_CANCELED -> {
ToastUtils.showShort("Access to Update Cancelled")
}
ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> {
ToastUtils.showShort("Access to Update Failed")
}
}
}
}
Key Points
Uploaded my app on the internal test track with Android App Bundle Format
App Update is available on the store(on internal track) when my code written above in onCreate returns UPDATE_NOT_AVAILABLE.
I have uploaded the using Google Play Developers API, and have set the inAppUpdatePriority as 5
QUERIES:
I have tried updating the app many times on the store and I can never see an update on my app via this code.WHY?
How can I see actual FLEXIBLE or IMMEDIATE Update by testing from the Internal test track? Where is the way to set that configuration?
I have recently implemented in app date successfully so I think I may be able to help you.
I may suggest you to make some changes in your code and also you must follow the correct way of testing with internal app sharing.
Inside the try block in OnCreate Method you can use this
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE){
if (appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.FLEXIBLE,
this,
REQUEST_CODE_TO_FETCH_UPDATES)
}
else if (appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.IMMEDIATE,
this,
REQUEST_CODE_TO_FETCH_UPDATES)
}
}
To test the in app update feature you must follow the following points-
You must make sure that the current app on your device is installed using an internal app sharing URL and the current app already supports in-app updates and also its version code must be lower than the updated version in Internal App Sharing.
If above all is fine, only click the internal app-sharing link for the updated version of your app. Do not install the app from the Google Play Store page you see after clicking the link.
Now when you open the app you will find the update in your app.
Or in simple way -
Step 1- Just build your app with the app update features and upload it to the Internal App Testing in Play Console
Step 2- Now go to the link obtained after uploading the app and install this version of your app from Play Store.
Step 3- Now again build your app with a higher version code than the previous one and again upload it to the Internal App Testing in Play Console
Step 4 - Now again go to the link obtained after uploading the app but now don't install this update just after going to Play Store page, press back and exit.
Step 5 - Now open your previously installed app and you will find the app update in your app
Hope it helps you.

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

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

How to specify which updates need to be updated immediately and which ones are flexible with Google's in app update API?

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.

Categories

Resources