Reputation: 18729
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...
Upvotes: 12
Views: 2802
Reputation: 3703
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
Upvotes: 3
Reputation: 111
If the order is expired when autorenew status is changes you are going to get latest_expired_receipt_info and latest_expired_receipt ( this cases include orders that are in billing retry and app store could not renew them during billing retry period, or the order was refunded), for other cases when subscription is still valid you will get latest_receipt and latest_receipt_info
Upvotes: 0