无法向iOS设备发送推送通知

时间:2016-08-25 10:28:12

标签: ios windows apns-sharp

我想从后端向iOS设备发送推送通知。我能够注册我的设备以进行推送通知。但该设备未收到任何通知。 这是我的代码:

string pushNotificationsTelerikBackendServiceAPIKey = "baas-api-key";
var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://api.everlive.com/v1/" + pushNotificationsTelerikBackendServiceAPIKey + "/Push/Notifications");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string notificationMessage = "These are not the droids you are looking for";

                string json = "{\"Filter\":\"{\\\"$and\\\":[{\\\"Parameters.User\\\":\\\"" + "Luke".ToLower() + "\\\"}]}\",\"NotificationDate\":null,\"ExpirationDate\":null,\"IOS\":null,\"Android\":null,\"WindowsPhone\":null,\"Windows\":null,\"Message\":\"" + notificationMessage + "\",\"UseLocalTime\":false}";
                streamWriter.Write(json);
                streamWriter.Close();
            } 
            HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            WebHeaderCollection header = httpResponse.Headers;

            var encoding = ASCIIEncoding.ASCII;

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream(), encoding))
            {
                var res = streamReader.ReadToEnd();
            }

请帮忙!

先谢谢。

  

**更新1:**我收到“远程服务器返回错误:(403)禁止。”作为例外。

更新2:我在Visual Studio中使用telerik appbuilder扩展程序

0 个答案:

没有答案