How can I handle toast notifications on Windows Phone 7 when application is not running?

痞子三分冷 提交于 2019-12-07 18:59:27

问题


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:


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.



来源:https://stackoverflow.com/questions/15331528/how-can-i-handle-toast-notifications-on-windows-phone-7-when-application-is-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!