我有一个带有聚合物火力的PSK(聚合物入门套件)PWA构建,我想从Firebase Auth呼叫fetchSignInMethodsForEmail()
。我尝试过以下但有错误。
firebase.auth().fetchSignInMethodsForEmail(email).then((methods) => {
// Do something
});
错误Uncaught TypeError: firebase.auth(...).fetchSignInMethodsForEmail is not a function
。
我也试过以下但没有运气,即
firebase.auth.fetchSignInMethodsForEmail(email);
firebase.$.auth.fetchSignInMethodsForEmail(email); // Assume firebase-auth with id of 'auth'
答案 0 :(得分:1)
fetchProvidersForEmail()
,因此您需要至少拥有v4.12及更高版本。
据说它在v5.0中被弃用,而不是fetchSignInMethodsForEmail()
。
答案 1 :(得分:0)
首先,您必须声明Auth对象m
FirebaseAuth f = FirebaseAuth.getInstance();
然后调用fetchSignInMethodsForEmail()方法。
如下:-
// [START auth_differentiate_link]
auth.fetchSignInMethodsForEmail(email)
.addOnCompleteListener(new OnCompleteListener<SignInMethodQueryResult>() {
@Override
public void onComplete(@NonNull Task<SignInMethodQueryResult> task) {
if (task.isSuccessful()) {
SignInMethodQueryResult result = task.getResult();
List<String> signInMethods = result.getSignInMethods();
if(signInMethods.contains(EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD))
{
// User can sign in with email/password
} else if (signInMethods.contains(EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD)) {
// User can sign in with email/link
}
} else {
Log.e(TAG, "Error getting sign in methods for user", task.getException());
}
}
});
// [END auth_differentiate_link]
}