Windows Phone 7 Toast 通知,应用程序在前台 [英] Windows phone 7 Toast notification with app in foreground

查看:37
本文介绍了Windows Phone 7 Toast 通知,应用程序在前台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速提问.我是这样做的:

Quick question. I did this:

myChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(myChannel_ShellToastNotificationReceived);

因此,如果我在应用程序处于前台时收到 Toast 通知,则应调用 myChannel_ShellToastNotificationReceived 函数.在该功能中,我有:

So if I receive a toast notification while the application is in the foreground the myChannel_ShellToastNotificationReceived function should be called. In that function I have:

void myChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
{
    Dispatcher.BeginInvoke(() =>
    {
       ApplicationTitle.Text = "Toast Notification Message Received";
    });
}

问题是函数从未被调用,ApplicationTitle 也从未改变.

The problem is that the function is never called and the ApplicationTitle is never changed.

我做错了什么吗?

推荐答案

我发现了问题...看来正在发送的 toast xml 的格式已经足够好,因此手机可以从应用程序中接收它但不是当它在里面的时候.手工"写了xml,没有使用xmlWriter,工作正常.

I've found the problem...it seemed that the toast xml that was being sent was well enough formatted so the phone would receive it out of the app but not when it was inside it. Wrote the xml by "hand" and didn't use xmlWriter and worked.

string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
        "<wp:Notification xmlns:wp=\"WPNotification\">" +
           "<wp:Toast>" +
              "<wp:Text1>" + title + "</wp:Text1>" +
              "<wp:Text2>" + message + "</wp:Text2>" +
           "</wp:Toast>" +
        "</wp:Notification>";

这篇关于Windows Phone 7 Toast 通知,应用程序在前台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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