In-App Purchases; Subscription Status Notification Retry - ios

Using In-App Purchases, Does the subscription status notification via Subscription status URL has a retry mechanism? That is if the receiving server is down what happens to the call made, is it lost?
Apple documents for the same
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html

Related

DID_RECOVER server-to-server notification during Sandbox testing

I'm testing an auto-renewable subscription using a Sandbox account and observing the server-to-server notifications that are received during one purchase cycle (initial purchase, auto-renewals, expiration of a single in-app purchase product).
Logs of the notification_type of each notification that is received:
INITIAL_BUY // initial purchase
DID_CHANGE_RENEWAL_STATUS
DID_RENEW // first renewal
DID_RENEW // second renewal
DID_RENEW // third renewal
DID_RENEW // fourth renewal
DID_RECOVER // why does this happen?
DID_RENEW // fifth (last) renewal
DID_CHANGE_RENEWAL_STATUS // auto-cancellation in sandbox mode
I tried this process repeatedly with different Sandbox testers and noticed the same behavior. Is there an explanation for why the DID_RECOVER notification is received each time?
It's weird that you get that notification, for 2 reasons:
It is a notification related to billing issues
According to the documentation, this notification is not available in Sandbox
https://developer.apple.com/documentation/appstoreservernotifications/notification_type
Test Notification Events with Sandbox (picture)

Apple Server to Server notification not receiving from the sandbox for testing subscription renewal

I am trying to update the user's subscription renewal state. I had set up the endpoint in the app information section "URL for App Store Server Notifications" in the app information. But didn't receive any notification. Also, I had tried to set up revenuecat but got no notification. Does anyone know about this issue?

Apple Sandbox: Only receive 'INITIAL_BUY' server notifications

We have setup Apple’s Server notifications for auto-renewable subscriptions. Last month we still able to get all notification type(INITIAL_BUY, RENEWAL, INTERACTIVE_RENEWAL).
Recently when we tested with sandbox (1 year subscription), we receive only 'INITIAL_BUY' server notifications, we were expect to receive 'RENEWAL' server notifications after 1 hour, but we are not getting those notifications.
Question:
I just want to confirm that is it a new notifications service that only send us 'INITIAL_BUY' notifications? And there are no server-to server notification if the renewal is successful?
Note:**
We did validate receipt with verifyReceipt server to check latest_receipt_info.
Correct. According to this technical note (https://developer.apple.com/library/archive/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-SUBSCRIPTIONS-MY_SERVER_PROCESS_RARELY_RECEIVES_RENEWAL_NOTICES_WHEN_THE_AUTO_RENEWING_SUBSCRIPTION_RENEWS_)
The App Store attempts to charge the user account 24 hours before an auto-renewing subscription expires. If the renewal is successful, there is no server-to server notification because the auto-renewing subscription did not enter into the expired state.
You have to actively call Apple's receipt validation endpoint on or around the expiration date of each receipt (and possible for a few days after that) to fetch the renewal receipts. Apple will not notify your servers.

Server to Server Pollling Auto Renewable Subscription

We are implementing server side receipt validation for auto renewable subscription. Now when a user turn off the subscription or when it auto renew there is no notification send from apple server to our server. We want to poll apple server when the subscription is about to expire. So how can we do this?
Is there a way to schedule such polling at specific date ?
First when any in app purchase made you need to store receipt data after validating it. Also you need to store expire date of that particular purchase which you will get by receipt validation.
Now create a crone job in your server to validate auto renew purchase, crone job time interval is up to you as per your project need but let say for example take 1 hours. In the crone job you need to select only those record which expire time with in next 6 hours(You can change this time as per your need). Then again validate this receipt and if purchase get auto renew then you will get list of receipt. You will get always new receipt in the list whenever purchase auto renew. In this you will get new expire time. Suppose you are not getting any new receipt then it means user has cancel subscription
You would need Receipt validation.
If your app offers auto-renewable subscriptions, you can receive server notifications from the App Store about key events by setting up an optional URL that links to your server.
Before sending a notification to your server, the App Store will try to establish a secure network connection with your server by using App Transport Security (ATS) protocols. If a secure connection cannot be established, notifications will not be sent to your server. See Requirements for Connecting Using ATS to learn more about security requirements.
After a secure HTTPS connection has been established, the App Store will deliver JSON objects through an HTTP post to your server for key subscription events. See the In-App Purchase Programming Guide to learn more about the contents of this HTTP post.
Use server notifications together with Receipt Validation to validate a customer's current subscription status and provide them access to content or services from within your app.
For more info : Link
Not get notifications such as cancel as these notifications are only sent when a subscription is canceled by Apple directly.
The renewal notification, "Automatic renewal was successful for an expired subscription. Check Subscription Expiration Date to determine the next renewal date and time." 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. There is no support at present to simulate this event in the sandbox environment.“
Read more: https://forums.developer.apple.com/message/283579#283579

How to check if a user has an active iOS auto-renewable subscription from server?

My iOS app offers auto-renewable subscriptions. Only the users that has non-expired subscriptions are supposed to receive some news alerts through push notifications. Currently I thought of two possible ways to implement this. One is to subscribe and unsubscribe to push notification from the app by checking the subscription state during the application launch and send push notifications to all subscribers from the server-side.The second method is to update the expiration date of the subscription to the server and make the server checking if the subscription is expired before sending push notifications.
I understand that both methods will always require the app to be launched frequently to update the subscription status. Is there any other way to handle this task? Any tips/suggestions would be highly appreciated. Thanks!

Resources