我在应用控制台中创建了以下代码:
app.compontent.ts
this.firebaseX.getToken().then(token => console.log('PUSH_TOKEN: GET_TOKEN: ', token))
.catch(err => console.log(err));
if (this.platform.is('ios')) {
this.firebaseX.grantPermission().then(hasPermission => console.log(hasPermission ? 'granted' : 'denied'));
this.firebaseX.onApnsTokenReceived().subscribe(token => console.log('PUSH_TOKEN: IOS_TOKEN: ' + token));
}
this.firebaseX.onMessageReceived().subscribe(message => console.log(message));
通过Firebase控制台发送推送消息后,
应用初始化时的xCode控制台:
2020-01-19 17:09:22.816015+0100 myApp[8896:2663293] registerForRemoteNotifications
2020-01-19 17:09:22.816107+0100 myApp[8896:2663293] _hasPermission: YES
...
2020-01-19 17:09:22.821477+0100 myApp[8896:2663036] PUSH_TOKEN: IOS_TOKEN: d2aac51a963530-FULL_TOKEN_HERE
2020-01-19 17:09:22.821807+0100 myApp[8896:2663036] PUSH_TOKEN: GET_TOKEN: frWxHosY-gQ:APA91bEk3-FULL_TOKEN_HERE
...
2020-01-19 17:13:46.395935+0100 myApp[8896:2663036] FCM direct channel = true
2020-01-19 17:15:39.418759+0100 myApp[8896:2663036] FCM direct channel = false
我正在调试环境中运行我的应用程序。
当前行为:
Android:
iOS:
iOS:13.3(17C54)
xCode:11.3(11C29)
“ cordova-plugin-firebasex”:“ ^ 7.0.1”
我该怎么做才能开始在iOS上接收推送?
答案 0 :(得分:0)
我解决了我的问题。
我忘记将.p8密钥上传到Firebase。 https://firebase.google.com/docs/cloud-messaging/ios/certs
经验教训:请务必阅读文档:)