phonegap-build / PushPlugin

This repository is deprecated head to phonegap/phonegap-push-plugin
https://github.com/phonegap/phonegap-plugin-push
MIT License
1.31k stars 996 forks source link

Problem with Notifications Plugin WP8 #197

Open swiven opened 10 years ago

swiven commented 10 years ago

I already received the result.uri by using pushNotification.register. Then I send message in ASP.NET

  try
  {
      string subscriptionUri = uri;

      HttpWebRequest sendNotificationRequest = (HttpWebRequest)WebRequest.Create(subscriptionUri);

      sendNotificationRequest.Method = "POST";

      string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
      "<wp:Notification xmlns:wp=\"WPNotification\">" +
         "<wp:Toast>" +
              "<wp:Text1>" + "MY APP" + "</wp:Text1>" +
              "<wp:Text2>" + "message" + "</wp:Text2>" +
              "<wp:Param>/MainPage.xaml?NavigatedFrom=Toast Notification</wp:Param>" +
         "</wp:Toast> " +
      "</wp:Notification>";

      byte[] notificationMessage = Encoding.Default.GetBytes(toastMessage);

      sendNotificationRequest.ContentLength = notificationMessage.Length;
      sendNotificationRequest.ContentType = "text/xml";
      sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "toast");
      sendNotificationRequest.Headers.Add("X-NotificationClass", "2");

      using (Stream requestStream = sendNotificationRequest.GetRequestStream())
      {
          requestStream.Write(notificationMessage, 0, notificationMessage.Length);
      }

      HttpWebResponse response = (HttpWebResponse)sendNotificationRequest.GetResponse();
      string notificationStatus = response.Headers["X-NotificationStatus"];
      string notificationChannelStatus = response.Headers["X-SubscriptionStatus"];
      string deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"];

  }
  catch (Exception ex)
  {
  }

It's no problem !!!! PushPlugin is very greate !!!!!!! Thanks.

joshilomas commented 10 years ago

hello swiven , I am getting empty uri. any suggestions??

Thanks, Lomas joshi

swiven commented 10 years ago

To:joshilomas Sorry for reply late..

Here is my code

function onDeviceReady() {
    appini();
    //alert(device.platform);
    try {
        var pushNotification = window.plugins.pushNotification;
        pushNotification.register(successHandler, errorHandler, { "channelName": "ppp", "ecb": "onNotification" });
    }
    catch (err) { }

}
function successHandler(result) {
    //console.log('registered###' + result.uri);
    // send uri to your notification server
   result.uri  ====> here can give uri 
}
function errorHandler(result) {
    // send uri to your notification server
    //alert('error');
}
swiven commented 10 years ago

you must include script src="Scripts/PushNotification.js"></script

gustter commented 9 years ago

Hi.

To test the App on the device, I deploy the application connecting the phone to PC using USB. event.uri returns empty. I notice I never indicate the CN and Identity so there is not relationship betwen my App and SID and Cliente Secret. But I don't know where I have to set this parameters in the App, config.xml or anywhere.

Could you tell me how to solved this?

Thanks