2
votes

I am using Azure Mobile Services for sending push notifications to my client app. I send both square and tile notification using the push.wns object (first square and then wide). Below is how the server-side code that sends push notifications looks like (this is basically called whenever a record is updated in my DB table):

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

}

I notice that the wide notification is displayed correctly when my app tile is wide. However, when I make the tile size of my app to square, the square notification is not displayed. How can I correct this?

2
Almost impossible to answer without some code. - Daniel Kelley
@DanielKelley added some code - Raman Sharma
It's not clear why this was tagged as C# when your code is not C#. - Daniel Kelley
I've retagged the question as JavaScript and WinJS. - JKor
ah my bad. My client app is C# although the entire cloud infrastructure that pushes notifications to this app is in Javascript - Raman Sharma

2 Answers

3
votes

Here's sample which you can use to send one update and update two kind of tiles at once.

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
votes

The tile notification with the wide content is replacing the tile notification containing the square content. A single notification should be sent containing both square and wide tile content.