Skip to content

Instantly share code, notes, and snippets.

@awaik
Created July 20, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awaik/7806273546b6a901d8691b355a927fac to your computer and use it in GitHub Desktop.
Save awaik/7806273546b6a901d8691b355a927fac to your computer and use it in GitHub Desktop.
check ios subscribtion fluter
if (Platform.isIOS) {
var history = await FlutterInappPurchase.getPurchaseHistory();
for (var purchase in history) {
Duration difference =
DateTime.now().difference(purchase.transactionDate);
if (difference.inMinutes <= (duration + grace).inMinutes &&
purchase.productId == 'SKU_OF_SUBSCRIPTION') return 'PAID_STATE_FOR_YOUR_CHOICE';
}
return 'NOT_PAID_STATE_FOR_YOUR_CHOICE';
}
@sarkaramitabh300
Copy link

HI, what is "duration + grace"? where should I get this info from

@awaik
Copy link
Author

awaik commented Apr 9, 2021

Hi, sorry, I don't remember :)
I switched to this package and service more then a year ago
https://pub.dev/packages/purchases_flutter

Posted it here
https://stackoverflow.com/questions/53880390/how-to-implement-in-app-purchases-subscription-in-flutter/55835182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment