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.

      switch (purchaseDetails.status) {
case PurchaseStatus.pending:
// Pending
break;
case PurchaseStatus.error:
// Purchase Error
break;
case PurchaseStatus.canceled:
// User Cancelled
break;
case PurchaseStatus.purchased:
// Purchase Successful
break;
case PurchaseStatus.restored:
// Purchase Restored
// BTW: if there are many purchases, this will be triggered many many times.
super.isPendingPurchase = false;
break;
}

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:

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

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

import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';

to

import '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?