使用 Azure 服务总线通知中心注销标记

Unregister tags with Azure Service Bus Notification Hubs

我继承了一个 iOS 应用程序,它使用 Azure 通知中心发送通知,但是有一个障碍。

用户 select 接收通知的多个类别(新闻、体育等),他们可以随时更改这些。每当他们添加或删除兴趣时,应用程序都会从​​通知中心注销并订阅新标签。

我认为这是不正确的,但我找不到查看用户订阅了哪些标签或add/delete单个标签的方法。

在当前应用中,有时我们的测试设备没有收到我认为应该收到的通知。

我在网上找到了答案,说你应该避免注销,注册和注销都有延迟(比如这里的答案,Android Azure Notification hub unregister

我正在寻找有关如何处理此用例(添加和删除标签)的任何见解。

由于您没有指定如何与 Azure 通知中心通信,我将使用 ANH REST API 作为参考。

"...I can't find a way to see what tags a user is subscribed to..."

如果您请求注册(例如 per registration ID),您将获得包含指定标签的注册数据。

"...or add/delete a single tag."

您不会直接在 ANH 的注册上添加或删除单个标签,如果需要,您基本上会更新整个注册。一些 ANH SDK 可能为此提供方便的方法,但一般来说,您只需将带有所需标签的完整注册对象发送到 ANH,它就会被覆盖。例如。 REST API 有一个“Update Registration”方法,但没有 "Add/Remove Tag" 方法。

"I've found answers online saying that you should avoid unregistering, and that there is a delay to register and unregister..."

由于您所述的原因,您确实不应取消注册并注册此用例。这可能也是原因:

"In the current app, sometimes our test devices don't receive notifications that I think they should."

切勿取消注册并再次注册以更新注册。如果您根本不想在特定设备上接收通知,请只取消注册。

"I am looking for any insight on how to handle this usecase, of adding and deleting tags."

基本上,只需省略 "unregister step" 并使用实际的 ANH 注册 ID 和所有需要的标签使 "register step" 成为“create or update registration 步骤”。