Я реализовал обновления в приложении, как описано в - https://developer.android.com/guide/app-bundle/in-app-updates#kotlin
Проблема в том, что когда я загружаю новую версию через внутренний тестовый трек (с большим номером сборки), я вижу его на своем Android-устройстве в приложении Play Store, но получаю appUpdateInfo.updateAvailability() = UPDATE_NOT_AVAILABLE
внутри слушателя: appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->.
Через несколько часов я получаю обновление через слушатель!
Кто-нибудь видел подобное поведение?
Мой код, который реализует это:
override fun onCreate(savedInstanceState: Bundle?) {
.
.
.
val buildCode = BuildConfig.VERSION_CODE
// Creates instance of the manager.
val appUpdateManager = AppUpdateManagerFactory.create(ctx)
appUpdateManager.registerListener(this)
Log.i(TAG, "IMMEDIATE Application context = $ctx")
// Returns an intent object that you use to check for an update.
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
Log.i(TAG, "IMMEDIATE Application Update - start listening for updates")
// Checks that the platform will allow the specified type of update.
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
Log.i(TAG, "IMMEDIATE Application addOnSuccessListener returned appUpdateInfo.updateAvailability() = ${appUpdateInfo.updateAvailability()}")
Log.i(TAG, "IMMEDIATE Application addOnSuccessListener IMMEDIATE appUpdateInfo.isUpdateTypeAllowed = ${appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)}")
Log.i(TAG, "IMMEDIATE Application addOnSuccessListener FLEXIBLE appUpdateInfo.isUpdateTypeAllowed = ${appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)}")
Log.i(TAG, "IMMEDIATE Application addOnSuccessListener appUpdateInfo.availableVersionCode() = ${appUpdateInfo.availableVersionCode()}")
Log.i(TAG, "IMMEDIATE Application addOnSuccessListener appUpdateInfo.packageName() = ${appUpdateInfo.packageName()}")
Log.i(TAG, "IMMEDIATE Application addOnSuccessListener appUpdateInfo.installStatus() = ${appUpdateInfo.installStatus()}")
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
Log.i(TAG, "IMMEDIATE Application Update is available. Version = ${appUpdateInfo.availableVersionCode()} Start the update flow")
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.IMMEDIATE,
view as MainActivity,
APPLICATION_UPDATE_REQUEST_CODE
)
}else {
Log.e(TAG, "Update not available")
}
}
}
override fun onStateUpdate(installState: InstallState) {
if (installState.installStatus() == InstallStatus.DOWNLOADED) {
Log.i(TAG, "Application update. download complete")
}
}
override fun onResume() {
.
.
.
resumeApplicationUpdateIfNeeded()
}
private fun resumeApplicationUpdateIfNeeded() {
appUpdateManager.appUpdateInfo?.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
if (appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
router.requestImmediateUpdate(appUpdateInfo) // calls appUpdateManager.startUpdateFlowForResult
} else {
router.requestFlexibleUpdate(appUpdateInfo)
}
} else if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
showApplicationUpdateSuccessSnackbar()
}
}
}