本文介绍了Firestore令牌检索失败:INVALID_SENDER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我没有从addOnSuccessListener
,addOnFailureListener
,addOnCompleteListener
等接口接收任何回调.
I am not receiving any callback from interfaces such as addOnSuccessListener
, addOnFailureListener
,addOnCompleteListener
.
依赖项:
classpath 'com.google.gms:google-services:3.2.1'
implementation 'com.google.firebase:firebase-firestore:16.0.0'
// }
apply plugin: 'com.google.gms.google-services'
代码:
firestore = FirebaseFirestore.getInstance(); // required for first time
FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
.setTimestampsInSnapshotsEnabled(true)
.build();
firestore.setFirestoreSettings(settings);
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Map<String, Object> user = new HashMap<>();
user.put("Title", "Ada");
user.put("category", "Lovelace");
user.put("id", "123");
firestore = FirebaseFirestore.getInstance();
firestore.collection("quotes")
.add(user)
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
Log.d("quotes", "DocumentSnapshot added with ID: " + documentReference.getId());
Snackbar.make(fab, "DocumentSnapshot added with ID: " + documentReference.getId(), Snackbar.LENGTH_INDEFINITE).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w("quotes", "Error adding document", e);
Snackbar.make(fab, "OnFailureListener: " + e, Snackbar.LENGTH_INDEFINITE).show();
}
})
.addOnCompleteListener(new OnCompleteListener<DocumentReference>() {
@Override
public void onComplete(@NonNull Task<DocumentReference> task) {
Snackbar.make(fab, "OnCompleteListener: " + task.isSuccessful(), Snackbar.LENGTH_INDEFINITE).show();
}
});
}
});
E/FirebaseInstanceId: Token retrieval failed: INVALID_SENDER
E/FirebaseInstanceId: Token retrieval failed: INVALID_SENDER
E/FirebaseInstanceId: Token retrieval failed: INVALID_SENDER
推荐答案
如果您最近更改了google-services.json
文件,则只需从android项目中删除build
文件夹,然后重新构建您的项目即可.
If you have recently change your google-services.json
file then just delete build
folder from android project and re-build your project.
这篇关于Firestore令牌检索失败:INVALID_SENDER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!