[英]Apple server to server notifications with multiple triggers
Apple states that for some subscription events they trigger multiple notifications. Apple 表示,对于某些订阅事件,它们会触发多个通知。 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.我可以听
DID_CHANGE_RENEWAL_STATUS
来确定他们何时关闭自动续订。 However, there is a problem – the same notification will trigger if a user has upgraded to another SKU.但是,有一个问题——如果用户升级到另一个 SKU,将触发相同的通知。 In fact, according to their docs, it will trigger three notifications:
CANCEL
, DID_CHANGE_RENEWAL_STATUS
, INTERACTIVE_RENEWAL
.事实上,根据他们的文档,它会触发三个通知:
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
?但是,我想知道我是否可以预期所有三个通知都会以相同的
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.如果是这样,我可以监听
DID_CHANGE_RENEWAL_STATUS
通知,检查unified_receipt
,如果我发现我的用户尚未注册其他产品,我可以为他们提供另一个订阅选项。
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
.但是,文档没有提到 Apple 是否保证在发送多个通知的情况下,所有通知都将使用相同的
unified_receipt
。 It would be logical... But it would also be logical to make notification_type
an array to simplify things.这将是合乎逻辑的......但将
notification_type
设为一个数组以简化事情也是合乎逻辑的。 And, given that Apple hasn't done it, I am worried that we cannot expect unified_receipt
to be the same for successive notifications.而且,鉴于 Apple 还没有这样做,我担心我们不能指望
unified_receipt
对于连续通知是相同的。
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).在今天 (20210404) 的文档中,您可以看到多个通知已更改(将它们与 2020 年 9 月激活的通知进行比较)。 For example, and upgrade have passed from 3 to 2 notifications (
CANCEL
isn't sent, if the documentation doesn't lie...).例如,升级已从 3 个通知传递到 2 个通知(如果文档没有说谎,则不发送
CANCEL
......)。
Perhaps you can detect what you need looking into the pending_renewal_info field.也许您可以检测到您需要查看 pending_renewal_info 字段的内容。 And the
original_transaction_id
should be the same in all the multiple notifications.并且
original_transaction_id
在所有多个通知中应该是相同的。
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.也许https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/determining_service_entitlement_on_the_server 中的代码示例可以让您了解如何管理通知中的信息。
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.
它没有对您的问题给出确切的答案,但可以为您提供有关如何管理它们的一些见解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.