azure 通知中心 - 应用程序卸载

标签 azure apple-push-notifications google-cloud-messaging azureservicebus azure-notificationhub

我想使用 Azure 通知中心向跨 iOS、Android 和 Windows Phone 运行我的应用程序的用户发送推送通知。

我已经成功地完成了基础工作,但我不知道如何管理应用程序卸载故事。

启动时,移动应用程序将调用我的 Identity Svc 以获取身份验证 token 。 然后,它调用其平台通知服务(例如 Google Cloud Messaging、APNS)来获取 PNS token 。 将 token 保存到本地存储后,它将调用后端 Contact Svc 来注册客户的设备。此服务将为设备创建 Azure 通知中心的订阅。

如下图所示:

enter image description here

稍后,后端发布服务将调用联系服务,请求特定用户 ID 的推送通知。联系服务将在通知中心查找分配给标签的 ID 并发送推送请求。

有哪些选项可用于确定客户何时卸载应用程序?这只是在通知中心调用“发送”时捕获错误的问题吗?我想如果只发送给单个用户,这可能会起作用,但我的目的是将某些消息类型发布给多个订阅者。在设备初始注册时,将为用户 ID 的标签创建订阅,但也会为更通用的标签(例如“新促销”)创建订阅。发布服务稍后希望向所有设备发出“新促销”通知。

最佳答案

为什么您需要了解应用卸载情况?

通知中心会自动使卸载的设备的注册过期。 另外,我会完全避免将 PNSHandles 保留在您的服务中。

当前使用集线器的准则如下:

store the registrationIds of the registrations associated with the device in local storage. This enables you to update tags and channel information with a single update call. Because mobile connections are not always reliable, it is best to avoid creating a new registration without being able to store the registrationId in local storage. This can result in the device registering multiple times, causing duplicate notifications. You can achieve this by using the Create Registration ID and Create or Update Registration REST APIs. The first API returns a registrationId without actually creating a registration. When the ID has been securely stored on the device storage, the device can call the Create or Update Registration API.

所以我会让你的 ContactSvc 公开两个功能: a) 创建注册 ID(只需调用 Hub 即可获取) b) 创建或更新给定的注册(registrationId、pnsHandle、标签?)

然后您的设备将 regId 保留在其存储中,从 PNS 获取句柄后,如果 regId 不存在,则使用端点 a) 创建一个新的,然后使用 pnsHandle 和标签更新注册。

请注意,通过这种方式,您的服务不需要保留句柄或 UUID,也不需要担心应用程序卸载。

如果您要跟踪用户,一种方法是定期(每月一次?)检查您的中心,其注册是否仍然存在...

如果不清楚,您可以通过@eliodamaggio 联系我。

关于 azure 通知中心 - 应用程序卸载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22564354/

相关文章:

php - 从 APNS-php 错误中检索 token

android - GCM : why my application crash in GCMRegistrar. 检查设备(这个);

android - 使用 gcm token 从 firebase 控制台向老用户发送通知?

ios - IOS 中的 GCM 通知未显示在状态栏上

api - 从 API 访问 azure 发票

azure - 在 Azure SAS 下允许多个 IP

iphone - 知道苹果应用程序是否收到推送通知的任何选项?

ios - 当我的应用程序未处于事件状态时,PushNotification 角标(Badge)编号不显示?

sql-server - Sql 备份到 url - azure blob 差异

google-chrome - 视频无法在 Chrome 中循环和搜索