Skip to content

Commit

Permalink
migrate to use in_app_review_platform_interface
Browse files Browse the repository at this point in the history
add Windows support for openStoreListing
  • Loading branch information
britannio committed Oct 24, 2020
1 parent 757b578 commit a4a96d2
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 576 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
in_app_review_platform_interface/.flutter-plugins
in_app_review_platform_interface/.flutter-plugins-dependencies
**/*.flutter-plugins
**/*.flutter-plugins-dependencies
**/*.packages
**/.dart_tool/**
5 changes: 5 additions & 0 deletions in_app_review/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# [1.0.0]

- Migrate to use `in_app_review_platform_interface`.
- Add Windows support for `openStoreListing`.

# [0.2.1+1]

- Improve IOS testing docs.
Expand Down
9 changes: 8 additions & 1 deletion in_app_review/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.1+1"
version: "1.0.0"
in_app_review_platform_interface:
dependency: transitive
description:
name: in_app_review_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher:
dependency: transitive
description:
Expand Down
59 changes: 15 additions & 44 deletions in_app_review/lib/in_app_review.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/services.dart';
import 'package:package_info/package_info.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:in_app_review_platform_interface/in_app_review_platform_interface.dart';

class InAppReview {
InAppReview._();

static final InAppReview instance = InAppReview._();

static const MethodChannel _channel =
const MethodChannel('dev.britannio.in_app_review');

/// Check's if the device is able to show a review dialog.
///
/// On Android the Google Play Store must be installed and the device must be
Expand All @@ -21,7 +15,7 @@ class InAppReview {
/// IOS devices must be running **IOS version 10.3** or higher.
///
/// MacOS devices must be running **MacOS version 10.14** or higher
Future<bool> isAvailable() => _channel.invokeMethod('isAvailable');
Future<bool> isAvailable() => InAppReviewPlatform.instance.isAvailable();

/// Attempts to show the review dialog. It's recommended to first check if
/// this cannot be done via [isAvailable]. If it is not available then
Expand All @@ -35,45 +29,22 @@ class InAppReview {
/// https://developer.android.com/guide/playcore/in-app-review#when-to-request
/// https://developer.apple.com/design/human-interface-guidelines/ios/system-capabilities/ratings-and-reviews/
/// https://developer.apple.com/design/human-interface-guidelines/macos/system-capabilities/ratings-and-reviews/
Future<void> requestReview() => _channel.invokeMethod('requestReview');
Future<void> requestReview() => InAppReviewPlatform.instance.requestReview();

/// Opens the Play Store on Android and opens the App Store with a review
/// screen on IOS & MacOS. [appStoreId] is required for IOS & MacOS.
/// Opens the Play Store on Android, the App Store with a review
/// screen on IOS & MacOS and the Microsoft Store on Windows.
///
/// [appStoreId] is required for IOS & MacOS.
/// [windowsStoreId] is required for Windows.
Future<void> openStoreListing({
/// Required for IOS & MacOS
/// Required for IOS & MacOS.
String appStoreId,
}) async {
final bool isIOS = Platform.isIOS;
final bool isMacOS = Platform.isMacOS;
final bool isAndroid = Platform.isAndroid;

if (isIOS || isMacOS) {
assert(appStoreId != null);

final Uri uri = Uri(
scheme: isIOS ? 'https' : 'macappstore',
host: 'apps.apple.com',
path: 'app/id$appStoreId',
queryParameters: {'action': 'write-review'},
);

await _launchUrl(uri.toString());
} else if (isAndroid) {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();

final String packageName = packageInfo.packageName;

await _launchUrl(
'https://play.google.com/store/apps/details?id=$packageName',
/// Required for Windows.
String windowsStoreId,
}) =>
InAppReviewPlatform.instance.openStoreListing(
appStoreId: appStoreId,
windowsStoreId: windowsStoreId,
);
} else {
throw UnsupportedError('Platform not supported');
}
}

Future<void> _launchUrl(String url) async {
if (await canLaunch(url)) {
await launch(url);
}
}
}
18 changes: 9 additions & 9 deletions in_app_review/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
in_app_review_platform_interface:
dependency: "direct main"
description:
name: js
name: in_app_review_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3-nullsafety.1"
version: "1.0.1"
matcher:
dependency: transitive
description:
Expand All @@ -85,9 +85,9 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.4"
version: "1.3.0-nullsafety.3"
package_info:
dependency: "direct main"
dependency: transitive
description:
name: package_info
url: "https://pub.dartlang.org"
Expand Down Expand Up @@ -125,7 +125,7 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.2"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -162,7 +162,7 @@ packages:
source: hosted
version: "1.3.0-nullsafety.3"
url_launcher:
dependency: "direct main"
dependency: transitive
description:
name: url_launcher
url: "https://pub.dartlang.org"
Expand Down Expand Up @@ -211,5 +211,5 @@ packages:
source: hosted
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.10.0-110 <=2.11.0-213.0.dev"
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.17.0 <2.0.0"
38 changes: 3 additions & 35 deletions in_app_review/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: in_app_review
description: Flutter plugin for showing the In-App Review/System Rating pop up on Android, IOS and MacOS. Makes it easy for users to rate your app.
version: 0.2.1+1
version: 1.0.0
homepage: https://github.com/britannio/in_app_review

environment:
Expand All @@ -10,9 +10,8 @@ environment:
dependencies:
flutter:
sdk: flutter

url_launcher: ^5.7.5
package_info: '>=0.4.3 <2.0.0'

in_app_review_platform_interface: ^1.0.1

dev_dependencies:
flutter_test:
Expand All @@ -36,34 +35,3 @@ flutter:
pluginClass: SwiftInAppReviewPlugin
macos:
pluginClass: InAppReviewPlugin

# To add assets to your plugin package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.

# To add custom fonts to your plugin package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
Loading

0 comments on commit a4a96d2

Please sign in to comment.