首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows phone 8推送通知空通道uri

Windows phone 8推送通知空通道uri
EN

Stack Overflow用户
提问于 2013-08-08 05:47:29
回答 5查看 1.7K关注 0票数 2

我知道这个问题已经被提过很多次了,但还是找不到答案。

我正在尝试使用下面的代码在我的应用程序中设置推送通知,但是我遇到了通道uri null的问题。

我在4个不同的设备+模拟器上尝试了这个应用程序,都是在相同的网络条件下(工作WiFi -家庭WiFi - 3G),其中2个设备是Lumia920,都无法获取通道uri,而另外2个设备HTC8X和Lumia820可以成功获取通道uri并注册推送。

仿真器还可以成功地获得信道uri。

在Lumia920上,它设法获得了频道uri,但我再次卸载并安装了这个应用程序,从那以后就无法获得任何频道uri。

以下是我的场景:

1-安装在3G上的Lumia 920黑色版工作正常,卸载/重新安装后在任何连接上都工作正常(3G -工作WiFi -家庭WiFi) 2-安装在3G上的Lumia 920黄色-工作WiFi -家庭WiFi从未设法获得频道uri 3- HTC 8X在3G上工作WIfi -家庭WiFi在所有3个网络上工作正常4- Lumia 820与HTC 8X一样工作正常

请注意,其他应用程序上的推送通知在所有4个设备上都工作得很好。

我非常感谢对频道null uri的任何反馈/建议。

下面是我使用的代码,它与MSDN提供的代码相同

代码语言:javascript
复制
  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()));

        }
    }
EN

回答 5

Stack Overflow用户

发布于 2016-03-16 17:31:40

我也遇到过同样的问题。我自动设置了日期和时间,我的混合应用程序wp8成功注册了pushplugin并接收到了MPNS Channeluri。

票数 1
EN

Stack Overflow用户

发布于 2014-05-07 14:04:31

ChannelUri为空,因为我正在开发的新手机不能正确设置日期和时间。一旦我切换到手动设置的时间,然后固定它的时间,日期和地区,然后切换回自动,一切正常,如ssl证书,windows phone更新,最重要的是一个ChannelUri ;)

票数 0
EN

Stack Overflow用户

发布于 2014-09-01 22:17:00

尝试进入设置>“手机+SIM卡”,并关闭“数据连接”选项,这有时能奏效吗?

您是否尝试过更改设置>数据感知中的选项?有限制后台数据的选项吗?

是否启用了电池节电功能?这限制了电池电量不足等情况下的使用。

另外,如上所述,你检查过设备上的日期和时间了吗?可能是自动设置日期和时间造成的。您可以手动修复此问题,然后切换回自动。它起作用了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18114399

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档