wp8:Handle Toast notification when application is in backgroung

▼魔方 西西 提交于 2019-12-08 02:45:42

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.

yes we can handle the toast notification. once the user clicks on toast notification we can send a request to our web service and do our job.

what happens when an user clicks on toast notification is it will redirect to the application launching event in App.Xaml.cs page. in that event depending upon the toast content you can proceed to the next step.

hope this helps.

still if you didn't get it done, just drop a mail to me

happy coding.

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