Firebase有时会为ios设备获取令牌NULL

Firebase有时会为ios设备获取令牌NULL,firebase,push-notification,ionic3,firebase-cloud-messaging,apple-push-notifications,Firebase,Push Notification,Ionic3,Firebase Cloud Messaging,Apple Push Notifications,我正在使用Ionic 3+Cordova开发一个应用程序。在应用程序中,我导入了Firebase云消息库,以向android/ios用户发送推送通知。问题是,我已经在Apple developer panel上设置了认证,但有时我的应用程序上的函数“get_token()”返回的令牌仅对IOS用户返回null,有时也返回null。有时此函数返回正确的令牌,然后推送通知可以正常工作,但有时不能 我已经尝试删除开发者apple菜单上的所有认证 get_token()函数位于app.component

我正在使用Ionic 3+Cordova开发一个应用程序。在应用程序中,我导入了Firebase云消息库,以向android/ios用户发送推送通知。问题是,我已经在Apple developer panel上设置了认证,但有时我的应用程序上的函数“get_token()”返回的令牌仅对IOS用户返回null,有时也返回null。有时此函数返回正确的令牌,然后推送通知可以正常工作,但有时不能

我已经尝试删除开发者apple菜单上的所有认证

get_token()函数位于app.component.ts文件中,这意味着该令牌是在用户打开应用程序时生成的

通过firebase服务器获取令牌:

try {
      const fcmToken = await this.fcm.getToken();
      Settings.push_token = fcmToken;
}
导入库:

import { FCM } from '@ionic-native/fcm';
此FCM变量将传递给构造函数内的FCM变量:

public fcm: FCM

我希望问题出在firebase工具上获取令牌,因为我在internet上没有找到任何解决方案。

我遇到了同样的问题,只有在平台准备好后,当fcm已经连接时,才调用get_token()来解决:

this.platform.ready().then(() => { // first, make sure platform is ready    

    this.fcm.getToken().then(token => { // save the token in the backend

我也遇到了同样的问题,只有在平台就绪后,当fcm已经连接时,才调用get_token()解决了这个问题:

this.platform.ready().then(() => { // first, make sure platform is ready    

    this.fcm.getToken().then(token => { // save the token in the backend