From 31512351ce7f9ff716ad1e89f857a67920e4eb22 Mon Sep 17 00:00:00 2001 From: Jonathan Salmon Date: Mon, 28 Oct 2019 22:57:08 +0000 Subject: [PATCH 1/2] #116 changed Future to Future due to dart sdk change --- example/README.md | 6 +++--- example/lib/main.dart | 6 +++--- lib/flutter_inapp_purchase.dart | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/example/README.md b/example/README.md index 583b5615..8b783dcf 100644 --- a/example/README.md +++ b/example/README.md @@ -81,7 +81,7 @@ class _InAppState extends State { FlutterInappPurchase.instance.requestPurchase(item.productId); } - Future _getProduct() async { + Future _getProduct() async { List items = await FlutterInappPurchase.instance.getProducts(_productLists); for (var item in items) { print('${item.toString()}'); @@ -94,7 +94,7 @@ class _InAppState extends State { }); } - Future _getPurchases() async { + Future _getPurchases() async { List items = await FlutterInappPurchase.instance.getAvailablePurchases(); for (var item in items) { @@ -108,7 +108,7 @@ class _InAppState extends State { }); } - Future _getPurchaseHistory() async { + Future _getPurchaseHistory() async { List items = await FlutterInappPurchase.instance.getPurchaseHistory(); for (var item in items) { print('${item.toString()}'); diff --git a/example/lib/main.dart b/example/lib/main.dart index a5e17246..afe73047 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -105,7 +105,7 @@ class _InAppState extends State { FlutterInappPurchase.instance.requestPurchase(item.productId); } - Future _getProduct() async { + Future _getProduct() async { List items = await FlutterInappPurchase.instance.getProducts(_productLists); for (var item in items) { print('${item.toString()}'); @@ -118,7 +118,7 @@ class _InAppState extends State { }); } - Future _getPurchases() async { + Future _getPurchases() async { List items = await FlutterInappPurchase.instance.getAvailablePurchases(); for (var item in items) { @@ -132,7 +132,7 @@ class _InAppState extends State { }); } - Future _getPurchaseHistory() async { + Future _getPurchaseHistory() async { List items = await FlutterInappPurchase.instance.getPurchaseHistory(); for (var item in items) { print('${item.toString()}'); diff --git a/lib/flutter_inapp_purchase.dart b/lib/flutter_inapp_purchase.dart index 3d1e7c06..2ededb8b 100644 --- a/lib/flutter_inapp_purchase.dart +++ b/lib/flutter_inapp_purchase.dart @@ -221,7 +221,7 @@ class FlutterInappPurchase { /// Result will be received in `purchaseUpdated` listener or `purchaseError` listener. /// /// Identical to [requestSubscription] on `iOS`. - Future requestPurchase(String sku, { + Future requestPurchase(String sku, { String developerIdAndroid, String accountIdAndroid, }) async { @@ -250,7 +250,7 @@ class FlutterInappPurchase { /// **NOTICE** second parameter is required on `Android`. /// /// Identical to [requestPurchase] on `iOS`. - Future requestSubscription(String sku, + Future requestSubscription(String sku, { String oldSkuAndroid, int prorationModeAndroid, @@ -293,8 +293,8 @@ class FlutterInappPurchase { /// Add Store Payment (iOS only) /// Indicates that the App Store purchase should continue from the app instead of the App Store. /// - /// @returns {Future} will receive result from `purchasePromoted` listener. - Future requestPromotedProductIOS() async { + /// @returns {Future} will receive result from `purchasePromoted` listener. + Future requestPromotedProductIOS() async { if (_platform.isIOS) { return await _channel.invokeMethod('requestPromotedProduct'); } @@ -303,8 +303,8 @@ class FlutterInappPurchase { /// Buy product with offer /// - /// @returns {Future} will receive result from `purchaseUpdated` listener. - Future requestProductWithOfferIOS( + /// @returns {Future} will receive result from `purchaseUpdated` listener. + Future requestProductWithOfferIOS( String sku, String forUser, String withOffer, ) async { if (_platform.isIOS) { @@ -319,8 +319,8 @@ class FlutterInappPurchase { /// Buy product with quantity /// - /// @returns {Future} will receive result from `purchaseUpdated` listener. - Future requestPurchaseWithQuantityIOS( + /// @returns {Future} will receive result from `purchaseUpdated` listener. + Future requestPurchaseWithQuantityIOS( String sku, int quantity, ) async { if (_platform.isIOS) { @@ -582,7 +582,7 @@ class FlutterInappPurchase { ); } - Future _setPurchaseListener() async { + Future _setPurchaseListener() async { if (_purchaseController == null) { _purchaseController = new StreamController.broadcast(); } @@ -624,7 +624,7 @@ class FlutterInappPurchase { }); } - Future _removePurchaseListener() async { + Future _removePurchaseListener() async { if (_purchaseController != null) { _purchaseController ..add(null) From 4a592f5ce7c6122140b3fc6f9c5599c230b2a824 Mon Sep 17 00:00:00 2001 From: Jonathan Salmon Date: Sat, 11 Jan 2020 18:47:19 +0000 Subject: [PATCH 2/2] Make amazon purchase trigger callback --- .../flutterinapppurchase/AmazonInappPurchasePlugin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/dooboolab/flutterinapppurchase/AmazonInappPurchasePlugin.java b/android/src/main/java/com/dooboolab/flutterinapppurchase/AmazonInappPurchasePlugin.java index 1c0c7370..e7a065fb 100644 --- a/android/src/main/java/com/dooboolab/flutterinapppurchase/AmazonInappPurchasePlugin.java +++ b/android/src/main/java/com/dooboolab/flutterinapppurchase/AmazonInappPurchasePlugin.java @@ -38,10 +38,11 @@ public class AmazonInappPurchasePlugin implements MethodCallHandler { public static Registrar reg; private final String TAG = "InappPurchasePlugin"; private Result result = null; + private static MethodChannel channel; /** Plugin registration. */ public static void registerWith(Registrar registrar) { - final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_inapp"); + channel = new MethodChannel(registrar.messenger(), "flutter_inapp"); channel.setMethodCallHandler(new FlutterInappPurchasePlugin()); reg = registrar; } @@ -208,6 +209,7 @@ public void onPurchaseResponse(PurchaseResponse response) { transactionDate.doubleValue()); Log.d(TAG, "opr Putting "+item.toString()); result.success(item.toString()); + channel.invokeMethod("purchase-updated", item.toString()); } catch (JSONException e) { result.error(TAG, "E_BILLING_RESPONSE_JSON_PARSE_ERROR", e.getMessage()); }