Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add app update failure listener #234

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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="errorNoAvailableUpdate">No available update</string>
<string name="updateInstallButton">Install</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
Loading