简体   繁体   English

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

[英]firebase-x@ionic 4 not showing push messages (FCM)

I created this code in my app console:我在我的应用程序控制台中创建了此代码:

app.compontent.ts app.component.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 configuration:代码配置: 代码

Chrome console after sending push message via firebase console:通过 firebase 控制台发送推送消息后的 Chrome 控制台: android 控制台 - 收到推送

xCode Console when app init:应用程序初始化时的 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


I'm running my app in debug env.我在调试环境中运行我的应用程序。

Current behavior:当前行为:

Android:安卓:

  1. Getting push messages only when app working is closed (im not using app) - it is possible to get push when app is running?仅在应用程序关闭时获取推送消息(我不使用应用程序)- 可以在应用程序运行时获取推送消息吗?

iOS: IOS:

  1. Only getting APNS token, push will not showing.只获取APNS令牌,推送不会显示。 I checked double Settings -> notifications -> myApp Name -> everything is enabled.我检查了双重设置 -> 通知 -> myApp 名称 -> 一切都已启用。 In Firebase console im using both tokens (from IOS_TOKEN and GET_TOKEN) both not working.在 Firebase 控制台中,我使用两个令牌(来自 IOS_TOKEN 和 GET_TOKEN)都不起作用。

iOS: 13.3 (17C54) iOS:13.3 (17C54)

xCode: 11.3 (11C29) xCode:11.3 (11C29)

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

What should i do to start receiving pushes on iOS?我应该怎么做才能开始在 iOS 上接收推送?

I solved my problem.我解决了我的问题。

I forgot to upload my .p8 key to firebase.我忘了将我的 .p8 密钥上传到 firebase。 https://firebase.google.com/docs/cloud-messaging/ios/certs https://firebase.google.com/docs/cloud-messaging/ios/certs

Lesson learnt: always read documentation :)经验教训:始终阅读文档:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM