我已经集成了应用内功能,但它返回 UPDATE_NOT_AVAILABLE 而在 Playstore 上我可以看到更新按钮并且我的应用版本低于 Playstore 版本。
fun updateAppIfAvailable(context: Context) {
val appUpdateManager = AppUpdateManagerFactory.create(context)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
Toast.makeText(context, "Update available " + appUpdateInfo.updateAvailability() + " " + appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE) + " " + appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE), Toast.LENGTH_LONG).show()
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
appUpdateManager.startUpdateFlowForResult(appUpdateInfo, AppUpdateType.FLEXIBLE, context as Activity, RequestCodes.REQUEST_CODE_IN_APP_UPDATE)
}
}
appUpdateInfoTask.addOnFailureListener {
Toast.makeText(context, "Exception Update available " + it, Toast.LENGTH_LONG).show()
}
}
任何帮助,将不胜感激。