Discussions
In-app purchases issue. iOS + Flutter
I’m building an app with in-app purchases (subscriptions) and stuck with implementing and testing using the in_app_purchase 0.3.5+1 flutter package https://pub.dev/packages/in_app_purchase
Each time when I open my iOS app the in-app purchases are not initializing automatically. Only when I tap the Subscribe button. This issue related to iOS only. Android works well.
Each time when I open my iOS app the in-app purchases are not initializing automatically. Only when I tap the Subscribe button. This issue related to iOS only. Android works well. Future<void> initializeIap() async { iapAvailable = await _iap.isAvailable(); if (iapAvailable) { await _getProducts(); await _getPastPurchases(); _subscription = _iap.purchaseUpdatedStream.listen((data) { _purchases.addAll(data); _verifyPurchase(); }); _verifyPurchase(); } }
Future<void> _getPastPurchases() async { QueryPurchaseDetailsResponse response = await _iap.queryPastPurchases(); //TODO: IOS Complete Purchases for (PurchaseDetails purchase in response.pastPurchases) { if (Platform.isIOS) { InAppPurchaseConnection.instance.completePurchase(purchase); } } _purchases = response.pastPurchases; }