android - ionic firebase.getToken() 总是在 android API 23 6.0.0 上返回 null 但在其他版本的 android 上不返回

标签 android firebase ionic-framework

为什么 firebase.getToken() 在 android API 23 6.0.0 上总是返回 null 而在其他版本的 android 上却不返回?我在android nougat, oreo, marsh(6.0.1)上试过,23之前的版本不为空,只在android 6.0.0上

注意:我正在使用插件 cordova-plugin-firebase 1.0.5 ( https://github.com/arnesson/cordova-plugin-firebase ) 我正在运行模拟器 genymotion

代码

this.platform.ready().then(() => {      
  // Okay, so the platform is ready and our plugins are available.
  // Here you can do any higher level native things you might need.
  var idtoken: string;

  if(this.platform.is('core') || this.platform.is('mobileweb')) {

  }else {
    this.firebase.getToken().then(token => {
        idtoken = token;
        alert(token)
     }) // save the token server-side and use it to push notifications to this device
    .catch(error => {
        console.error('Error getting token', error)
     });
    this.firebase.onTokenRefresh().subscribe((token: string) => {
        idtoken = token;
    });
  }
}

最佳答案

你运行到模拟器,请确保你的模拟器安装了google play服务

关于android - ionic firebase.getToken() 总是在 android API 23 6.0.0 上返回 null 但在其他版本的 android 上不返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52370387/

相关文章:

jquery - 创建一个文件并使用 ionic 将数据写入其中

不同 API 上的 Android 绘画问题

安卓服务 : Restarting once killed or removed from task stack from phone(Clear All) tasks

android - (Android) ParsePushBroadcastReceiver 的子类不会在推送通知时被调用。 (parse.com)

firebase - 我应该如何向我的 Info.plist 文件添加自定义 URL 方案以进行 Firebase 电话身份验证?

带有 gmap 和 ionic 框架的 Javascript 代码

android - 非清算通知会保留多长时间?

firebase - 何时设置 Firebase 身份验证状态持久性

ios - 在 iOS 记录事件后从 Firebase Analytics 发送邮件

angularjs - 第一个服务总是以未知的形式出现