wp8:在应用程序处于背景状态时处理Toast通知 [英] wp8:Handle Toast notification when application is in backgroung

查看:75
本文介绍了wp8:在应用程序处于背景状态时处理Toast通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序正在运行时,我可以在ShellToastNotificationReceived(对象发送者,NotificationEventArgs e)事件处理程序上接收烤面包通知,作为e.Collection中的键.

While my app is running I can receive toast notification,on ShellToastNotificationReceived(object sender, NotificationEventArgs e) event handler as keys in e.Collection.

如果我的应用程序未运行并且有敬酒通知到达,则显示敬酒,但是我该如何处理该通知?

If my app is not running and a toast notification arrives, a toast is displayed but how i can i handle this notification?

我的意思是当我的应用程序未运行且通知到达时,哪个事件着火.

I mean which event is fire when my application is not running and notification arrives.

我认识后台代理,但不能满足我的要求

I know background agent but its not fulfill my requirement

谢谢.

推荐答案

Windows Phone平台负责处理Push Notifications,并且当应用程序未运行时,开发人员无权直接进行通知处理.这意味着在收到Toast之后,您将无法执行任何后台逻辑.但是,当Toast消息包含<wp:Param>值和Uri到特定的应用页面时,如果用户点击Toast弹出窗口,则用户将被重定向到该页面.因此,您可以在用户点击Toast弹出窗口之后执行特定的工作.为此,您需要在Uri中添加一个参数,例如/YourPage?IsToast=true,并覆盖页面的OnNavigatedTo方法以运行业务逻辑:

Windows Phone platform is responsible to handle Push Notifications and developers don't have a direct access for notification handling when an app is not running. That means you can't do any background logic after Toast is received. But when Toast message contains <wp:Param> value with an Uri to a specific app page then user will be redirected to this page, if user taps a Toast popup. So, you can do specific job after user tapped a Toast popup. To accomplish it, you need add an parameter to Uri, for example /YourPage?IsToast=true and override OnNavigatedTo method of the page to run your business logic:

 protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (NavigationContext.QueryString.ContainsKey("IsToast"))
            {
                //do your business here
            }
    }

在其他情况下,您需要使用后台工作者.

For other cases you need to use a background worker.

这篇关于wp8:在应用程序处于背景状态时处理Toast通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆