Apple states that for some subscription events they trigger multiple notifications. Suppose I wish to find out whether the user has cancelled their subscription so that I can offer them another cheaper option.
I could listen to DID_CHANGE_RENEWAL_STATUS
to determine when they turned auto-renew off. However, there is a problem – the same notification will trigger if a user has upgraded to another SKU. In fact, according to their docs, it will trigger three notifications: CANCEL
, DID_CHANGE_RENEWAL_STATUS
, INTERACTIVE_RENEWAL
.
I would like to distinguish between these scenarios. Obviously, as these are asynchronous operations, the order of arrival is not guaranteed. However, I wonder whether I can expect that all three notifications will arrive with the same unified_receipt
? If so, I could listen for DID_CHANGE_RENEWAL_STATUS
notification, check the unified_receipt
and, if I see that my user has not signed up to another product, I can offer them another subscription option.
However, the docs do not mention whether Apple guarantees that in cases when multiple notifications are sent, all will arrive with the same unified_receipt
. It would be logical... But it would also be logical to make notification_type
an array to simplify things. And, given that Apple hasn't done it, I am worried that we cannot expect unified_receipt
to be the same for successive notifications.
Has anyoned had an experience with this which you could share?
In the documentation for today (20210404) you can see that the multiple notifications have changed (comparing them to the ones active in September 2020). For example, and upgrade have passed from 3 to 2 notifications (
CANCEL
isn't sent, if the documentation doesn't lie...).Perhaps you can detect what you need looking into the pending_renewal_info field. And the
original_transaction_id
should be the same in all the multiple notifications.Perhaps the code sample in https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/determining_service_entitlement_on_the_server can give you some ideas about how to manage the information in the notifications.
The code sample show how to extract information from notifications; it doesn't give the exact response to your question, but can give you some insights about how manage them.