Unable to send push notifications to iOS devices

96 Views Asked by At

I want to send push notifications from back-end to iOS devices. I am able to register my device for push notifications. But the device is not receiving any notification. Here is my code:

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();
            }

Please help!

Thanks in Advance.

**UPDATE 1:**I'm getting "The remote server returned an error: (403) Forbidden." as an exception.

UPDATE 2: I am using telerik appbuilder extension in Visual Studio

0

There are 0 best solutions below