【发布时间】:2013-08-07 21:47:29
【问题描述】:
我知道这已被多次提出,但找不到答案。
我正在尝试使用以下代码在我的应用中设置推送通知,但是我遇到了频道 uri null 问题。
我已经在 4 个不同的设备 + 模拟器上尝试了该应用程序,所有设备都在相同的网络条件下(工作 WiFi - 家庭 WiFi - 3G),其中 2 个设备是 Lumia 920,两者都无法获取通道 uri,而其他 2 个设备HTC 8X 和 Lumia 820 可以成功获取频道 uri 并注册推送。
模拟器也可以成功获取频道uri。
在其中一台 Lumia 920 上,它设法获得了频道 uri,但我再次卸载并安装了该应用程序,从那时起就无法获得任何频道 uri。
以下是我的场景:
1- 安装在 3G 上的 Lumia 920 Black 工作正常,卸载/重新安装后停止在任何连接上工作(3G - 工作 WiFi - 家庭 WiFi) 2- Lumia 920 Yellow 安装在 3G 上 - 工作 WiFi - 家庭 WIfi 从未设法获得频道 uri 3- HTC 8X on 3G - 工作 WiFi - 家庭 WiFi 在所有 3 个网络上都运行良好 4- Lumia 820 和 HTC 8X 一样好用
请注意,其他应用上的推送通知在所有 4 台设备上都可以正常工作。
对于频道 null uri 的任何反馈/建议,我将不胜感激
下面是我使用的代码,和MSDN提供的代码是一样的
public MainPage()
{
/// Holds the push channel that is created or found.
HttpNotificationChannel pushChannel;
// The name of our push channel.
string channelName = "ToastSampleChannel";
InitializeComponent();
// Try to find the push channel.
pushChannel = HttpNotificationChannel.Find(channelName);
// If the channel was not found, then create a new connection to the push service.
if (pushChannel == null)
{
pushChannel = new HttpNotificationChannel(channelName);
// Register for all the events before attempting to open the channel.
pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
// Register for this notification only if you need to receive the notifications while your application is running.
pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
pushChannel.Open();
// Bind this new channel for toast events.
pushChannel.BindToShellToast();
}
else
{
// The channel was already open, so just register for all the events.
pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
// Register for this notification only if you need to receive the notifications while your application is running.
pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
// Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
MessageBox.Show(String.Format("Channel Uri is {0}",
pushChannel.ChannelUri.ToString()));
}
}
【问题讨论】:
-
在 Lumia 820 上也遇到此问题。如果 URI 为空,已尝试处理和重新创建 HttpNotificationChannel。没什么区别。 URI 以 null 开头,并且没有引发 ChannelUriUpdated。
-
我现在正在恢复我的 lumia 920 black,希望如果它在恢复时没有变砖,我会对其进行测试并在此处发布我的结果...如果有任何解决方案请帮助
-
好的,所以在我的 lumia 920 变砖并设法修复它之后,我可以很高兴地说它从第一次启动就成功地获取了一个频道 uri,并且推送工作正常......任何人都有任何想法为什么在恢复之前无法获取频道 uri?
-
似乎用户注意到了 WP8 通知的问题。搜索“windows phone 通知问题”。
-
有时当您使用 PNS 开发应用程序并对其进行大量调试时,您必须等待才能继续。
标签: c# push-notification windows-phone mpns