Push notification Windows Phone 8.1通用应用程序,点击接收推送通知时导航到特定应用程序
我正在从Azure通知中心发送推送通知。我想在点击收到的Toast推送通知时导航到特定页面。我收到推送通知,但无法导航到特定页面 这是我的插入代码:Push notification Windows Phone 8.1通用应用程序,点击接收推送通知时导航到特定应用程序,push-notification,windows-phone-8.1,azure-mobile-services,win-universal-app,Push Notification,Windows Phone 8.1,Azure Mobile Services,Win Universal App,我正在从Azure通知中心发送推送通知。我想在点击收到的Toast推送通知时导航到特定页面。我收到推送通知,但无法导航到特定页面 这是我的插入代码: function insert(item, user, request) { var payload = '<?xml version="1.0" encoding="utf-8"?><toast><visual>' + '<binding template="ToastText01"> &
function insert(item, user, request) {
var payload = '<?xml version="1.0" encoding="utf-8"?><toast><visual>' +
'<binding template="ToastText01"> <text id="1">' +
item.subject + '</text></binding></visual></toast>';
request.execute({
success: function () {
// If the insert succeeds, send a notification.
push.wns.send(null, payload, 'wns/toast', {
success: function (pushResponse) {
console.log("Sent push:", pushResponse);
request.respond();
},
error: function (pushResponse) {
console.log("Error Sending push:", pushResponse);
request.respond(500, { error: pushResponse });
}
});
}
});
函数插入(项目、用户、请求){
var有效载荷=“”+
' ' +
item.subject+“”;
请求执行({
成功:函数(){
//如果插入成功,则发送通知。
push.wns.send(空,有效负载,'wns/toast'{
成功:功能(pushResponse){
日志(“发送推送:”,推送响应);
请求。响应();
},
错误:功能(pushResponse){
日志(“发送推送时出错:”,推送响应);
respond(500,{错误:pushResponse});
}
});
}
});
}
有人能帮忙吗?这里有很多步骤,您没有详细说明您的问题。我会尽力向所有可能需要这一切的人解释这个概念。请确保您首先设置了本文中的所有步骤: 首先,您需要发送包含要加载页面的推送通知。假设您有一个页面,其中显示了某个项目的一些详细信息。当您收到推送通知时,它会自动打开该项目。您可以发送如下有效负载:
var payload = '<?xml version="1.0" encoding="utf-8"?><toast><visual>' +
'<binding template="ToastText01"> <text id="1">' +
item.id + '</text></binding></visual></toast>';
var有效负载=“”+
' ' +
项目id+“”;
然后您需要响应推送通知。您可以在此处查看此文档页面:
您的设置代码如下所示:
ShellToastNotificationReceived +=
new EventHandler<NotificationEventArgs>(httpChannel_ShellToastNotificationReceived);
public static HttpNotificationChannel CurrentChannel { get; private set; }
// This is from the tutorial linked in the first paragraph
private void AcquirePushChannel()
{
CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");
if (CurrentChannel == null)
{
CurrentChannel = new HttpNotificationChannel("MyPushChannel");
CurrentChannel.Open();
CurrentChannel.BindToShellToast();
}
CurrentChannel.ChannelUriUpdated +=
new EventHandler<NotificationChannelUriEventArgs>(async (o, args) =>
{
// Register for notifications using the new channel
await MobileService.GetPush()
.RegisterNativeAsync(CurrentChannel.ChannelUri.ToString());
});
CurrentChannel.ShellToastNotificationReceived +=
new EventHandler<NotificationEventArgs(async (o, args) =>
{
RootFrame.Navigate(new Uri("/ItemPage.xaml"), args.Collection['1']);
});
}
ShellToastNotificationReceived+=
新事件处理程序(httpChannel_ShellToastNotificationReceived);
公共静态HttpNotificationChannel CurrentChannel{get;private set;}
//这是第一段中链接的教程
专用通道()
{
CurrentChannel=HttpNotificationChannel.Find(“MyPushChannel”);
如果(CurrentChannel==null)
{
CurrentChannel=新的HttpNotificationChannel(“MyPushChannel”);
CurrentChannel.Open();
CurrentChannel.BindToShellToast();
}
CurrentChannel.ChannelUri已更新+=
新的EventHandler(异步(o,args)=>
{
//使用新频道注册通知
等待MobileService.GetPush()的消息
.RegisterNativeAsync(CurrentChannel.ChannelUri.ToString());
});
CurrentChannel.ShellToastNotificationReceived+=
新事件处理程序
{
RootFrame.Navigate(新Uri(“/ItemPage.xaml”)、args.Collection['1']);
});
}
我还没有测试过这段代码,但它应该足够好,可以为您指出正确的方向。基本上
请务必查看本导航教程:这里有许多步骤,您没有详细说明您的问题。我会尽力向所有可能需要这一切的人解释这个概念。请确保您首先设置了本文中的所有步骤: 首先,您需要发送包含要加载页面的推送通知。假设您有一个页面,其中显示了某个项目的一些详细信息。当您收到推送通知时,它会自动打开该项目。您可以发送如下有效负载:
var payload = '<?xml version="1.0" encoding="utf-8"?><toast><visual>' +
'<binding template="ToastText01"> <text id="1">' +
item.id + '</text></binding></visual></toast>';
var有效负载=“”+
' ' +
项目id+“”;
然后您需要响应推送通知。您可以在此处查看此文档页面:
您的设置代码如下所示:
ShellToastNotificationReceived +=
new EventHandler<NotificationEventArgs>(httpChannel_ShellToastNotificationReceived);
public static HttpNotificationChannel CurrentChannel { get; private set; }
// This is from the tutorial linked in the first paragraph
private void AcquirePushChannel()
{
CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");
if (CurrentChannel == null)
{
CurrentChannel = new HttpNotificationChannel("MyPushChannel");
CurrentChannel.Open();
CurrentChannel.BindToShellToast();
}
CurrentChannel.ChannelUriUpdated +=
new EventHandler<NotificationChannelUriEventArgs>(async (o, args) =>
{
// Register for notifications using the new channel
await MobileService.GetPush()
.RegisterNativeAsync(CurrentChannel.ChannelUri.ToString());
});
CurrentChannel.ShellToastNotificationReceived +=
new EventHandler<NotificationEventArgs(async (o, args) =>
{
RootFrame.Navigate(new Uri("/ItemPage.xaml"), args.Collection['1']);
});
}
ShellToastNotificationReceived+=
新事件处理程序(httpChannel_ShellToastNotificationReceived);
公共静态HttpNotificationChannel CurrentChannel{get;private set;}
//这是第一段中链接的教程
专用通道()
{
CurrentChannel=HttpNotificationChannel.Find(“MyPushChannel”);
如果(CurrentChannel==null)
{
CurrentChannel=新的HttpNotificationChannel(“MyPushChannel”);
CurrentChannel.Open();
CurrentChannel.BindToShellToast();
}
CurrentChannel.ChannelUri已更新+=
新的EventHandler(异步(o,args)=>
{
//使用新频道注册通知
等待MobileService.GetPush()的消息
.RegisterNativeAsync(CurrentChannel.ChannelUri.ToString());
});
CurrentChannel.ShellToastNotificationReceived+=
新事件处理程序
{
RootFrame.Navigate(新Uri(“/ItemPage.xaml”)、args.Collection['1']);
});
}
我还没有测试过这段代码,但它应该足够好,可以为您指出正确的方向。基本上
请务必查看本导航教程:谢谢您的回复,Windows Phone 8.1 universal app中推送通知的实现已更改。以上在Windows Phone Silverlight中工作正常。啊,对不起。我认为,非代码建议仍然是正确的。使用此移动服务教程和此Windows推送通知快速启动谢谢回复,推送通知的实现在Windows Phone 8.1 universal app中更改。以上在Windows Phone Silverlight中工作正常。啊,对不起。我认为,非代码建议仍然是正确的。使用此移动服务教程和此Windows推送通知快速启动谢谢回复,推送通知的实现在Windows Phone 8.1 universal app中更改。上面的方法在风中效果很好