hi i am using asp.net to send push notification , i assigned tag "ID" and i am using this code but i got time out everytime i use this function, whats the wrong in my code

public string SendNotificationById( string content, string load,Guid[] idList) {

        string pwApplication = "myapp";
        string pwAuth = "myAuth";
        string ids = "";
        foreach (Guid id in idList)
        {
            ids = ids + @"""" + id + @""",";
        }
        ids = ids.Remove(ids.Length - 1);
        string tag = @"A(""" + pwApplication + @""") * T(""ID"", IN, [" + ids + "])";

        JObject json = new JObject(

            new JProperty("auth", pwAuth),
            new JProperty("notifications",
                new JArray(
                    new JObject(
                        new JProperty("send_date", "now"),
                        new JProperty("content", content),
                        new JProperty("wp_type", "Toast"),
                        new JProperty("wp_count", 3),

                          new JProperty("data",
                             new JObject(
                                 new JProperty("type", load))),

                          new JProperty(@"devices_filter", tag)

                       ))));



        Uri url = new Uri("https://cp.pushwoosh.com/json/1.3/createTargetedMessage");
        JObject jsonR = new JObject(new JProperty("request", json));



        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
        req.ContentType = "text/json";
        req.Method = "POST";
        using (var streamWriter = new StreamWriter(req.GetRequestStream()))
        {
            streamWriter.Write(jsonR.ToString());
        }
        HttpWebResponse httpResponse;
        try
        {
            httpResponse = (HttpWebResponse)req.GetResponse();
        }
        catch (Exception exc)
        {
            throw new Exception(string.Format("Problem with {0}, {1}", url, exc.Message));
        }
        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
        {
            var responseText = streamReader.ReadToEnd();
            return responseText.ToString();
        }
    }
asked 01 Aug, 16:48
ahmedzayed's gravatar image

ahmedzayed
111

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×120
×64
×51

question asked: 01 Aug, 16:48

question was seen: 129 times

last updated: 01 Aug, 16:48