I am working on an app that has a auto-renewable subscription that gives users 200 tokens to use in the app each month. I have written a firebase cloud function to verify the receipt with apple and give the user the first 200 tokens on initial purchase, but I don't know how to continue to give the users a fixed amount of 200 tokens each month if their subscription is still valid. Could I store the receipt from the initial purchase of the subscription on my servers and use a monthly recurring firebase cloud function that checks the user's receipt from their initial purchase of the subscription to see if it's valid? Do old receipts tell you if a subscription is still valid like that? I also looked into Server to Server notifications but I am not very sure if the automatic renewal of a subscription gets sent as an event.
How to get notified each time a user's Auto-renewable subscription renews
Currently, the onus is on the app process to determine that an auto-renewing subscription has renewed. If you have server-to-server notifications implemented, you will observe that there is the RENEWAL notification
RENEWAL - Automatic renewal was successful for an expired subscription. Check Subscription Expiration Date to determine the next renewal date and time.
Clarification - in general, iTunes will attempt to charge the user account a day before an auto-renewing subscription is scheduled to expire. If the renewal is successful, there is no server-to server notification because the auto-renewing subscription did not enter into an expired state. However, in the few cases that iTunes is unable to renew the subscription (generally there was a connection problem with the credit card server) and the auto-renewing subscription is not renewed before the expiration_date passes, the auto-renewing subscription is technically considered “expired”. However, iTunes will still continue to attempt to renew the subscription. If iTunes is successful, then the “RENEWAL” event is sent. for this reason, the advice is presented - “Check Subscription Expiration Date to determine the next renewal date and time.”
At the recent WWDC, in the Whats new with in-app purchases there are plans to implement the DID_RENEW notification. That's in the future. For now, one means to detect the renewal is to validate the appStoreReceipt saved when the auto-renewing subscription was purchased. This can be performed from the server you mention. When the renewal transaction is processed, the "latest receipt info" section will contain a record for the renewal showing an "expiration date" later than the current date.
Of course there are other issues which can occur with auto-renewing subscriptions - and they are discussed in the Whats new with in-app purchases session.
rich kubota - rkubota@apple.com
developer technical support CoreOS/Hardware/MFI
RENEWAL - Automatic renewal was successful for an expired subscription. Check Subscription Expiration Date to determine the next renewal date and time.
Clarification - in general, iTunes will attempt to charge the user account a day before an auto-renewing subscription is scheduled to expire. If the renewal is successful, there is no server-to server notification because the auto-renewing subscription did not enter into an expired state. However, in the few cases that iTunes is unable to renew the subscription (generally there was a connection problem with the credit card server) and the auto-renewing subscription is not renewed before the expiration_date passes, the auto-renewing subscription is technically considered “expired”. However, iTunes will still continue to attempt to renew the subscription. If iTunes is successful, then the “RENEWAL” event is sent. for this reason, the advice is presented - “Check Subscription Expiration Date to determine the next renewal date and time.”
At the recent WWDC, in the Whats new with in-app purchases there are plans to implement the DID_RENEW notification. That's in the future. For now, one means to detect the renewal is to validate the appStoreReceipt saved when the auto-renewing subscription was purchased. This can be performed from the server you mention. When the renewal transaction is processed, the "latest receipt info" section will contain a record for the renewal showing an "expiration date" later than the current date.
Of course there are other issues which can occur with auto-renewing subscriptions - and they are discussed in the Whats new with in-app purchases session.
rich kubota - rkubota@apple.com
developer technical support CoreOS/Hardware/MFI