我正在开发发送推送通知,一切正常,响应也“正常”。但我无法得到任何通知。我的设备设置有任何变化吗?请帮帮我。
以下是我的代码:
我从这段代码获得channeluri:
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
var jj = channel.Uri.ToString();
我的服务代码是:
string subscriptionUri = "https://hk2.notify.windows.com/?token=rretetretretretretretrergtrgtrgtrg43589743cn43jr43jr43jr4rvr43ro045jv77nninuoinjyt";
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 pavan" + "</wp:Title>" +
"</wp:Tile> " + "</wp:Notification>";
string strChannelURI = subscriptionUri;
//string secret = "xxxxxxxxxxxxxxxxx";
//string sid = "ms-app://s-1-15-2-23454435445-4343434-4343434443434-343434343-334-343443434-3434344443";
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();
响应“正常”,但我无法收到有关我设备的任何通知。