0

我想从后端向 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 扩展

4

0 回答 0