【问题标题】:Receive and handle a notification arguments when the Windows (phone) 8.1 app is on foreground当 Windows (phone) 8.1 应用程序在前台时接收并处理通知参数
【发布时间】:2023-03-08 06:03:01
【问题描述】:

当我收到通知并在徽章上或从通知中心顶部收到通知时,应用程序将打开,并在 App.xaml.cs 文件中显示 OnLaunched(LaunchActivatedEventArgs e)。我从e.Arguments 中获取论点,然后做任何我想做的事情。

当我收到通知并且我在应用程序中(在前台)时,有没有办法获取这些参数?

【问题讨论】:

    标签: c# notifications push-notification windows-phone-8.1 windows-8.1


    【解决方案1】:

    试试这个解决方案:

    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
    }
    

    【讨论】:

    • 阻止Windows默认处理通知是什么意思?
    • 您可以在前台处理您的推送消息并选择行为:如果您设置了true - 默认 toast 通知似乎没有,您可以随意管理
    • 另外,查看 xml 的内容。您可以找到从 WNS 检索的需要参数
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-21
    • 2020-01-17
    • 1970-01-01
    相关资源
    最近更新 更多