使用UWP应用中的通知导航到特定页面

时间:2018-11-16 07:48:17

标签: javascript uwp

我正在编写UWP应用(Javascript),并且我具有ScheduledToastNotification来充当警报。该通知会按时出现,但是当我单击通知时(没有按钮,通常是在通知上),该应用程序无法正确启动,它将启动到根页面中。另外,我无法使用通知访问传递给应用程序的参数。该代码附在下面:

var Notifications = Windows.UI.Notifications;
var currentTime = new Date();
var seconds = 60;
var dueTime = new Date(currentTime.getTime() + seconds * 60 * 1000);
var idNumber = Math.floor(Math.random() * 100000000);  // Generates a unique ID number for the notification.

// Set up the notification text.
var toastXml = Notifications.ToastNotificationManager.getTemplateContent(Notifications.ToastTemplateType.toastText02);
var strings = toastXml.getElementsByTagName("text");
strings[0].appendChild(toastXml.createTextNode(This is a scheduled toast notification));
strings[1].appendChild(toastXml.createTextNode("Received: " + dueTime.toLocaleTimeString()));



var toastNode = toastXml.selectSingleNode("/toast");
toastNode.setAttribute("duration", "long");
var audio = toastXml.createElement("audio");

audio.setAttribute("src", "ms-winsoundevent:Notification.IM");
toastXml.selectSingleNode("/toast").setAttribute("launch", '{"type":"details","contentId":"112234","contentType":"Music"}');

// Create the toast notification object.
var toast = new Notifications.ScheduledToastNotification(toastXml, dueTime);
toast.id = "Toast" + idNumber;

// Add to the schedule.
Notifications.ToastNotificationManager.createToastNotifier().addToSchedule(toast);

如何让应用导航到正确的路线?我要听哪个事件来执行此操作,并注意我已通过的参数。

0 个答案:

没有答案