How can I handle toast notifications on Windows Ph

2019-05-28 13:53发布

My Toast Message is

 string ToastPushXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
            "<wp:Notification xmlns:wp=\"WPNotification\">" + "<wp:Toast>" + "<wp:Text1>{0}</wp:Text1>" +
            "<wp:Text2>{1}</wp:Text2>" + "<wp:Param>{2}</wp:Param>" + "</wp:Toast>" + "</wp:Notification>";

While my app is running I can receive my custom parameters (wp:myCustomParam1 and other) on ShellToastNotificationReceived(object sender, NotificationEventArgs e) event handler as keys in e.Collection

But when my app is not running and notification comes, the user taps on pop-up notification and app started, the ShellToastNotificationReceived doesn't calls and notification is lost.

So, how can I get my custom parameters in this case?

1条回答
啃猪蹄的小仙女
2楼-- · 2019-05-28 14:39

While the parameter is not available in this scenario, I believe the intended behaviour in this area was that the toast would drive the user to start the app. Once the app is (re)started it would make a request to the server to get the latest information it needs. There could have been any number of toasts sent since the app was last launched or the app may be using a "sociable hours" mechanism to not send toasts in the middle of the night (or equivalent) so any number of notifications may also have not been sent.

The param parameter in the payload is intended to be used only when the notification is received when the app is running. In this scenario the parameter is there to save another round trip back to the server for more information.

The text is there for the user. The param is there for the app. The expectation is that, at most, only one will be relevant/used in any one notification. The text is there for the user when not using the app and to tell them something that may want them open the app.

查看更多
登录 后发表回答