Reputation: 915
How to Unregistered one device from particular tag. I m sending notification with tag.It is working good. but even though i unregister still it is getting notifications.
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++;
}
}
I want to know how to unregister a device that previously tagged to?
Upvotes: 1
Views: 331
Reputation: 2834
You have to use service Bus Explorer(Download) with Microsoft Visual Studio to see all registered devices. You can also un-register devices from registered device list.
Upvotes: 1