2

クライアント アプリにプッシュ通知を送信するためにAzure Mobile Servicesを使用しています。push.wns オブジェクトを使用して、正方形とタイルの両方の通知を送信します (最初に正方形、次にワイド)。以下は、プッシュ通知を送信するサーバー側のコードがどのように見えるかです (これは基本的に、DB テーブルでレコードが更新されるたびに呼び出されます)。

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

}

アプリ タイルが広い場合、ワイド通知が正しく表示されることに気付きました。しかし、アプリのタイルサイズを正方形にすると、正方形の通知が表示されません。どうすればこれを修正できますか?

4

2 に答える 2

3

1 つの更新を送信し、2 種類のタイルを一度に更新するために使用できるサンプルを次に示します。

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);
    }
}
);
于 2013-01-24T13:40:21.777 に答える
2

幅の広いコンテンツを含むタイル通知は、正方形のコンテンツを含むタイル通知に取って代わります。スクエア タイルとワイド タイルの両方のコンテンツを含む1 つの通知を送信する必要があります。

于 2013-01-20T21:03:07.823 に答える