2011-11-29 94 views
0

快速的問題。 我這樣做:Windows phone 7在前臺應用程序吐司通知

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

所以,如果我收到Toast通知,而應用程序是在前臺myChannel_ShellToastNotificationReceived函數被調用。在這個功能我有:

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

問題是,該函數永遠不會被調用,並且ApplicationTitle永遠不會改變。

我做錯了什麼?

+1

您可以檢查您是否實際收到通知? – abhinav

+0

如果應用程序不在前臺,則在屏幕頂部會出現Toast消息...所以我認爲如果我只是離開應用程序並指示我的服務發送一個推送它的工作。但不是當它在前臺 –

回答

1

我發現這個問題......似乎發送的敬酒xml格式已經足夠好,所以手機會將它從應用程序中接收出來,而不是在它裏面。 用「手」寫了xml,並沒有使用xmlWriter並工作。

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>"; 
0

您的頻道註冊是否接收通知?

+0

是的,這是......事實上,如果應用程序不在前臺,敬酒通知可以工作......但不是當我打開應用程序時。 –

相關問題