为什么 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/