Windows (phone) 8.1 应用程序在前台时接收并处理通知参数
Receive and handle a notification arguments when the Windows (phone) 8.1 app is on foreground
当我收到通知并位于徽章顶部或来自通知中心时,应用程序打开并在 App.xaml.cs
文件中显示 OnLaunched(LaunchActivatedEventArgs e)
。我从 e.Arguments
中获取参数并用它做任何我想做的事情。
当我收到通知并且我在应用程序中(在前台)时,有没有办法获取这些参数?
试试这个解决方案:
PushNotificationChannel currentChannel = myChannel;
currentChannel.PushNotificationReceived += OnPushNotificationReceived;
void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
{
e.Cancel = true; // True to prevent default processing of the notification by Windows
// implement your logic there
}
当我收到通知并位于徽章顶部或来自通知中心时,应用程序打开并在 App.xaml.cs
文件中显示 OnLaunched(LaunchActivatedEventArgs e)
。我从 e.Arguments
中获取参数并用它做任何我想做的事情。
当我收到通知并且我在应用程序中(在前台)时,有没有办法获取这些参数?
试试这个解决方案:
PushNotificationChannel currentChannel = myChannel;
currentChannel.PushNotificationReceived += OnPushNotificationReceived;
void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
{
e.Cancel = true; // True to prevent default processing of the notification by Windows
// implement your logic there
}