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

时间:2013-01-20 18:05:56

标签: javascript windows-8 push-notification azure-mobile-services

我正在使用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);               
                                }
                            }  
                    });
            });
        }
    });
}

}

我注意到当我的应用磁贴很宽时,广泛的通知会正确显示。但是,当我将应用的图块大小设置为方形时,不会显示方形通知。我怎么能纠正这个?

2 个答案:

答案 0 :(得分: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);
    }
}
);

答案 1 :(得分:2)

广泛内容的磁贴通知正在替换包含方形内容的磁贴通知。应发送一个通知containing both square and wide tile content