Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
kauemurakami committed Feb 24, 2023
1 parent 9f48f23 commit 87de728
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
5 changes: 1 addition & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ class _MyHomePageState extends State<MyHomePage> {
}

void _verifyVersion() async {
PackageInfo? packageInfo = await PackageInfo.fromPlatform();
await AppVersionUpdate.checkForUpdates(
appleId: '284882215',
playStoreId: 'com.facebook.katana',
country: 'br')
appleId: '1459706595', playStoreId: 'com.byebnk.app', country: 'br')
.then((data) async {
print(data);
if (data.canUpdate!) {
Expand Down
10 changes: 5 additions & 5 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ packages:
app_version_update:
dependency: "direct main"
description:
name: app_version_update
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
path: ".."
relative: true
source: path
version: "3.0.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -136,7 +136,7 @@ packages:
source: hosted
version: "1.8.0"
package_info_plus:
dependency: "direct main"
dependency: transitive
description:
name: package_info_plus
url: "https://pub.dartlang.org"
Expand Down
5 changes: 2 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
version: 1.0.0
# nothing update
# version: 1000.0.0+1

Expand All @@ -31,9 +31,8 @@ environment:
dependencies:
flutter:
sdk: flutter
package_info_plus:
app_version_update:
# path: ../
path: ../

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down
25 changes: 14 additions & 11 deletions lib/app_version_update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ class AppVersionUpdate {
Uri.https(playStoreAuthority, playStoreUndecodedPath, parameters);
final response =
await http.get(uri, headers: headers).catchError((e) => throw e);
AppVersionResult appVersionResult = AppVersionResult(
canUpdate: convertVersion(
version: packageInfo.version,
versionStore: RegExp(r',\[\[\["([0-9,\.]*)"]],')
.firstMatch(response.body)!
.group(1)!),
storeUrl: uri.toString(),
storeVersion: RegExp(r',\[\[\["([0-9,\.]*)"]],')
.firstMatch(response.body)!
.group(1),
platform: TargetPlatform.android);
AppVersionResult? appVersionResult;
final versionMatch =
RegExp(r',\[\[\["([0-9,\.]*)"]],').firstMatch(response.body);
if (versionMatch != null) {
appVersionResult = AppVersionResult(
canUpdate: convertVersion(
version: packageInfo.version,
versionStore: versionMatch.group(1)!),
storeUrl: uri.toString(),
storeVersion: versionMatch.group(1),
platform: TargetPlatform.android);
} else {
throw "Could not find version information in Play Store response.";
}
if (response.statusCode != 200) {
throw " Aplication not found in Play Store, verify your app id. ";
}
Expand Down

0 comments on commit 87de728

Please sign in to comment.