繁体   English   中英

Windows Phone 8推送通知null通道uri

[英]Windows phone 8 push notification null channel uri

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

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

我已经在相同的网络条件下(工作WiFi-家庭WiFi-3G)在4种不同的设备+模拟器上尝试了该应用程序,其中2台设备均为Lumia 920,都无法获取频道uri,而其他2台设备为HTC 8X和Lumia 820可以成功获取频道uri并注册进行推送。

仿真器还可以成功获取通道uri。

在Lumia 920的其中一个上,它设法获得了频道uri,但是我再次卸载并安装了该应用程序,从那时起就无法获得任何频道uri。

以下是我的情况:

1-在3G上安装的Lumia 920 Black可以正常工作,卸载/重新安装后可以在任何连接上停止工作(3G-工作WiFi-家用WiFi)2-在3G上安装的Lumia 920 Yellow在-3G-工作WiFi-家用WIfi从未设法获得频道uri 3 -3G上的HTC 8X-工作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()));

        }
    }

我也遇到过同样的问题。 通过将我的HTC Windows Phone设置为正确的日期和时间可以解决此问题。一旦我自动设置了日期和时间,我的混合应用程序wp8成功注册了pushplugin,并收到了MPNS Channeluri。

ChannelUri为空,因为正在开发的新手机无法正确设置其日期和时间。 一旦我将时间设置为手动设置,然后将其固定为时间,日期和区域,然后又切换回自动设置,一切工作正常,例如SSL证书,Windows Phone更新以及最重要的ChannelUri;)

尝试进入“设置”>“电话+ SIM”并关闭“数据连接”选项,这有时有用吗?

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

是否启用了省电模式? 当电池电量不足等情况时,这会限制使用。

同样如上所述,您是否在设备上检查了日期和时间? 可能是由于日期和时间的自动设置引起的。 您可以手动修复此问题,然后切换回自动。 有用。

尝试使用本地wifi连接而不是手机数据连接。 根据此处的注释之一禁用电话的“数据连接”将实现此结果。 尽管我尝试了此操作并失败了,但它使我注意到我的手机未连接到我们的wifi路由器。

注意:就我而言,我们的蜂窝网络覆盖范围很差,因此我们使用特殊的沃达丰路由器,该路由器通过固网Internet连接重定向所有手机数据,通话等。 一旦绕过那个路由器,我就会收到一个ChannelUri。 我还尝试了在工作中使用不同信号塔的电话/应用,这很好。

我尝试手动设置日期,但没有任何效果。 最终对我有用的是实际上在没有SIM卡的情况下启动手机,关机,重新插入SIM卡并重新启动。 这使我能够再次获得ChannelUri。

怀疑这可能与TripVoltage的建议有关,后者建议切换SIM的数据连接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM