Skip to content

Commit

Permalink
feat(InAppUpdateListener): Add failure listener
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Nov 12, 2024
1 parent cb59a92 commit 93941d5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class BaseInAppUpdateManager(private val activity: FragmentActivity) :

open fun installDownloadedUpdate() = Unit

open fun requireUpdate() = activity.goToPlayStore()
open fun requireUpdate(onFailure: ((Exception) -> Unit)? = null) = activity.goToPlayStore()

open fun init(
mustRequireImmediateUpdate: Boolean = false,
Expand Down
2 changes: 2 additions & 0 deletions Stores/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string name="errorNoAvailableUpdate">Kein Update verfügbar</string>
<string name="updateInstallButton">Installieren</string>
<string name="updateRequiredDescription">Ihre Version der Anwendung wird nicht mehr unterstützt.\nInstallieren Sie die neueste Version und profitieren Sie von den neuesten Verbesserungen und Neuerungen.</string>
</resources>
2 changes: 2 additions & 0 deletions Stores/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string name="errorNoAvailableUpdate">No hay actualizaciones disponibles</string>
<string name="updateInstallButton">Instalar</string>
<string name="updateRequiredDescription">Su versión de la aplicación ya no es compatible.\nInstale la última versión y aproveche las últimas mejoras y nuevas funciones.</string>
</resources>
2 changes: 2 additions & 0 deletions Stores/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string name="errorNoAvailableUpdate">Aucune mise à jour disponible</string>
<string name="updateInstallButton">Installer</string>
<string name="updateRequiredDescription">Votre version de l’application n’est plus supportée.\nInstallez la dernière version et profitez des dernières améliorations et nouveautés.</string>
</resources>
2 changes: 2 additions & 0 deletions Stores/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string name="errorNoAvailableUpdate">Nessun aggiornamento disponibile</string>
<string name="updateInstallButton">Installa</string>
<string name="updateRequiredDescription">La versione dell’applicazione in uso non è più supportata.\nInstalla la versione più recente e approfitta degli ultimi miglioramenti e delle nuove funzionalità.</string>
</resources>
2 changes: 2 additions & 0 deletions Stores/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<string name="updateInstallButton">Install</string>
<string name="errorNoAvailableUpdate">No available update</string>
<string name="updateRequiredDescription">Your application version is no longer supported.\nInstall the latest version and benefit from the latest enhancements and new features.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,16 @@ class InAppUpdateManager(
}
}

override fun requireUpdate() {
override fun requireUpdate(onFailure: ((Exception) -> Unit)?) {
appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
if (updateType == AppUpdateType.IMMEDIATE) {
val isUpdateStalled =
appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS
if (isUpdateStalled || !viewModel.isUpdateBottomSheetShown) startUpdateFlow(appUpdateInfo)
}
}.addOnFailureListener {
it.printStackTrace()
onFailure?.invoke(it)
}
}

Expand Down

0 comments on commit 93941d5

Please sign in to comment.