Skip to content

Commit

Permalink
expose available version code - fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Bark committed Nov 4, 2019
1 parent e6ffb74 commit 98e6e16
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.4

* Expose Available Version Code: https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html#availableVersionCode()
(fixes https://github.com/feilfeilundfeil/flutter_in_app_update/issues/7)

## 1.1.3

* Fix Android build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,17 @@ class InAppUpdatePlugin(private val activity: Activity) : MethodCallHandler,
mapOf(
"updateAvailable" to true,
"immediateAllowed" to info.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE),
"flexibleAllowed" to info.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)
"flexibleAllowed" to info.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE),
"availableVersionCode" to info.availableVersionCode()
)
)
} else {
result.success(
mapOf(
"updateAvailable" to false,
"immediateAllowed" to false,
"flexibleAllowed" to false
"flexibleAllowed" to false,
"availableVersionCode" to null
)
)
}
Expand Down
14 changes: 9 additions & 5 deletions lib/in_app_update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class InAppUpdate {
static Future<AppUpdateInfo> checkForUpdate() async {
final result = await _channel.invokeMethod('checkForUpdate');
return AppUpdateInfo(result['updateAvailable'], result['immediateAllowed'],
result['flexibleAllowed']);
result['flexibleAllowed'], result['availableVersionCode']);
}

/// Performs an immediate update that is entirely handled by the Play API.
Expand Down Expand Up @@ -42,9 +42,10 @@ class InAppUpdate {

class AppUpdateInfo {
final bool updateAvailable, immediateUpdateAllowed, flexibleUpdateAllowed;
final int availableVersionCode;

AppUpdateInfo(this.updateAvailable, this.immediateUpdateAllowed,
this.flexibleUpdateAllowed);
this.flexibleUpdateAllowed, this.availableVersionCode);

@override
bool operator ==(Object other) =>
Expand All @@ -53,16 +54,19 @@ class AppUpdateInfo {
runtimeType == other.runtimeType &&
updateAvailable == other.updateAvailable &&
immediateUpdateAllowed == other.immediateUpdateAllowed &&
flexibleUpdateAllowed == other.flexibleUpdateAllowed;
flexibleUpdateAllowed == other.flexibleUpdateAllowed &&
availableVersionCode == other.availableVersionCode;

@override
int get hashCode =>
updateAvailable.hashCode ^
immediateUpdateAllowed.hashCode ^
flexibleUpdateAllowed.hashCode;
flexibleUpdateAllowed.hashCode ^
availableVersionCode.hashCode;

@override
String toString() => 'InAppUpdateState{updateAvailable: $updateAvailable, '
'immediateUpdateAllowed: $immediateUpdateAllowed, '
'flexibleUpdateAllowed: $flexibleUpdateAllowed}';
'flexibleUpdateAllowed: $flexibleUpdateAllowed, '
'availableVersionCode: $availableVersionCode}';
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: in_app_update
description: Enables In App Updates on Android using the official Android APIs.
version: 1.1.3
version: 1.1.4
authors:
- FFUF <info@ffuf.de>
- Jonas Bark <jonas.bark@ffuf.de>
Expand Down

0 comments on commit 98e6e16

Please sign in to comment.