Skip to main content

This is the scenario.
I develop with Flutter.
I have a subscription that is automatically renewed monthly or annually.
My app can safely work with all the features even off-line.
Of course, to subscribe, you need to be online.
But I wonder: if after the first monthly subscription, the user always uses my app off-line (he must of course remember to put the device off-line before using it), how can I check if the subscription has been deleted?
Can there be a way?
Thanks for any suggestion.

You can call the .getPurchaserInfo() method the same way you would as if the device is offline. 

The latest PurchaserInfo object is cached on the device, and will always be returned first. The cache will get updated when a network connection resumes.

What this means for your customers is that the subscription status will remain the same as what it was when the device went offline.

 

how can I check if the subscription has been deleted?

You’ll need a network connection to detect any changes in the subscription that may have occurred while offline. If this is a hard requirement, then you should not allow offline usage of your app.


Thanks for the precise explanation.
In my application, being able to be used off-line is a feature that I would like to leave behind because it gives an extra option. However, the problem of detecting whether the subscription is still active is fundamental.
Could you give me some advice on how to solve the problem. Maybe using the property:
purchaserInfo.entitlements.all [entitlementID] ?. expirationDate


Unfortunately I can’t think of a way to get a 100% correct subscription status without a network connection.

You could get the expiration date of the entitlement, but you can’t be sure what is supposed to happen after that - detecting a renewal or cancellation would require a network connection. 

Also, the device date is easy to change by dimply changing the date/time on the phone so you shouldn’t do any comparisons to the device `Date()`, only a server timestamp.


Thanks.


Interesting thread. I was wondering whether the isActive property could be more sophisticated using the data available such as expiration date, and willRenew. Point taken the date on the device could be edited, but for 99% of people editing their device date to get free subscriptions would never be worth the trade off. 


I agree with you


I have a similar requirement as Carlo Sacchetti and instead of using purchaserInfo.entitlement.expiryDate I was thinking of using both:

  • purchaserInfo.entitlementstpremiumEntitlementID].isActive
  • purchaserInfo.requestDate.

Here is my detailed solution:

I was thinking of checking the purchaserInfo.entitlementstpremiumEntitlementID].isActive, by calling Purchases.shared.purchaserInfo() at 2 places:
- when the app becomes active.
- when the app is active and the internet connection becomes actives.

Then anytime a user would access a premium feature, the app would first make sure the premium entitlement is active and purchaserInfo.requestDate is not older than 24h, otherwise I would consider the premium entitlement to be stale and kindly ask the user to go online to keep using the premium features.

Provided the user does not change their phone date, would you consider this to be a workable solution? Is this any better actually than checking on purchaserInfo.entitlement.expiryDate?


You could always unpack the customer info while offline and check against the expiration date.


As much as the device is offline, any other check will be relative to the device's DateTime. This can be manipulated/backdated to give the user extended usage, taking us back to the original problem of being offline.
 


Reply