[英]Can I configure my windows 8.1 TABLET application to receive toast notifications
[英]How can I receive toast for my app?
我遵循了Jeff的教程,並在應用程序內部實現了push。
HttpNotificationChannel channel;
void GetPushChannel()
{
channel = new HttpNotificationChannel("BLANKENSOFT_" + DateTime.Now.Ticks.ToString());
channel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(channel_ChannelUriUpdated);
channel.Open();
}
void channel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
{
Dispatcher.BeginInvoke(delegate
{
URIBlock.Text = channel.ChannelUri.ToString();
});
}
這樣,我現在可以在應用程序中獲取和處理推送通知。 但是,當我的應用程序關閉並且想要向他人敬酒時,發生了什么?
我想到了ScheduledTaskAgent,但是它們受到活動時間的限制...如果在代理未運行時發送通知,該怎么辦? 還是沒關系?
我想到了在ScheduledTaskAgent中實現上述功能。
您可以參考示例http://code.msdn.microsoft.com/wpapps/Toast-Notification-Sample-fb20ae13 。 當應用程序關閉並從服務器端發送通知時,它將在設備上收到,無需任何ScheduledTaskAgent或后台進程。 WP pushnotification的有效負載如下所示:
<?xml version=\1.0\ encoding=\utf-8\?>
<wp:Notification xmlns:wp=\WPNotification\>
<wp:Toast>
<wp:Text1>Title of application</wp:Text1>
<wp:Text2>Subtitle for application</wp:Text2>
<wp:Param>/Page2.xaml?NavigatedFrom=Toast Notification</wp:Param> //supported from WP7.1
</wp:Toast>
</wp:Notification>
WP7.1中包含有效負載,當關閉應用程序時,該有效負載用於將用戶導航到特定頁面。 另外,如果您想在應用程序關閉並到達烤面包時顯示任何自定義消息,請將其導航到特定頁面並顯示包含自定義消息的消息框。
這就是我以為您想知道的,如果沒有讓我知道。 謝謝
添加
pushChannel.BindToShellToast();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.