我知道这个问题主要是 tag registration ANH 的重复。但没有具体答案,这就是我再次提出的原因。
我正在开发 Cordova 应用程序并使用此 Azure 移动服务插件 ( https://github.com/Azure/azure-mobile-apps-cordova-client ) 来注册推送通知。我从 PNS(gcm 和 apns)获得成功响应,并且向通知中心注册(注册事件)的调用也返回下面的成功响应。当我使用 Azure 通知中心的“测试发送”实用程序发送通知而不指定标签时,我也会在设备上收到通知(在 IOS 和 Android 上),但当我尝试使用标签发送通知时,不会收到任何通知。还有其他方法可以注册标签吗?
client.push.register('gcm', handle, {
mytemplate: { body: { data: { message: "{$(messageParam)}" } },
tags: [tag}
}).then(function(data){
alert("success");
},function(error){
alert(error);
});} else if (device.platform === 'iOS') {
// Register for notifications.
client.push.register('apns', handle, {
mytemplate: { body: { aps: { alert: "{$(messageParam)}" } },
tags: [tag]}
}).then(function(data){
alert("success");
},function(error){
alert(error);
});}
最佳答案
如果您使用指定的插件,那么您确实有后端代码。标签只能在后端注册 - 不能在前端注册(好吧,除非您在请求中发送标签,然后在后端读取该请求以执行相同的请求 - 但这仍然是后端进行注册)。
此时。我建议不要使用 Azure 移动应用来实现此功能。创建一个为您进行注册的 Azure Function API,然后使用它来注册推送。 Azure 移动应用的 future 版本将不会包含 ANH 功能。
关于ios - 使用无法在 azure 通知中心工作的标签注册推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56785526/