gpt4 book ai didi

android - 使用 GCM 的 Azure 推送通知

转载 作者:行者123 更新时间:2023-11-30 02:26:11 24 4
gpt4 key购买 nike

如何从特定标签取消注册一台设备。我正在发送带标签的通知。效果很好。但即使我取消注册,它仍然会收到通知。

protected async void HandleRegistration(Context context, Intent intent)
{


string registrationId = intent.GetStringExtra("registration_id");
string error = intent.GetStringExtra("error");
string unregistration = intent.GetStringExtra("unregistered");


//Retriving string From The Memory

ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(context);
string groupname = preferences.GetString ("GroupName","");


var nMgr = (NotificationManager)GetSystemService (NotificationService);

if (!String.IsNullOrEmpty (registrationId)) {
NativeRegistration = await Hub.RegisterNativeAsync (registrationId,new[] {groupname.ToString()});

var notificationNativeRegistration = new Notification (Resource.Drawable.notification, "Your Device Successfully Registered To "+groupname.ToString());
var pendingIntentNativeRegistration = PendingIntent.GetActivity (this, 0, new Intent (this, typeof(MainActivity)), 0);

notificationNativeRegistration.SetLatestEventInfo (this, "Device ID ", NativeRegistration.RegistrationId, pendingIntentNativeRegistration);
nMgr.Notify (_messageId, notificationNativeRegistration);
_messageId++;
}
else if (!String.IsNullOrEmpty (error)) {
var notification = new Notification (Resource.Drawable.notification, "Gcm Registration Failed.");
var pendingIntent = PendingIntent.GetActivity (this, 0, new Intent (this, typeof(MainActivity)), 0);
notification.SetLatestEventInfo (this, "Gcm Registration Failed", error, pendingIntent);
nMgr.Notify (_messageId, notification);
_messageId++;
}
else if (!String.IsNullOrEmpty (unregistration)) {
if (NativeRegistration != null)
await Hub.UnregisterAsync (NativeRegistration);

var notification = new Notification (Resource.Drawable.notification, "Unregistered successfully.");
var pendingIntent = PendingIntent.GetActivity (this, 0, new Intent (this, typeof(MainActivity)), 0);
notification.SetLatestEventInfo (this, "MyIntentService", "Unregistered successfully.", pendingIntent);
nMgr.Notify (_messageId, notification);
_messageId++;
}
}

我想知道如何取消注册之前标记的设备?

最佳答案

您必须将服务总线资源管理器 ( Download ) 与 Microsoft Visual Studio 结合使用才能查看所有已注册的设备。您还可以从注册设备列表中取消注册设备。

关于android - 使用 GCM 的 Azure 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27885686/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com