Windows phone 8通知集线器取消注册 [英] Windows phone 8 notification hub unregister
本文介绍了Windows phone 8通知集线器取消注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以告诉我或告诉我如何取消注册Windows Phone 8中的通知中心。我试过这种方式但它不起作用。
public void registerForNotifications(string [] tags)
{
var channel = HttpNotificationChannel.Find(" xxx");
if(channel == null)
{
channel = new HttpNotificationChannel(" xxx");
channel.Open();
channel.BindToShellToast();
}
string [] tagsToSubscribeTo = tags;
channel.ChannelUriUpdated + = new EventHandler< NotificationChannelUriEventArgs>(async(o,args)=>
{
var hub = new NotificationHub(" xxx" ;," xxx");
await hub.RegisterNativeAsync(args.ChannelUri.ToString(),tagsToSubscribeTo);
});
}
public async void unregisterFromNotifications()
{
var channel = HttpNotificationChannel.Find(" xxx");
var hub = new NotificationHub(" xxx"," xxx");
等待hub.UnregisterAllAsync(channel.ChannelUri.ToString());
}
解决方案
如果您使用的是Windows Azure移动服务,我注意到也丢失了。我写了一篇博客,描述了如何添加缺失的部分(并删除注册)
http://markbschramm.blogspot.com/2013/12/registering-for-live-tile-pushes-from.html
Can someone show me or tell some example how to unregister from notification hub in windows phone 8. I tried on this way but it doesn't work.
public void registerForNotifications(string[] tags) { var channel = HttpNotificationChannel.Find("xxx"); if (channel == null) { channel = new HttpNotificationChannel("xxx"); channel.Open(); channel.BindToShellToast(); } string[] tagsToSubscribeTo = tags; channel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(async (o, args) => { var hub = new NotificationHub("xxx", "xxx"); await hub.RegisterNativeAsync(args.ChannelUri.ToString(), tagsToSubscribeTo); }); } public async void unregisterFromNotifications() { var channel = HttpNotificationChannel.Find("xxx"); var hub = new NotificationHub("xxx", "xxx"); await hub.UnregisterAllAsync(channel.ChannelUri.ToString()); }
解决方案
If you are using Windows Azure Mobile Services, I noticed that missing too. I wrote a blog that describes how to add the missing piece (and remove the registration)
http://markbschramm.blogspot.com/2013/12/registering-for-live-tile-pushes-from.html
这篇关于Windows phone 8通知集线器取消注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文