2

我使用Azure Mobile Services向我的客户端应用发送推送通知。我使用push.wns对象(第一个方形,然后宽)发送正方形和平铺通知。下面是发送推送通知的服务器端代码的样子(只要记录在我的数据库表中更新这基本上是所谓的):平方米和宽平铺推送通知

function update(item, user, request) { 
request.execute({ 
    success: function() { 
     request.respond(); 
     sendNotifications(); 
    } 
}); 

function sendNotifications() { 
    var channelTable = tables.getTable('channel'); 

    channelTable.read({ 
     success: function(channels) { 
      channels.forEach(function(channel) { 
       push.wns.sendTileSquarePeekImageAndText02(channel.pushuri, 
       {image1src: '<imgPath>', 
       text1: 'New Game', 
       text2: item.playername }, 
        { 
        success: function(pushResponse) { console.log("Sent Square:", pushResponse); }, 
        error: function(error) { 
           console.log("error sending push notification to ", channel.pushuri); 
           if (error.statusCode == 410) { 
            console.log("Deleting ", channel); 
            channelTable.del(channel.id);    
           } 
          } 
        }); 

       push.wns.sendTileWidePeekImage01(channel.pushuri, 
       {image1src: <imgPath>, 
       text1: 'New Game', 
       text2: item.playername }, 
        { 
        success: function(pushResponse) { console.log("Sent Square:", pushResponse); }, 
        error: function(error) { 
           console.log("error sending push notification to ", channel.pushuri); 
           if (error.statusCode == 410) { 
            console.log("Deleting ", channel); 
            channelTable.del(channel.id);    
           } 
          } 
        }); 
      }); 
     } 
    }); 
} 

}

我注意到,广泛通知显示正确的时候我的应用程序瓷砖很宽。但是,当我将我的应用程序的拼贴大小设置为方形时,不显示方形通知。我该如何解决这个问题?

+0

几乎不可能没有一些代码的答案。 –

+0

@DanielKelley添加了一些代码 –

+0

目前还不清楚为什么当您的代码不是C#时,它被标记为C#。 –

回答

3

以下是您可以用来发送一个更新并一次更新两种瓷砖的示例。

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); 
    } 
} 
); 
2

带宽内容的图块通知将替换包含方形内容的图块通知。应发送单一通知containing both square and wide tile content

+0

你会碰巧知道如何构建服务器端使用Javascript的有效载荷? –

+0

看来,sendTile *方法只发送单一类型的内容(正方形或宽度)。要使用正方形和宽内容构建通知,请使用[send](http://msdn.microsoft.com/zh-cn/library/windowsazure/jj860484.aspx#send)方法,并显式传递通知XML。 –

+0

这就是我的意思。我是新来的JavaScript,JSON,XML等你知道如何构建这一片XML负载? –