我有两个 Android 设备 5.1.1 、 5.0.2 和模拟器(Pixel2 api 28 (android 9) ),对于第一个设备(5.1.1),我可以毫无问题地生成 fcm token
我正在使用此代码来生成 token
irebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
@Override
public void onComplete(@NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
Log.w("FCM_TOKEN", "getInstanceId failed", task.getException());
return;
}
// Get new Instance ID token
String token = task.getResult().getToken();
}
});
我在使用第二个设备 (5.0.2) 和模拟器 (android 9) 时遇到此异常
05-26 01:10:01.115 13377-13402/com.abc.payapp E/FirebaseInstanceId: token 检索失败:AUTHENTICATION_FAILED
生成 token 时需要什么样的身份验证!
最佳答案
使用模拟器或设备不使用 Google Play 将导致此错误。
检查您的设备/模拟器上的 Google Play 商店应用,进行更新,然后就可以开始了!
关于java - 无法为某些设备生成 FCM token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56309965/