Toast推送通知服务空例外

时间:2015-07-18 13:43:29

标签: c# windows-phone-8 push-notification toast

我正在尝试发送推送通知,但收到此错误:

  

类型' System.ArgumentNullException'的异常" HttpWebRequest请求=(HttpWebRequest)WebRequest.Create(uri);""发生在System.dll中,但未在用户代码中处理)代码行...

这是我的发送通知代码:

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
        request.Method = WebRequestMethods.Http.Post;
        request.ContentType = "test/xml";
        request.ContentLength = message.Length;

        request.Headers.Add("X-MessageID", Guid.NewGuid().ToString());

        request.Headers["X-WindowsPhone-Target"] = "toast";
        request.Headers.Add("X-NotificationClass", "2");

        var requestStream = request.GetRequestStream();
        requestStream.Write(message, 0, message.Length);

0 个答案:

没有答案