如何获取推送到我的Windows手机?

时间:2015-08-20 05:34:21

标签: windows-phone-8 push-notification windows-phone-8.1

我在Windows Phone 8.1中创建了pushnotification。但是每当我运行我的代码时,我都没有收到任何通知我的设备.Code工作正常,没有任何错误。下面是我的代码

 string subscriptionUri = "https://hk2.notify.windows.com/?token=AwYAAABR4r1HR4ncUnppJKR5oQ2%2bU1IwNe0dQfXgEltoIoIqBz3sSKHSt8Rge5GtbH2yDvSg2Syd0wd0%2bWhz9cSFMm40QxkEMOafHTXzgKmoKrzuSvDg0xO5etxpJRkqRbl3RWA%3d";
           string PushNotificationXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Tile>" +
           "<wp:BackgroundImage>" + "sdfsafdsafsdf" + "</wp:BackgroundImage>" + "<wp:Count>" + "0" + "</wp:Count>" + "<wp:Title>" +
          "Hi This is Sudheer" + "</wp:Title>" + "</wp:Tile> " + "</wp:Notification>";
           string strChannelURI = subscriptionUri;



           string secret = "aHsb3Hhhhhnvfuyknk";
           string sid = "ms-app://s-1-15-2-435756784356-ffdsfdffd-sfsfsf-1465244715-23315sfdsfdsf61566-4957dsfdsf35136-dsfdsf";









           var accessToken = GetAccessToken(secret, sid);

           byte[] contentInBytes = Encoding.UTF8.GetBytes(PushNotificationXML);

           HttpWebRequest request = HttpWebRequest.Create(subscriptionUri) as HttpWebRequest;
           request.Method = "POST";
           request.Headers.Add("X-WNS-Type", "wns/badge");
           request.ContentType = "text/xml"; 
           request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken.AccessToken));

           using (Stream requestStream = request.GetRequestStream())
               requestStream.Write(contentInBytes, 0, contentInBytes.Length);

           using (HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse())
           webResponse.StatusCode.ToString();

回复&#34;好的&#34 ;;

但没有收到任何通知我的设备。

0 个答案:

没有答案