【发布时间】:2019-08-02 12:50:27
【问题描述】:
当我直接通过 USB 运行我的应用程序时,我可以正常获取令牌,但我已将应用程序上传到 testFlight,并且在我第一次在设备上运行应用程序时,我通过 Firebase 服务器获取了 null 令牌。如果我关闭应用程序并再次打开它,则会生成令牌并且推送通知正常工作。
我正在使用插件:Cordova-plugin-firebase
离子信息:
Ionic:
ionic (Ionic CLI) : 4.2.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.9
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 8.0.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 15 other plugins)
System:
Android SDK Tools : 26.1.1 (/Users/bruno/Library/Android/sdk)
ios-deploy : 1.9.2
NodeJS : v8.12.0 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS
Xcode : Xcode 10.1 Build version 10B61
我试过了: - 下载应用程序 -> 打开它 -> 关闭它 -> 再次打开它并获取令牌
我已将令牌请求放在 app.components.ts 上,以便在应用打开时获取它。
solicitarToken(){
this.firebase.grantPermission();
this.firebase.getToken()
.then(token => {
Settings.push_token = token;
this.iniciarListenerDeNotificacoes();
return token;
})
.catch(error => {
console.error('Error getting token', error);
return null;
});
}
这个请求放在构造函数的末尾。
我没有收到任何错误消息,只有空标记。我读过有时 Firebase 需要时间来生成令牌。我想在等待几毫秒,但我需要一个自信的解决方案,因为苹果分析应用程序有大约 3 天的延迟。
【问题讨论】:
标签: ios firebase ionic-framework apple-push-notifications