Windows Phone 8推送服务

时间:2013-12-27 21:15:43

标签: windows-phone-8 push-notification

我正在尝试为我的一个Windows手机应用程序运行推送通知。

基本上我复制并粘贴了microsoft msdn页面的示例代码并对其进行了修改, 更新我的web服务,而不是将push-uri打印到控制台。

但是,它没有工作 - 即使是未经修改的例子......

每当我尝试打开推送频道时,我都会收到推送频道已经存在的信息 - 但它的推送uri是null ...

我删除了所有评论,但添加了一些用于信息目的。

提取我的应用程序构造函数:

        string channelName = "S0meRandomString.";

        InitializeComponent();

        pushChannel = HttpNotificationChannel.Find(channelName);

        if (pushChannel == null)
        {
            pushChannel = new HttpNotificationChannel(channelName);
        }

        pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
        pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

        //Without ConnectionStatus check, an Exception is thrown, stating that the channel is already open
        if (pushChannel.ConnectionStatus == ChannelConnectionStatus.Disconnected)
        {
            pushChannel.Open();
        }

        if (pushChannel.ChannelUri != null)
        {
            //this part is basically never executed, because ChannelUri is ALWAYS null.
            //EVEN if ConnectionStatus says Connected...

            WebClient wc = new WebClient();
            String uriPush = "http://my.domain.tld/app/updatePushChannel.php?device_id=" + Configuration.Instance.GetDeviceID() + "&channel_uri=" + HttpUtility.UrlEncode(pushChannel.ChannelUri.ToString());
            wc.DownloadStringAsync(new Uri(uriPush)); //fire and forget for debuging.

            if (!pushChannel.IsShellToastBound)
            {
                pushChannel.BindToShellToast();
            }
        }

我读了很多关于微软推送服务器的问题...但是,大多数帖子都是2 - 4年,我认为现在应该解决这个服务的“启动问题”?!< / p>

0 个答案:

没有答案