Kalzem
Kalzem

Reputation: 7492

How to handle auto-renewal subscription ending during app life time

If the user has a weekly auto-renewal subscription running that has the current week expiring at 4:00 (then it will renew) and the user is on the app from 3:55 until 4:10 for example, how are you suppose to handle it?

I noticed that paymentQueue(_:updatedTransactions:) won't trigger during the app lifecycle (maybe I'm wrong?), and so I can't get the new renewal that will inform me that the user is still subscribed.

In this case, do I need to call a restore purchase to force detect a renewal, or should I consider the user still being subscribed until the app is killed (and so at the next launch, paymentQueue will be triggered)? Or maybe a third solution?

Upvotes: 1

Views: 209

Answers (2)

Kalzem
Kalzem

Reputation: 7492

Got an official answer from an Apple StoreKit Engineer:

Apple considers this to be an edge case and suggests that you don't handle expiration of subscriptions in real-time (if possible).

This means that if you have a subscription that turns your users into Premium users, just keep the Premium flag true during the entire lifecycle of the app (until the app is killed by the user or the system).

Next time the app is relaunched, you can rely on a potential new paymentQueue:updatedTransaction.

Upvotes: 3

Paul Schröder
Paul Schröder

Reputation: 1540

You could do this by registering a timer and a) trigger a restore or b) restart the app or c) validate with your server, which handels server-to-server notifications.

I don't know what kind of app you are developing and how crucial it is that users shouldn't be able to use the app longer than their subscription duration, but forcing the user to type in his credentials without his explicit consent (point a) or restarting the app (point b) would be bad user experience. So if it is crucial, then you probably need to use server-to-server notifications. Otherwise let the user use your app till he closes it and validate the receipt with the next start on your device.

Server-to-server notifications are a service for auto-renewable subscriptions. The App Store sends notifications to your server of real-time changes in a subscription's status.

For details see here

Upvotes: 1

Related Questions