【问题标题】:Push Notification for square and wide tiles方形和宽瓷砖的推送通知
【发布时间】:2013-01-20 18:05:56
【问题描述】:

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

}

我注意到当我的应用磁贴很宽时,宽通知会正确显示。但是,当我将应用程序的磁贴大小设置为方形时,不会显示方形通知。我该如何纠正这个问题?

【问题讨论】:

  • 没有一些代码几乎不可能回答。
  • @DanielKelley 添加了一些代码
  • 不清楚为什么当你的代码不是 C# 时它被标记为 C#。
  • 我已将问题重新标记为 JavaScript 和 WinJS。
  • 啊,我的错。我的客户端应用程序是 C#,尽管将通知推送到该应用程序的整个云基础架构都使用 Javascript

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


【解决方案1】:

这是一个示例,您可以使用它来一次发送一个更新并更新两种磁贴。

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

    【讨论】:

    • 您是否知道如何使用 Javascript 在服务器端构建该有效负载?
    • 看来 sendTile* 方法只发送一种类型的内容(方形或宽)。要构建具有方形和宽内容的通知,请使用send 方法并显式传入通知 XML。
    • 这就是我的意思。我是 javascript、JSON、XML 等的新手。你知道如何构造那段 xml 有效负载吗?
    猜你喜欢
    • 2018-05-28
    • 1970-01-01
    • 2014-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多