Skip to content

Commit

Permalink
android in app update implemented #1100
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Jan 25, 2023
1 parent 0244df9 commit ccebb4f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lib/app_upgrade/view/app_upgrade_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:altme/l10n/l10n.dart';
import 'package:altme/splash/splash.dart';
import 'package:altme/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:in_app_update/in_app_update.dart';
import 'package:secure_storage/secure_storage.dart';
import 'package:url_launcher/url_launcher.dart';

Expand Down Expand Up @@ -32,7 +33,8 @@ class AppUpgradeView extends StatelessWidget {
final StoreInfo storeInfo;

Future<void> launchAppStore(String appStoreLink) async {
debugPrint(appStoreLink);
final log = getLogger('AppUpgradeView - launchAppStore');
log.i('Launching $appStoreLink');
if (await canLaunchUrl(Uri.parse(appStoreLink))) {
await launchUrl(Uri.parse(appStoreLink));
} else {
Expand Down Expand Up @@ -100,8 +102,26 @@ class AppUpgradeView extends StatelessWidget {
],
const SizedBox(height: 30),
MyGradientButton(
onPressed: () async {
await launchAppStore(storeInfo.appStoreLink);
onPressed: () {
final log = getLogger('AppUpgradeView - onPress');
if (isAndroid()) {
log.i('checkFor Androdi Update');
InAppUpdate.checkForUpdate().then((info) {
log.i('info - $info');
InAppUpdate.performImmediateUpdate().then((_) {
log.i('Update Complete');
}).catchError((dynamic e) {
log.e(e.toString());
launchAppStore(storeInfo.appStoreLink);
});
}).catchError((dynamic e) {
log.e(e.toString());
launchAppStore(storeInfo.appStoreLink);
});
} else {
log.i('iOS update');
launchAppStore(storeInfo.appStoreLink);
}
},
text: 'Update Now',
),
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
in_app_update:
dependency: "direct main"
description:
name: in_app_update
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
intl:
dependency: "direct main"
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ dependencies:
web3dart: ^2.3.3
webview_flutter: ^4.0.1
workmanager: ^0.5.0
in_app_update: ^4.0.1

dependency_overrides:
# Because flutter_sodium 0.2.0 depends on ffi ^1.0.0 and no versions of flutter_sodium match >0.2.0 <0.3.0, flutter_sodium ^0.2.0 requires ffi ^1.0.0
Expand Down

0 comments on commit ccebb4f

Please sign in to comment.