Skip to content

Commit 7227263

Browse files
Add README instructions for enablePendingPurchases (flutter#2921)
Add README instructions for enablePendingPurchases. If a developer attempts to access this plugin on Android without invoking enablePendingPurchases, an exception is thrown. Related StackOverflow post: https://stackoverflow.com/questions/60046903/flutter-in-app-purchase-enablependingpurchases-enablependingpurchases-must
1 parent f8f666f commit 7227263

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Diff for: packages/in_app_purchase/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.4+5
2+
3+
* Added necessary README docs for getting started with Android.
4+
15
## 0.3.4+4
26

37
* Update package:e2e -> package:integration_test

Diff for: packages/in_app_purchase/README.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ use.
5151

5252
### Initializing the plugin
5353

54+
```dart
55+
void main() {
56+
// Inform the plugin that this app supports pending purchases on Android.
57+
// An error will occur on Android if you access the plugin `instance`
58+
// without this call.
59+
//
60+
// On iOS this is a no-op.
61+
InAppPurchaseConnection.enablePendingPurchases();
62+
63+
runApp(MyApp());
64+
}
65+
```
66+
5467
```dart
5568
// Subscribe to any incoming purchases at app initialization. These can
5669
// propagate from either storefront so it's important to listen as soon as
@@ -90,7 +103,7 @@ if (!available) {
90103
// Set literals require Dart 2.2. Alternatively, use `Set<String> _kIds = <String>['product1', 'product2'].toSet()`.
91104
const Set<String> _kIds = {'product1', 'product2'};
92105
final ProductDetailsResponse response = await InAppPurchaseConnection.instance.queryProductDetails(_kIds);
93-
if (!response.notFoundIDs.isEmpty) {
106+
if (response.notFoundIDs.isNotEmpty) {
94107
// Handle the error.
95108
}
96109
List<ProductDetails> products = response.productDetails;

Diff for: packages/in_app_purchase/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: in_app_purchase
22
description: A Flutter plugin for in-app purchases. Exposes APIs for making in-app purchases through the App Store and Google Play.
33
homepage: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase
4-
version: 0.3.4+4
4+
version: 0.3.4+5
55

66
dependencies:
77
async: ^2.0.8

0 commit comments

Comments
 (0)