Skip to content

Commit

Permalink
fix: Catch crash when resultLauncher is not unregistered we don't kno…
Browse files Browse the repository at this point in the history
…w why
  • Loading branch information
FabianDevel committed Nov 19, 2024
1 parent 5b55ce1 commit ae25564
Showing 1 changed file with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.infomaniak.lib.stores.BaseInAppUpdateManager
import com.infomaniak.lib.stores.StoreUtils
import com.infomaniak.lib.stores.StoresSettingsRepository
import io.sentry.Sentry
import io.sentry.SentryLevel

/**
* Manager encapsulating all the needed logic for Google Play's in-app update api
Expand Down Expand Up @@ -199,13 +200,24 @@ class InAppUpdateManager(
}

private fun startUpdateFlow(appUpdateInfo: AppUpdateInfo) = with(appUpdateManager) {
registerListener(installStateUpdatedListener)
viewModel.isUpdateBottomSheetShown = true
startUpdateFlowForResult(
appUpdateInfo,
inAppUpdateResultLauncher,
AppUpdateOptions.newBuilder(updateType).build(),
)
runCatching {
registerListener(installStateUpdatedListener)
viewModel.isUpdateBottomSheetShown = true
startUpdateFlowForResult(
appUpdateInfo,
inAppUpdateResultLauncher,
AppUpdateOptions.newBuilder(updateType).build(),
)
}.onFailure { exception ->
exception.printStackTrace()
exception.message?.let {
Sentry.captureMessage(it, SentryLevel.WARNING) { scope ->
scope.setExtra("contract", inAppUpdateResultLauncher.contract.toString())
scope.setTag("updateType", updateType.toString())
scope.setTag("onInstallFailure is null", (onInstallFailure == null).toString())
}
}
}
}

private class AppUpdateException(override val message: String?) : Exception()
Expand Down

0 comments on commit ae25564

Please sign in to comment.