Skip to content

Commit

Permalink
Catch app update errors and fallback to store
Browse files Browse the repository at this point in the history
  • Loading branch information
cachapa committed Aug 10, 2023
1 parent 2b90032 commit c50c77c
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 95 deletions.
15 changes: 14 additions & 1 deletion lib/lists/list_manager_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ class _ListManagerPageState extends State<ListManagerPage> {

if (result == true) {
if (Platform.isAndroid) {
await InAppUpdate.performImmediateUpdate();
final result = await _attemptAppUpdate();
if (result == AppUpdateResult.inAppUpdateFailed) {
await launchUrlString(
'https://play.google.com/store/apps/details?id=net.cachapa.tudo');
}
} else {
await launchUrlString(
'https://apps.apple.com/us/app/tudo-lists/id1550819275');
Expand All @@ -267,3 +271,12 @@ class _ListManagerPageState extends State<ListManagerPage> {
}
}
}

Future<AppUpdateResult> _attemptAppUpdate() async {
try {
return await InAppUpdate.performImmediateUpdate();
} on Exception catch (e) {
print(e);
return AppUpdateResult.inAppUpdateFailed;
}
}
Loading

0 comments on commit c50c77c

Please sign in to comment.