Strong Like Bull
Strong Like Bull

Reputation: 11297

Where to check for expired subscription using non-renewing subscriptions?

We are using non-renewing subscriptions in our iOS application and are confused to when and where expired subscriptions are removed. For instance we show two subscriptions (7 days and 30 days). The user then purchases one of the subscriptions and we save that in NSUserDefaults along with storing in database on the server (creation date, subscription type, expiration date). Now the confusion we have is when the user is past their 7 days (or 30 days), how do we expire the subscription?

We were thinking of doing it in didFinishLaunchingWithOptions however what happens if the user stays logged in and never terminates their application,

Upvotes: 2

Views: 457

Answers (2)

Firo
Firo

Reputation: 15566

I would do it in applicationDidBecomeActive. This is called every time they launch the app even if it was never terminated. I would guess you would be pretty safe with this. If someone is willing to keep your application open constantly to prevent the expiration, then they are pretty dedicated to your app! Also, most people would not know how you checked their subscription so they would probably not think to keep it open.

You should also think about storing their subscription in NSUserDefaults. What if they remove the app and reinstall it? Do you check your database and reload that value into defaults? If it is a small amount of data you could store it in the keychain. The keychain values are not deleted when the app is removed.

Upvotes: 2

Caleb
Caleb

Reputation: 124997

You could check every time the user brings your app to the foreground. To do that, do your check in the app delegate's -applicationWillEnterForeground method. If you want to go a step further, you could use that method to set up a timer that will fire when the subscription expires. That would let you expire the subscription as soon as it ends, even if the end comes while the user is using the app.

Upvotes: 0

Related Questions