Upgrade in_app_purchase
This commit is contained in:
parent
e2fb00af59
commit
1159b8e6f3
5 changed files with 38 additions and 41 deletions
|
@ -7,7 +7,6 @@ import 'package:background_fetch/background_fetch.dart';
|
|||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:photos/app.dart';
|
||||
|
@ -128,7 +127,6 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
|
|||
} else {
|
||||
AppLifecycleService.instance.onAppInForeground('init via: $via');
|
||||
}
|
||||
InAppPurchaseConnection.enablePendingPurchases();
|
||||
CryptoUtil.init();
|
||||
await NotificationService.instance.init();
|
||||
await Network.instance.init();
|
||||
|
|
|
@ -38,12 +38,11 @@ class BillingService {
|
|||
Future<BillingPlans> _future;
|
||||
|
||||
Future<void> init() async {
|
||||
InAppPurchaseConnection.enablePendingPurchases();
|
||||
// if (Platform.isIOS && kDebugMode) {
|
||||
// await FlutterInappPurchase.instance.initConnection;
|
||||
// FlutterInappPurchase.instance.clearTransactionIOS();
|
||||
// }
|
||||
InAppPurchaseConnection.instance.purchaseUpdatedStream.listen((purchases) {
|
||||
InAppPurchase.instance.purchaseStream.listen((purchases) {
|
||||
if (_isOnSubscriptionPage) {
|
||||
return;
|
||||
}
|
||||
|
@ -54,11 +53,11 @@ class BillingService {
|
|||
purchase.verificationData.serverVerificationData,
|
||||
).then((response) {
|
||||
if (response != null) {
|
||||
InAppPurchaseConnection.instance.completePurchase(purchase);
|
||||
InAppPurchase.instance.completePurchase(purchase);
|
||||
}
|
||||
});
|
||||
} else if (Platform.isIOS && purchase.pendingCompletePurchase) {
|
||||
InAppPurchaseConnection.instance.completePurchase(purchase);
|
||||
InAppPurchase.instance.completePurchase(purchase);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -60,9 +60,8 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
}
|
||||
|
||||
void _setupPurchaseUpdateStreamListener() {
|
||||
_purchaseUpdateSubscription = InAppPurchaseConnection
|
||||
.instance.purchaseUpdatedStream
|
||||
.listen((purchases) async {
|
||||
_purchaseUpdateSubscription =
|
||||
InAppPurchase.instance.purchaseStream.listen((purchases) async {
|
||||
if (!_dialog.isShowing()) {
|
||||
await _dialog.show();
|
||||
}
|
||||
|
@ -74,7 +73,7 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
purchase.productID,
|
||||
purchase.verificationData.serverVerificationData,
|
||||
);
|
||||
await InAppPurchaseConnection.instance.completePurchase(purchase);
|
||||
await InAppPurchase.instance.completePurchase(purchase);
|
||||
String text = "Thank you for subscribing!";
|
||||
if (!widget.isOnboarding) {
|
||||
final isUpgrade = _hasActiveSubscription &&
|
||||
|
@ -121,7 +120,7 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
return;
|
||||
}
|
||||
} else if (Platform.isIOS && purchase.pendingCompletePurchase) {
|
||||
await InAppPurchaseConnection.instance.completePurchase(purchase);
|
||||
await InAppPurchase.instance.completePurchase(purchase);
|
||||
await _dialog.hide();
|
||||
} else if (purchase.status == PurchaseStatus.error) {
|
||||
await _dialog.hide();
|
||||
|
@ -395,8 +394,7 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
}
|
||||
await _dialog.show();
|
||||
final ProductDetailsResponse response =
|
||||
await InAppPurchaseConnection.instance
|
||||
.queryProductDetails({productID});
|
||||
await InAppPurchase.instance.queryProductDetails({productID});
|
||||
if (response.notFoundIDs.isNotEmpty) {
|
||||
_logger.severe(
|
||||
"Could not find products: " + response.notFoundIDs.toString(),
|
||||
|
@ -410,34 +408,15 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
_currentSubscription.productID != freeProductID &&
|
||||
_currentSubscription.productID != plan.androidID;
|
||||
if (isCrossGradingOnAndroid) {
|
||||
final existingProductDetailsResponse =
|
||||
await InAppPurchaseConnection.instance
|
||||
.queryProductDetails({_currentSubscription.productID});
|
||||
if (existingProductDetailsResponse.notFoundIDs.isNotEmpty) {
|
||||
_logger.severe(
|
||||
"Could not find existing products: " +
|
||||
response.notFoundIDs.toString(),
|
||||
);
|
||||
await _dialog.hide();
|
||||
showGenericErrorDialog(context);
|
||||
return;
|
||||
}
|
||||
final subscriptionChangeParam = ChangeSubscriptionParam(
|
||||
oldPurchaseDetails: PurchaseDetails(
|
||||
purchaseID: null,
|
||||
productID: _currentSubscription.productID,
|
||||
verificationData: null,
|
||||
transactionDate: null,
|
||||
),
|
||||
);
|
||||
await InAppPurchaseConnection.instance.buyNonConsumable(
|
||||
purchaseParam: PurchaseParam(
|
||||
productDetails: response.productDetails[0],
|
||||
changeSubscriptionParam: subscriptionChangeParam,
|
||||
),
|
||||
await _dialog.hide();
|
||||
showErrorDialog(
|
||||
context,
|
||||
"Could not update subscription",
|
||||
"Please contact support@ente.io and we will be happy to help!",
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
await InAppPurchaseConnection.instance.buyNonConsumable(
|
||||
await InAppPurchase.instance.buyNonConsumable(
|
||||
purchaseParam: PurchaseParam(
|
||||
productDetails: response.productDetails[0],
|
||||
),
|
||||
|
|
23
pubspec.lock
23
pubspec.lock
|
@ -601,7 +601,28 @@ packages:
|
|||
name: in_app_purchase
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.5.2"
|
||||
version: "3.0.7"
|
||||
in_app_purchase_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: in_app_purchase_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.3+5"
|
||||
in_app_purchase_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: in_app_purchase_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.2"
|
||||
in_app_purchase_storekit:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: in_app_purchase_storekit
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.2+2"
|
||||
intl:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -68,7 +68,7 @@ dependencies:
|
|||
image: ^3.0.2
|
||||
image_editor: ^1.0.0
|
||||
implicitly_animated_reorderable_list: ^0.4.0
|
||||
in_app_purchase: ^0.5.2
|
||||
in_app_purchase: ^3.0.7
|
||||
intl: ^0.17.0
|
||||
like_button: ^2.0.2
|
||||
loading_animations: ^2.1.0
|
||||
|
|
Loading…
Add table
Reference in a new issue