Azure 通知中心注册生效时间(90 天限制)

标签 azure push-notification azure-notificationhub

现在我正在使用PushSharp库来发送 Apple 推送通知(通过 APNS),但我想迁移到通知中心以获得稳健性和可扩展性。

我计划使用后端注册通过 Azure 通知中心发送通知,如 this article 中所述。 。所以:

  1. iOS 客户端有一个后端 API 方法,当推送 token 更新时会调用该方法。在此方法中,我使用用户 ID 进行注册标记。 (之前,我将推送 token 存储到数据库中的用户链接。)
  2. 当我要为特定用户发送一些通知时,我会使用标签(用户 ID)发送它。 (之前,我使用了 DB 中的 APNS 设备 token 。)

这似乎是一个可行的解决方案,但在 Notification Hubs documentation 中据说:

It is important to note that registrations are transient. Similar to the PNS handles that they contain, registrations expire. You can set the time to live for a registration on the Notification Hub, up to a maximum of 90 days. This limit means that they must be periodically refreshed, and also that they should not be the only store for important information. This automatic expiration also simplifies cleanup when your mobile application is uninstalled.

这就是问题所在。有时我需要向 90 天没有更新 token 的设备发送通知,等等。因此 APNS token 仍然有效,但通知中心的注册将失效。所以我只是失去了用户的沟通 channel 。

你如何处理这个问题?

当然,我仍然可以将 token 存储在数据库中并进行定期更新注册的工作。但这并不是您对通知中心等推送通知解决方案的期望。

最佳答案

您可以从应用程序或服务器刷新您的注册。如果您通过应用程序执行此操作,则用户必须启动该应用程序才能刷新注册。

因此,如果您要求设备注册保持事件状态,即使对于超过 90 天未启动的应用程序,您也必须通过服务器刷新注册,并且在服务器中运行一个会刷新 token 的作业看起来像你唯一的选择。

我同意通知中心使 token 过期的决定似乎很奇怪。也许他们想到的是 MPNS(Microsoft 推送通知服务)通知 channel 的行为,该 channel 比 APNS 设备 token 或 GCM 注册 ID 更频繁地过期。

关于Azure 通知中心注册生效时间(90 天限制),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23823813/

相关文章:

azure - ERROR_AZURE_DRIVE_DEV_PATH_NOT_SET 是什么意思?

Azure 通知中心 - 从 GCM 迁移到 FCM

java - 计算从 Azure 查询返回的字符串数量

c# - 如何使用azure Active Directory b2c覆盖忘记密码的调用功能

python - 什么是最好用作队列 : Redis, Mysql,Python 列表

cordova - 推送插件 : Can't find variable: onNotificationAPN

c# - 使用 Azure 从 Web 到移动设备(跨平台)的 Web/浏览器推送通知

Azure 通知中心上的 iOS13 apns-push-type header

sql-server - SSMS - 无法查看 Azure SQL 数据库中的存储过程

ios - 如何在 iOS 中读取其他应用程序的推送通知