How to update an installation if installation id is unknown?

南楼画角 提交于 2019-12-11 10:11:50

问题


For some reason, one cannot download all installations. So, how does one go about updating a template for all installations if one doesn't know all the installation ids?

Surely someone thought of this...?


回答1:


There are two options when using NotificationHubs: register a device directly with the NotificationHub, or register a device through your web backend.

If you're registering directly with the NotificationHub from a device, you're going to have a bad time when you need to update a template for all installations. To my knowledge, you're SOL in this case.

If you're registering with the NotificationHub from your backend, you have options. You'll need to keep a list of every installation in a separate data store. For example, on my last project, I kept a PushNotificationRegistrations database table that contained the PNS type (gcm, apns), the registrationId (the unique device registration from the respective PNS), the userId (so I could swap out tags as needed later), and a generated installationId.

If you've got this information for each registration, you can retrieve the relevant records from your data store, then re-register each with the NotificationHub in one big giant decadent for-loop. Installations are idempotent, so this will overwrite old templates. I think that you need to ensure that your InstallationId and registration Id are the same when you re-register.

I remember seeing something in the REST docs about using a HTTP PATCH endpoint to just target portions of an installation, but I haven't experimented with them.



来源:https://stackoverflow.com/questions/50122012/how-to-update-an-installation-if-installation-id-is-unknown

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