Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 方形和宽瓷砖的推送通知_Javascript_Windows 8_Push Notification_Azure Mobile Services - Fatal编程技术网

Javascript 方形和宽瓷砖的推送通知

Javascript 方形和宽瓷砖的推送通知,javascript,windows-8,push-notification,azure-mobile-services,Javascript,Windows 8,Push Notification,Azure Mobile Services,我正在使用向我的客户端应用发送推送通知。我使用push.wns对象发送正方形和平铺通知(先是正方形,然后是宽度)。下面是发送推送通知的服务器端代码的样子(这基本上是在my DB表中更新记录时调用的): 功能更新(项目、用户、请求){ 请求执行({ 成功:函数(){ 请求。响应(); 发送通知(); } }); 函数sendNotifications(){ var channelTable=tables.getTable('channel'); channelTable.read({ 成功:功能(

我正在使用向我的客户端应用发送推送通知。我使用push.wns对象发送正方形和平铺通知(先是正方形,然后是宽度)。下面是发送推送通知的服务器端代码的样子(这基本上是在my DB表中更新记录时调用的):

功能更新(项目、用户、请求){
请求执行({
成功:函数(){
请求。响应();
发送通知();
}
});
函数sendNotifications(){
var channelTable=tables.getTable('channel');
channelTable.read({
成功:功能(频道){
channels.forEach(函数(通道){
push.wns.sendtilesquarepeekimageandtext2(channel.pushuri,
{image1src:',
text 1:'新游戏',
text2:item.playername},
{ 
成功:函数(pushResponse){console.log(“Sent Square:,pushResponse);},
错误:函数(错误){
log(“向发送推送通知时出错”,channel.pushuri);
如果(error.statusCode==410){
控制台日志(“删除”,频道);
channelTable.del(channel.id);
}
}  
});
});
}
});
}
}


我注意到,当我的应用程序磁贴宽时,宽通知显示正确。但是,当我将应用程序的平铺大小设置为方形时,不会显示方形通知。如何更正此问题?

具有宽内容的磁贴通知正在替换包含方形内容的磁贴通知。应发送一个通知。

以下是一个示例,您可以使用它同时发送一个更新和更新两种瓷砖

push.wns.send(item.channel,
'<tile><visual>' +
'<binding template="TileSquarePeekImageAndText02">' + 
    '<image id="1" src="imageUri" />' + 
    '<text id="1">Template: TileSquarePeekImageAndText02</text>' + 
    '<text id="2">' + item.text + '</text>' + 
'</binding>' + 
'<binding template="TileWidePeekImage01">' + 
    '<image id="1" src="imageUri" />' + 
    '<text id="1">Template: TileWidePeekImage01</text>' + 
    '<text id="2">' + item.text + '</text>' + 
'</binding>' + 
'</visual></tile>',
"wns/toast", {
    success: function(pushResponse) {
        console.log("Sent push:", pushResponse);
    }
}
);
push.wns.send(item.channel、,
'' +
'' + 
'' + 
'模板:TileSquarePeekImageAndText02'+
''+item.text+''+
'' + 
'' + 
'' + 
'模板:TILEWIDEPEKIMAGE01'+
''+item.text+''+
'' + 
'',
“wns/toast”{
成功:功能(pushResponse){
日志(“发送推送:”,推送响应);
}
}
);

如果没有一些代码几乎无法回答。@DanielKelley添加了一些代码。不清楚为什么在您的代码不是C时将其标记为C。我已经将问题重新标记为JavaScript和WinJS。啊,我的错。我的客户端应用程序是C#尽管将通知推送到该应用程序的整个云基础设施都是JavaScription,但您是否知道如何使用Javascript在服务器端构建有效负载?sendTile*方法似乎只发送单一类型的内容(方形或宽)。要构造包含方形和宽内容的通知,请使用该方法并显式传递通知XML。这就是我的意思。我不熟悉javascript、JSON、XML等。您知道如何构造这段XML负载吗?
push.wns.send(item.channel,
'<tile><visual>' +
'<binding template="TileSquarePeekImageAndText02">' + 
    '<image id="1" src="imageUri" />' + 
    '<text id="1">Template: TileSquarePeekImageAndText02</text>' + 
    '<text id="2">' + item.text + '</text>' + 
'</binding>' + 
'<binding template="TileWidePeekImage01">' + 
    '<image id="1" src="imageUri" />' + 
    '<text id="1">Template: TileWidePeekImage01</text>' + 
    '<text id="2">' + item.text + '</text>' + 
'</binding>' + 
'</visual></tile>',
"wns/toast", {
    success: function(pushResponse) {
        console.log("Sent push:", pushResponse);
    }
}
);