@@ -72,27 +72,36 @@ fun UpdateSheet(
72
72
if (context.isInstalledFromPlayStore()) {
73
73
LaunchedEffect (visible) {
74
74
if (visible) {
75
- val appUpdateManager = AppUpdateManagerFactory .create(context)
75
+ runCatching {
76
+ val appUpdateManager = AppUpdateManagerFactory .create(context)
76
77
77
- val appUpdateInfoTask = appUpdateManager.appUpdateInfo
78
+ val appUpdateInfoTask = appUpdateManager.appUpdateInfo
78
79
79
- appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
80
- if (appUpdateInfo.updateAvailability() == UpdateAvailability .UPDATE_AVAILABLE
81
- && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType .IMMEDIATE )
82
- ) {
83
- appUpdateManager.startUpdateFlow(
84
- appUpdateInfo,
85
- context as Activity ,
86
- AppUpdateOptions .defaultOptions(AppUpdateType .IMMEDIATE )
87
- )
88
- } else {
89
- scope.launch {
90
- toastHostState.showToast(
91
- icon = Icons .Rounded .FileDownloadOff ,
92
- message = context.getString(R .string.no_updates)
80
+ appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
81
+ if (appUpdateInfo.updateAvailability() == UpdateAvailability .UPDATE_AVAILABLE
82
+ && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType .IMMEDIATE )
83
+ ) {
84
+ appUpdateManager.startUpdateFlow(
85
+ appUpdateInfo,
86
+ context as Activity ,
87
+ AppUpdateOptions .defaultOptions(AppUpdateType .IMMEDIATE )
93
88
)
89
+ } else {
90
+ scope.launch {
91
+ toastHostState.showToast(
92
+ icon = Icons .Rounded .FileDownloadOff ,
93
+ message = context.getString(R .string.no_updates)
94
+ )
95
+ }
94
96
}
95
97
}
98
+ }.onFailure {
99
+ scope.launch {
100
+ toastHostState.showToast(
101
+ icon = Icons .Rounded .FileDownloadOff ,
102
+ message = context.getString(R .string.no_updates)
103
+ )
104
+ }
96
105
}
97
106
}
98
107
}
0 commit comments