firebase-x @ ionic 4未显示推送消息(FCM)

时间:2020-01-19 16:25:31

标签: android ios firebase ionic-framework

我在应用控制台中创建了以下代码:

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));

xCode配置: xCode

通过Firebase控制台发送推送消息后,

Chrome控制台: android console - push received

应用初始化时的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:

  1. 仅在关闭应用程序工作时(不使用应用程序)获取推送消息-是否可以在应用程序运行时获取推送消息?

iOS:

  1. 仅获取APNS令牌,推送不会显示。我检查了双重设置->通知-> myApp名称->启用了所有功能。在Firebase控制台中,我同时使用了两个令牌(分别来自IOS_TOKEN和GET_TOKEN)都无法正常工作。

iOS:13.3(17C54)

xCode:11.3(11C29)

“ cordova-plugin-firebasex”:“ ^ 7.0.1”

我该怎么做才能开始在iOS上接收推送?

1 个答案:

答案 0 :(得分:0)

我解决了我的问题。

我忘记将.p8密钥上传到Firebase。 https://firebase.google.com/docs/cloud-messaging/ios/certs

经验教训:请务必阅读文档:)

相关问题