I’m using storekit2 to allow people to purchase subscriptions in my iOS app. I have a node js server backend. How can I tell if someone cancels a subscription ? And which user did so?
When a user "cancels" a subscription, they are actually disabling the auto-renewal of the subscription at the next renewal date; They keep the subscription benefit that they have already paid for (or until the end of the free-trial period if they are in one).
This means that as long as you are processing renewal transactions correctly, you may not need to do anything about cancellations; You simply withdraw the subscription benefit at the end of the current period when you don't receive a renewal event.
However, you may want to proactively attempt to "win back" the subscriber with promotional messaging or a discount ahead of any App Store win back offers you may have configured.
In this case you can use App Store server notifications to receive a notification that the user has changed their renewal preference - The DID_CHANGE_RENEWAL_PREF
notification type with a subtype of AUTO_RENEW_DISABLED
implies that the user has "cancelled" their subscription (Although this notification can also indicate that they have requested and received a refund).
As with renewal events, you can use the originalTransactionId
to identify the user; Your server should keep a record of of the originalTransactionId
for the subscription associated with each user.