azure - 在 Xaramin 和 Azure 通知中心注册用户标签

标签 azure xamarin xamarin.android azure-notificationhub

我正在尝试在我的 Xamarin Forms 应用程序中向特定用户执行推送通知的 POC。

我对所有文档都遇到了问题,因为很多引用 GCM 现已弃用,但尚未更新到 Firebase,特别是与 Azure 通知中心集成。

我的目标是:

  1. 当我的应用加载时,它会在 Azure 中注册设备。
  2. 我有一个 Azure 函数,它将向通知中心传递消息以发送给特定用户。

根据我收集的信息,我可以使用标签将消息发送给特定用户(为每个设备创建一个标签),但我看不到如何从 Xamarin 中为用户创建标签。我正在使用 Microsoft.WindowsAzure.MobileServices 但它似乎不处理标签。

我也见过Azure Messaging component但已经一年没碰过了,很多人提示它不起作用,而且我不知道如何在 Visual Studio 中使用该组件。

我稍微了解了一下移动应用程序,但不确定我是否真的需要这个。我希望,因为这是一个 POC,所以我不需要部署和额外的 Web api 来处理这个问题,我只是希望将设备 ID(或安装 ID)传递到通知中心并使用它。

任何正确方向的提示将不胜感激。

谢谢

最佳答案

当您在

中注册推送通知时

安卓:

public class PushHandlerService : GcmServiceBase 
{
.....
var tags = new List<string>() { "deviceID" }; // create tags if you want
var hubRegistration = Hub.Register(registrationId, tags.ToArray());
.....
}

iOS:

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
......
                NSSet tags = new NSSet(new string[] { "deviiceID" }); // create tags if you want
                this.Hub.RegisterNativeAsync(deviceToken, tags, registerError =>
                {
                    if (registerError != null)
                    {
                        Console.WriteLine($"Error registering {registerError}");
                    }
                });
......
}

更多信息在这里:

https://learn.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-ios-push-notification-apns-get-started

https://learn.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-push-notifications-android-gcm

关于azure - 在 Xaramin 和 Azure 通知中心注册用户标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45394587/

相关文章:

android - android服务的monodroid

android - 使用 mvvmcross 的 LinearLayout 背景颜色

azure - StorageSharedKeyCredential 不是构造函数 : vue. js + azure-blob 存储

azure - 如何删除 Azure Blob 容器中的文件夹

xaml - Xamarin.Forms 工具栏项目图标大小

c# - 找不到 Xamarin.Android.Support.Compat

c# - Xamarin Sqlite-Net Insert(对象引用未设置为对象的实例)

azure - 无法使用已发布的 Power BI 报告连接到 AzureTable

asp.net - 尝试将图像上传到 Azure 但收到 404

c# - 使用 C# 可移植库中的 F# 可移植类库