简体   繁体   English

Azure 通知中心设备注册

[英]Azure Notification Hub device registration

Since AppCenter retiring at the end of this year, I have started migrating to Azure-Notification-Hub.自从 AppCenter 在今年年底退休后,我开始迁移到 Azure-Notification-Hub。 But the documentation for notification-hub is not clear at all.但是通知中心文档根本不清楚。 Especially the documentation for Xamarin.Android.特别是 Xamarin.Android 的文档。 It does not match with their latest SDK.它与他们最新的 SDK 不匹配。

In the latest (version 1.1.1) azure-notification-hub SDK for Android (or Xamarin.Android ) there's no need to implement FirebaseMessagingService .在适用于Android (或Xamarin.Android )的最新(版本 1.1.1)azure-notification-hub SDK 中,无需实施FirebaseMessagingService NotificationHub.Start() method registers the device in the Notification-Hub. NotificationHub.Start()方法在 Notification-Hub 中注册设备。 A device registered with this way gets notifications without any problem.以这种方式注册的设备可以毫无问题地收到通知。

NotificationHub.Start(Application, <HubName>, <ConnectionString>);

Addition tags to existing NotificationHub instance are also straightforward with the new SDK.使用新 SDK 向现有 NotificationHub 实例添加标签也很简单。

NotificationHub.AddTag("username:user123");

But in Registration Management official doc states that devices can register with the notification-hub either from client-side or from server-side.但在注册管理官方文档中,设备可以从客户端或服务器端向通知中心注册。 Is it necessary to use one of those methods if my app registered with the notification-hub using the NotificationHub.Start() method?如果我的应用程序使用NotificationHub.Start()方法在通知中心注册,是否有必要使用其中一种方法? Or do I missing something?或者我错过了什么?

Also, when I was using the AppCenter, I have used the AppCenter-InstallId to target a specific device.此外,当我使用 AppCenter 时,我使用 AppCenter-InstallId 来定位特定设备。 With that in mind is it possible to use the NotificationHub.InstallationId to use as a tag (eg: "handle:<devce's InstallationId>" ) to send device-specific notifications?考虑到这一点,是否可以使用NotificationHub.InstallationId作为标记(例如: "handle:<devce's InstallationId>" )来发送特定于设备的通知?

Is it necessary to use one of those methods if my app registered with the notification-hub using the NotificationHub.Start() method?如果我的应用程序使用 NotificationHub.Start() 方法在通知中心注册,是否有必要使用其中一种方法?

When you invoke NotificationHub.start(Application, ...) , the Android SDK will listen for changes like added tags, new FirebaseMessagingService tokens, etc. Anytime it detects a change, it will invoke an InstallationAdapter to inform a backend of the new details.当您调用NotificationHub.start(Application, ...) ,Android SDK 将侦听更改,例如添加的标签、新的 FirebaseMessagingService 令牌等。只要检测到更改,它就会调用InstallationAdapter来通知后端新的详细信息.

The default InstallationAdapter will send an PUT request to the Azure Notification Hubs backend as documented here .默认InstallationAdapter将发送一个PUT请求到在Azure通知集线器后端的记录在这里 This is what is created by NotificationHub.start(Application, string, string) ;这是由NotificationHub.start(Application, string, string) for people who are not hosting their own backend, this is a sensible default.对于没有托管自己后端的人来说,这是一个明智的默认设置。

If you have your own backend where you track devices, or you're just looking to keep your credentials server-side, you can swap out the InstallationAdapter to be a class that invokes your API.如果您有自己的后端来跟踪设备,或者您只是希望将凭据保留在服务器端,则可以将InstallationAdapter替换为调用 API 的类。 All you need to do is implement the InstallationAdapter interface and initialize the SDK by calling NotificationHub.start(Application, InstallationAdapter) .您需要做的就是实现InstallationAdapter接口并通过调用NotificationHub.start(Application, InstallationAdapter)初始化 SDK。

If you use the NotificationHub.start(...) methods as indicated above, there is no further registration action required.如果您使用上述NotificationHub.start(...)方法,则不需要进一步的注册操作。

With that in mind is it possible to use the NotificationHub.InstallationId to use as a tag (eg: "handle:<devce's InstallationId>") to send device-specific notifications?考虑到这一点,是否可以使用 NotificationHub.InstallationId 作为标记(例如:“handle:<devce's InstallationId>”)来发送特定于设备的通知?

Yes!是的! This documentation walks you through how to use the special tag format $InstallationId:{YOUR_TAG_ID} to target a specific device. 本文档将引导您了解如何使用特殊标签格式$InstallationId:{YOUR_TAG_ID}来定位特定设备。

When you've used NotificationHub.start() , if you do not specify an InstallationId , it will generate one for you.当您使用NotificationHub.start() ,如果您没有指定InstallationId ,它会为您生成一个。

Question about setting the InstallationId and/or UserId.关于设置 InstallationId 和/或 UserId 的问题。 If I'm using Microsoft.Azure.NotificationHubs.Client, which makes more sense to do.如果我使用 Microsoft.Azure.NotificationHubs.Client,这样做更有意义。

Should I set the InstallationId via the $InstallationId Tag (see here: https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management#installations ) or via implementing the InstallationEnrichmentAdapter and set it via a call to installation.InstallationId = in the EnrichInstallation method?我应该通过 $InstallationId 标签设置 InstallationId(请参阅此处: https : //docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management#installations )或通过实现 InstallationEnrichmentAdapter 并通过在 EnrichInstallation 方法中调用 installation.InstallationId = 来设置它?

Additionally, the Microsoft.Azure.NotificationHubs.Client.Installation class provides a UserId property that can be updated too.此外, Microsoft.Azure.NotificationHubs.Client.Installation类提供了一个也可以更新的 UserId 属性。

I'm also moving my push notifications from AppCenter to Azure Notification Hub and want to reuse my existing AppCenter InstallId .我还将推送通知从 AppCenter 移至 Azure 通知中心,并希望重用我现有的 AppCenter InstallId

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 设备注册后将推送通知标签添加到Azure通知中心 - Adding push notification tags to Azure Notification Hub after device registration 如何将 Azure 通知中心中 iOS 设备注册的到期日期设置为 31-12-9999 23:59:59? - How to set the expiration date of an iOS device registration in Azure Notification Hub to 31-12-9999 23:59:59? 如何通过Web App向Azure Notification Hub注册远程设备 - How to register remote device with Azure Notification Hub via Web App 为Azure通知中心推送通知 - Push notification for azure notification hub 尝试使用特定设备标签通过 Rest API 向 Azure 通知中心发送推送通知 - Trying to send push notification to Azure Notification Hub via Rest API using specific device tag 我们允许每个设备为Azure推送通知中心注册多少个标签 - How many tags we are allow to register per device for Azure push notification hub 使用Azure Notification Hub在Xamarin Forms上注册Android设备以进行推送通知 - Registering an Android device for push notifications on Xamarin Forms using Azure Notification Hub 如何通过 Azure 通知中心应用服务 SDK 或手动为 Xamarin Forms 应用注册设备? - How to Register a device through Azure Notification Hub App Service SDK or manually for a Xamarin Forms App? 适用于多个平台的Azure Notification Hub应用徽标 - Azure Notification Hub App Logo for multiple platforms Azure通知中心:调度移动应用程序API - Azure Notification Hub: Schedule Mobile App API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM