Skip to content

Commit 2b5cbe7

Browse files
Add support for other iOS stores
1 parent 6540968 commit 2b5cbe7

9 files changed

+36
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes will be documented in this file.
44

5+
## [1.0.9] - 2023-03-18
6+
* Add support for other iOS stores.
7+
58
## [1.0.8] - 2023-03-01
69
* Add Google playstore as default fallback marketplace for android.
710

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ class MyApp extends StatelessWidget {
218218
}
219219
}
220220
```
221+
For IOS, if you want to redirect user to some other store you can use the following parameters:
222+
223+
- preferredIosStore: PreferredIosStore.other
224+
- otherIosStoreUrl: "https://otheriosstoreurl.com/app/id"// Required if preferredAndroidMarket is Other.
221225

222226
### Note:
223227
1. For opening the app store/playstore the app should be live.
@@ -280,7 +284,7 @@ class MyApp extends StatelessWidget {
280284
}
281285
```
282286

283-
## App Upgrade Docs
287+
## App Upgrade
284288
For more information visit [App Upgrade](https://appupgrade.dev)
285289

286290
### Changelog
@@ -298,6 +302,6 @@ The MIT License (MIT). Please see [License File](LICENSE) for more information.
298302
## Need help?
299303

300304
If you're looking for help, try our [Documentation](https://appupgrade.dev/docs/) or our [FAQ](https://appupgrade.dev/docs/app-upgrade-faq).
301-
If you need support please write to us at appupgrade.dev@gmail.com
305+
If you need support please write to us at support@appupgrade.dev
302306

303307
### Happy Coding!!!

example/lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class _MyHomePageState extends State<MyHomePage> {
6161
appLanguage: 'es',
6262
// preferredAndroidMarket: PreferredAndroidMarket.huawei, // or PrefferedAndroidMarket.huawei or PrefferedAndroidMarket.other If not provided default android marketplace is Google playstore. Optional
6363
// otherAndroidMarketUrl: 'https://otherandroidmarketplaceurl.com/app/id', // Required only if PreferredAndroidMarket is other.
64+
// preferredIosStore: PreferredIosStore.other,
65+
// otherIosStoreUrl: "https://otheriosstoreurl.com/app/id"
6466
);
6567

6668
// This is Optional.

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
path: ".."
88
relative: true
99
source: path
10-
version: "1.0.8"
10+
version: "1.0.9"
1111
async:
1212
dependency: transitive
1313
description:

lib/app_upgrade_flutter_sdk.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export 'src/app_upgrade_api.dart';
55
export 'src/app_upgrade_alert.dart';
66
export 'src/app_info.dart';
77
export 'src/dialog_config.dart';
8-
export 'src/preferred_android_market.dart';
8+
export 'src/preferred_android_market.dart';
9+
export 'src/preferred_ios_store.dart';

lib/src/app_info.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class AppInfo {
66
String? appLanguage;
77
String? preferredAndroidMarket;
88
String? otherAndroidMarketUrl;
9+
String? preferredIosStore;
10+
String? otherIosStoreUrl;
911

1012
AppInfo({
1113
required this.appName,
@@ -15,5 +17,7 @@ class AppInfo {
1517
this.appLanguage,
1618
this.preferredAndroidMarket,
1719
this.otherAndroidMarketUrl,
20+
this.preferredIosStore,
21+
this.otherIosStoreUrl,
1822
});
1923
}

lib/src/app_upgrade.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'package:app_upgrade_flutter_sdk/app_upgrade_flutter_sdk.dart';
23
import 'package:flutter/cupertino.dart';
34
import 'package:flutter/material.dart';
45
import 'package:url_launcher/url_launcher.dart';
@@ -235,12 +236,22 @@ class AppUpgrade {
235236
mode: LaunchMode.externalApplication);
236237
}
237238
} else if (Platform.isIOS) {
238-
url = "https://apps.apple.com/app/id/$appId";
239-
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
239+
if (appInfo.preferredIosStore == PreferredIosStore.other && appInfo.otherIosStoreUrl != null) {
240+
url = appInfo.otherIosStoreUrl!;
241+
} else {
242+
url = "https://apps.apple.com/app/id/$appId";
243+
}
244+
try {
245+
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
246+
} catch (e) {
247+
if (debug) {
248+
print('App Upgrade: launch to store failed: $e');
249+
}
250+
}
240251
}
241252
} catch (e) {
242253
if (debug) {
243-
print('App Upgrade: launch to app store failed: $e');
254+
print('App Upgrade: launch to store failed: $e');
244255
}
245256
}
246257
}

lib/src/preferred_ios_store.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class PreferredIosStore {
2+
static const other = 'Other';
3+
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: app_upgrade_flutter_sdk
22
description: The official Flutter SDK for App Upgrade. The SDK integrates with the App Upgrade version check API.
3-
version: 1.0.8
3+
version: 1.0.9
44
homepage: https://github.com/appupgrade-dev/app_upgrade_flutter_sdk
55

66
environment:

0 commit comments

Comments
 (0)