简体   繁体   English

在Windows Phone 8.1应用中单击本地通知时,应用未打开?

[英]App is not open when local notification click in windows phone 8.1 app?

I developed a windows phone app. 我开发了Windows Phone应用。 in this scheduled local notification. 在此计划的本地通知中。 what happen is notification came but whenever I click notification app was not open it goes to back. 发生的情况是通知到来,但是每当我单击通知应用程序未打开时,它就会返回。

below is my code: 下面是我的代码:

string textLine1 = "Sample Toast App";
            string textLine2 = "This is a sample message.";
            string contentString =
              "<toast duration=\"long\">\n" +
                "<visual>\n" +
                  "<binding template=\"ToastText02\">\n" +
                    "<text id=\"1\">" + textLine1 + "</text>\n" +
                    "<text id=\"2\">" + textLine2 + "</text>\n" +
                  "</binding>\n" +
                "</visual>\n" +
              "</toast>\n";



XmlDocument content = new Windows.Data.Xml.Dom.XmlDocument();
content.LoadXml(contentString);

DateTime EventDate = new DateTime(2016, 02, 11, 12, 45, 00);

ToastNotifier toastNotifier =ToastNotificationManager.CreateToastNotifier();
var scheduledToast = new ScheduledToastNotification(content, EventDate);
toastNotifier.AddToSchedule(scheduledToast);

in the above code 在上面的代码中

I am replace EventDate to DateTime.Now.AddSeconds(30) then app was open. 我将EventDate替换为DateTime.Now.AddSeconds(30)然后打开了应用程序。

ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
var scheduledToast = new ScheduledToastNotification(content, DateTime.Now.AddSeconds(30));
toastNotifier.AddToSchedule(scheduledToast);

what should I do. 我该怎么办。 please help me. 请帮我。

You have to set ' launch ' attribute as your app landing page. 您必须将' launch '属性设置为您的应用登录页面。 Sample below. 下面的示例。

<toast launch="/Views/HomeView.xaml?toast=test">
    <visual>
        <binding template="ToastText01">
            <text id="1">Hello World!</text>
        </binding>
    </visual>
</toast>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM