简体   繁体   English

具有多个触发器的 Apple 服务器到服务器通知

[英]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 .事实上,根据他们的文档,它会触发三个通知: CANCELDID_CHANGE_RENEWAL_STATUSINTERACTIVE_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.

相关问题 Apple:应用内购买订阅和服务器到服务器通知 - Apple: In App Purchase Subscriptions & Server to Server Notifications Windows Server上的Apple Push Notifications证书 - Apple push notifications certificate on windows server 使用Sandbox服务器和SNS的Apple推送通知 - Apple Push Notifications using Sandbox server and SNS Apple iOS Inapp 购买服务器到服务器通知的“取消”通知案例? - Apple iOS Inapp purchase Server to Server Notifications' 'Cancel' notification cases? Apple Sandbox APN Server上的推送通知性能不佳 - Push Notifications on Apple Sandbox APN Server performing poorly 推送通知发送到Apple apns服务器但设备没有收到任何信息 - Push notifications delivered to apple apns server but device received nothing 苹果沙箱:仅接收“ INITIAL_BUY”服务器通知 - Apple Sandbox: Only receive 'INITIAL_BUY' server notifications iOS中的Apple推送通知(APN)服务服务器端Python 2脚本 - Apple Push Notifications (APN) service server side Python 2 script in iOS Apple:在 App 内购买订阅服务器通知查看过去的历史记录 - Apple: In App Purchase Subscriptions Server Notifications view past history 在通知托盘中看不到Apple多推通知 - Apple Multiple Push Notifications not visible in Notifications Tray
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM