azure notification hubs - app uninstall

随声附和 提交于 2019-12-06 13:52:10

Why do you need to know app uninstalls?

Notification Hubs automatically expire registrations for devices that get uninstalled. Also, I would avoid persisting the PNSHandles in your service at all.

The current guidelines for using hubs are the following:

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.

So I would have your ContactSvc expose two functionalities: a) create registration id (just call hub to get it) b) create or update registration given (registrationId, pnsHandle, tags?)

Then your device keeps the regId in its storage, ad after getting the handle from PNS, if as regId is not there creates a new one with endpoint a), then updates the registration with pnsHandle and tags.

Note that in this way your service does not need to persist handles or UUIDs, and does not need to worry about app uninstalls.

If you are keeping track of users, one approach is to periodically (once a month?) check in your hub if its registrations are still there...

You can reach me at @eliodamaggio if this is not clear.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!