我正在使用 ionic
开发应用程序,我需要获取推送通知的设备 token ,但遇到了麻烦。应用程序没有收到通知,但我仍然需要在用户登录应用程序时发送设备 token (例如,我需要在不接收通知的情况下获取设备 token )。我也尝试使用 Cordova 推送通知插件。
最佳答案
我用过 phonegap-plugin-push插件,它非常容易和简单。对于 regID
在 deviceReady
上的代码中我用过的事件。
var push = PushNotification.init({
"android": {
"senderID": "SENDER-ID"
},
"ios": {"alert": "true", "badge": "true", "sound": "true"},
"windows": {}
});
push.on('registration', function(data) {
console.log("registration event");
//here is your registration id
console.log(data.registrationId);
});
This也是教程的链接
希望能帮助到你。
关于cordova - 使用 ionic 框架从设备检索设备 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36717556/