2

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?

Raman Sharma
  • 4,551
  • 4
  • 34
  • 63

2 Answers2

3

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);
    }
}
);
Teemu Tapanila
  • 1,275
  • 8
  • 20
2

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.

Community
  • 1
  • 1
Nathan Kuchta
  • 13,482
  • 2
  • 26
  • 35
  • Would you happen to know how to construct that payload on the server-side using Javascript? – Raman Sharma Jan 20 '13 at 22:34
  • It appears that the sendTile* methods only send a single type of content (square or wide). To construct a notification with both square and wide content, use the [send](http://msdn.microsoft.com/en-us/library/windowsazure/jj860484.aspx#send) method and explicitly pass in the notification XML. – Nathan Kuchta Jan 21 '13 at 03:52
  • That's what I meant. I am new to javascript, JSON, XML etc. Do you know how to construct that piece of xml payload? – Raman Sharma Jan 21 '13 at 05:21