Javascript 使用带有自定义API的Azure移动服务向单个用户发送通知
我希望使用Azure移动服务向个人用户发送通知。当我在Visual Studio 2013中添加通知服务时,它会在我的Azure服务中自动生成自定义API。因为我已经用JavaScript后端构建了我的移动服务。生成代码如下所示:Javascript 使用带有自定义API的Azure移动服务向单个用户发送通知,javascript,node.js,azure,windows-phone-8,push-notification,Javascript,Node.js,Azure,Windows Phone 8,Push Notification,我希望使用Azure移动服务向个人用户发送通知。当我在Visual Studio 2013中添加通知服务时,它会在我的Azure服务中自动生成自定义API。因为我已经用JavaScript后端构建了我的移动服务。生成代码如下所示: exports.post = function (request, response) { response.send(statusCodes.OK); sendNotifications(request); }; function sendNot
exports.post = function (request, response) {
response.send(statusCodes.OK);
sendNotifications(request);
};
function sendNotifications(request) {
var payload = '<?xml version="1.0" encoding="utf-8"?><toast><visual><binding template="ToastText01">' +
'<text id="1">' + request.body.toast + '</text></binding></visual></toast>';
var push = request.service.push;
push.wns.send(null,
payload,
'wns/toast', {
success: function (pushResponse) {
console.log("Sent push:", pushResponse);
}
});
}
其中userIdTags是一个字符串列表,其中包含我希望接收消息的某些userId值
但是当我调试时,我发现所有用户都会收到通知。因此我想知道我是否需要处理或修改自定义API中的自动生成代码,或者是任何其他导致问题的原因。我想你已经做了你在客户端所做的事情,你需要更新你的移动服务脚本。你想做的事类似于。因此,请检查博客中的概念。如果它仍然有效,因为我使用了自定义身份验证,但没有使用Microsoft提供的任何身份验证方法?抱歉,我发现我提供了一个错误的链接给你。检查。我认为认证方式并不重要
`await App.MobileService.GetPush().RegisterNativeAsync(channel.Uri,userIdTags);`