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

问题描述 投票:1回答:1

我正在使用Ionic 3 + Cordova开发应用程序。在应用程序中,我已经导入了Firebase Cloud Message库,以向Android / ios用户发送推送通知。问题是我已经在Apple开发人员面板上设置了证书,但是有时我的应用程序中由函数“ 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工具上以获取令牌,因为我没有在互联网上找到任何解决方案。

firebase push-notification ionic3 firebase-cloud-messaging apple-push-notifications
1个回答
0
投票

我有相同的问题,只有在平台已就绪且fcm已连接时,才通过调用get_token()解决此问题:

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

    this.fcm.getToken().then(token => { // save the token in the backend
© www.soinside.com 2019 - 2024. All rights reserved.