Reputation: 388
I'm new to windows phone development and push notification. I've implement pushwoosh notification in my app. I followed the documentation PushWoosh WP I received notification but the exact notification text does not display on notification bar. I got only "New Notification"
Here is my code.
private async void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
{
String notificationContent = String.Empty;
switch (e.NotificationType)
{
case PushNotificationType.Badge:
notificationContent = e.BadgeNotification.Content.GetXml();
break;
case PushNotificationType.Tile:
notificationContent = e.TileNotification.Content.GetXml();
break;
case PushNotificationType.Toast:
ToastTemplateType toastType = ToastTemplateType.ToastText02;
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastType);
toastXml = e.ToastNotification.Content;
XmlNodeList toastTextElement = toastXml.GetElementsByTagName("text");
toastTextElement[0].AppendChild(toastXml.CreateTextNode("eg"));
//toastTextElement (toastTextElement[0] as XmlElement).InnerText = message;
IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
((XmlElement)toastNode).SetAttribute("duration", "long");
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
break;
case PushNotificationType.Raw:
notificationContent = e.RawNotification.Content;
break;
}
e.Cancel = true;
}
I tried to get exact push message but couldn't do so.. Please see attached SS to for calrification.
why I'm getting package name in header and no image? why not the real message display rather than New Notification? Can anyone please help me out this.? Thank you in advance.
Upvotes: 0
Views: 106
Reputation: 81
Please note that for Windows Phone 8.1 and higher Pushwoosh SDK integration flow is different from the one you have followed:
http://docs.pushwoosh.com/docs/windows-8-sdk-integration
This is due to WP8.1 using WNS (Windows Push Notification ServiceS) for push messaging instead of MPNS used on WP8.0 and prior. Please note that MPNS API is still available for backwards compatibility - that's why you still receive notifications, however its content should be different to be shown on WP8.1 device, particularly it should be XML or raw content encoded in MIME's base64 in form of Object ( language1: 'content1', language2: 'content2' ) OR String.
If you send your pushes via Pushwoosh Remote API you should specify notification text in "wns_content" rather than in just "content":
"wns_content": {
"en": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==",
"de": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4="
}
If you send notifications via Pushwoosh Dashboard you should compose your message in a separate Windows tab:
Upvotes: 1