I am working on adding subscription to my iOS app and I came across some very annoying inconsistencies:
My server is listening for the DID_CHANGE_RENEWAL_STATUS
notification from Apple:
{
"auto_renew_status_change_date": "2019-06-05 13:42:43 Etc/GMT",
"environment": "Sandbox",
"auto_renew_status": "false",
"auto_renew_status_change_date_pst": "2019-06-05 06:42:43 America/Los_Angeles",
"latest_expired_receipt": "ewoJIn...",
"latest_expired_receipt_info": ⊖{
"original_transaction_id": "10000001010101010",
"expires_date_formatted": "2019-06-05 13:43:13 Etc/GMT",
...
},
"password": "xxxxxxxxx",
"auto_renew_status_change_date_ms": "1559742163000",
"auto_renew_product_id": "com.my.product",
"notification_type": "DID_CHANGE_RENEWAL_STATUS"
}
During my tests the notification contained in almost all cases a latest_expired_receipt
and a latest_expired_receipt_info
.
BUT some message contained latest_receipt
and a latest_receipt_info
instead. Beside this difference the structure of the messages was identical ("auto_renew_status": "false"
, auto_renew_status_change_date
before the expires_date_formatted
, etc.)
Does Apple change the structure randomly to make implementing subscription even more enjoyable or is there any logic on when which structure is used?
Of course I can simply adapt my server code to check if latest_receipt
OR latest_expired_receipt
is available but this would be a quick and dirty solution. I would prefer to understand when to expect which content/structure...
Apple constantly make developer's life harder.
As stated in App Store Server Notifications documentation, top-level objects latest_receipt, latest_receipt_info, latest_expired_receipt, and latest_expired_receipt_info are scheduled for deprecation. This could be the reason for the notification to behave differently.
You should update your code to rely on latest_receipt & latest_receipt_info in unified_receipt object instead. Source: https://developer.apple.com/documentation/appstoreservernotifications/responsebody
latest_expired_receipt_info - This array appears in the notification instead of latest_receipt_info for expired transactions. You can check the official Apple documentation here. Also note per Apple's docs: The following top-level objects are scheduled for deprecation: latest_receipt, latest_receipt_info, latest_expired_receipt, and latest_expired_receipt_info.
You might also consider a third-party service like Qonversion.io to avoid headaches implementing the subscriptions and get subscription analytics integrations out of the box.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With