Reputation: 716
I want to control push notifications (toast) coming from WNS server before it displays on screen..I can do it in Android but can I do it in Windows Phone..??
Upvotes: 1
Views: 104
Reputation: 73
I believe you want a raw notification, this is a notification that your phone handles while the application is running.
When you create your pushchannel you can use the OnPushNotificationRecieved Event to do logic when reciving a notification.
This way your logic will trigger before the notification appears on the screen IF the application is running.
If the application is not running it will be a regular Toast.
Example:
_channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
_channel.PushNotificationReceived += OnPushNotificationReceived;
private void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
{
switch (args.NotificationType)
{
case PushNotificationType.Badge:
this.OnBadgeNotificationReceived(args.BadgeNotification.Content.GetXml());
break;
case PushNotificationType.Tile:
this.OnTileNotificationReceived(args.TileNotification.Content.GetXml());
break;
case PushNotificationType.Toast:
this.OnToastNotificationReceived(args.ToastNotification.Content.GetXml());
break;
case PushNotificationType.Raw:
this.OnRawNotificationReceived(args.RawNotification.Content);
break;
}
args.Cancel = true;
}
private void OnBadgeNotificationReceived(string notificationContent)
{
// Code when a badge notification is received when app is running
}
private void OnTileNotificationReceived(string notificationContent)
{
// Code when a tile notification is received when app is running
}
private void OnToastNotificationReceived(string notificationContent)
{
// Code when a toast notification is received when app is running
// Show a toast notification programatically
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml(notificationContent);
var toastNotification = new ToastNotification(xmlDocument);
//toastNotification.SuppressPopup = true;
ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
}
private void OnRawNotificationReceived(string notificationContent)
{
// Code when a raw notification is received when app is running
}
Upvotes: 1
Reputation: 1560
you can use toast notifications in your case. Toast notifications are handled by OS. you can get payload in launch argument at OnLaunched Event of App.
Server app, you can use it for testing. You can also use emulator for push testing.
Upvotes: 1