【发布时间】:2016-01-24 15:55:32
【问题描述】:
我现在正在开发 Xamarin.Forms 应用程序,但在配置推送通知时遇到了一些问题。我已经关注了https://azure.microsoft.com/en-us/documentation/articles/partner-xamarin-mobile-services-xamarin-forms-get-started-push/ 上的文档,但这只会教您如何使用推送通知响应请求。
如何创建推送通知并将其发送给 Xamarin.Forms 中的用户?如何设置不同的推送渠道,以便一次通知特定的用户组?
事实上,这是我用于响应推送通知的 Javascript 后端代码:
function insert(item, user, request) {
// Execute the request and send notifications.
request.execute({
success: function() {
// Create a template-based payload.
var payload = '{ "message" : "New item added: ' + item.text + '" }';
// Write the default response and send a notification
// to all platforms.
push.send(null, payload, {
success: function(pushResponse){
console.log("Sent push:", pushResponse);
// Send the default response.
request.respond();
},
error: function (pushResponse) {
console.log("Error Sending push:", pushResponse);
// Send the an error response.
request.respond(500, { error: pushResponse });
}
});
}
});
}
【问题讨论】:
-
这只是一个建议。值得一看 parse.com,它有一个推送通知服务和适用于所有平台的非常简单的 API。
标签: javascript azure xamarin push-notification xamarin.forms