Hero Image

in_app_purchase Plugin Update 2.0.0 - Whats new?

By Alexander Thiele - Average reading time: 2 minutes

The Flutter team recently update the flutter plugin in_app_purchase to version 2.0.0. We've checked the changes and here is what is new.

What's new in version 2.0.0

Version 2.0.0 has breaking changes and your project will probably need to be adjusted, but don't worry. Only the package names have been changed and a simple renaming should fix the issue.

New PurchaseStatus

The most interesting change is the addition of the new PurchaseStatus.canceled. You can now determine if a purchase got cancelled by the user or by a purchase error.

1 switch (purchaseDetails.status) {
2 case PurchaseStatus.pending:
3 // Pending
4 break;
5 case PurchaseStatus.error:
6 // Purchase Error
7 break;
8 case PurchaseStatus.canceled:
9 // User Cancelled
10 break;
11 case PurchaseStatus.purchased:
12 // Purchase Successful
13 break;
14 case PurchaseStatus.restored:
15 // Purchase Restored
16 // BTW: if there are many purchases, this will be triggered many many times.
17 super.isPendingPurchase = false;
18 break;
19 }

Android Changes

Google Play no longer accepts App submissions that don't support pending purchases. it‘s now no longer necessary to acknowledge this through code by calling InAppPurchaseAndroidPlatformAddition.enablePendingPurchases();

You can delete this code fragment in version 2.0.0 and upwards:

1 if (defaultTargetPlatform == TargetPlatform.android) {
2 InAppPurchaseAndroidPlatformAddition.enablePendingPurchases();
3 }

iOS Changes

The sub plugin in_app_purchase_ios has been renamed to in_app_purchase_storekit. This is no breaking change if you only use the package in_app_purchase. If you use the platform-specific package like the AppStoreProductDetails, then this is a BREAKING CHANGE and you have to change the package name.

From

1import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';

to

1import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';

Other than the package the following class names changed as well:

  • Renames InAppPurchaseIosPlatform to InAppPurchaseStoreKitPlatform
  • RenamesInAppPurchaseIosPlatformAddition to InAppPurchaseStoreKitPlatformAddition

There are no logic changes.

More Changes

  • restorePurchases now always emits an empty list of purchases (was different on iOS before)
  • Adds support for promotional offers on the store_kit_wrappers Dart API.

LinkFive Purchases Changes

For LinkFive users of our linkfive_purchases plugin: There should be no breaking changes for you. Our next version will adapt the version 2.0.1 and everything will work for you!


First published on Dec 13, 2021, last updated on Dec 13, 2021

Ready to get started?