我试图将facebook登录添加到flutter firebase_auth plugin。
以下是现有的Google登录方法,运行正常:
private void handleSignInWithGoogle(MethodCall call, final Result result) {
@SuppressWarnings("unchecked")
Map<String, String> arguments = (Map<String, String>) call.arguments;
String idToken = arguments.get("idToken");
String accessToken = arguments.get("accessToken");
AuthCredential credential = GoogleAuthProvider.getCredential(idToken, accessToken);
firebaseAuth
.signInWithCredential(credential)
.addOnCompleteListener(activity, new SignInCompleteListener(result));
}
在这里,我添加了一个Facebook登录方法,该方法会产生以下错误:
private void handleSignInWithFacebook(MethodCall call, final Result result) {
@SuppressWarnings("unchecked")
Map<String, String> arguments = (Map<String, String>) call.arguments;
String accessToken = arguments.get("accessToken");
AuthCredential credential = FacebookAuthProvider.getCredential(accessToken);
firebaseAuth
.signInWithCredential(credential)
.addOnCompleteListener(activity, new SignInCompleteListener(result));
}
以下是完整的PR和travis-ci上构建错误的链接:https://github.com/flutter/plugins/pull/184
以下是本地生成的错误:
/Users/frederickcook/GondolaProjects/Eng/plugins/packages/firebase_auth/android/src/main/java/io/flutter/firebaseauth/FirebaseAuthPlugin.java:120: error: cannot find symbol
AuthCredential credential = FacebookAuthProvider.getCredential(accessToken);
^
symbol: variable FacebookAuthProvider
location: class FirebaseAuthPlugin
以下是travis-ci的错误:https://travis-ci.org/flutter/plugins/builds/257319164
请注意,GoogleAuthProvider和FacebookAuthProvider都是firebase身份验证包中的类:https://firebase.google.com/docs/reference/android/com/google/firebase/auth/package-summary
答案 0 :(得分:0)
import com.google.firebase.auth.FacebookAuthProvider;
以访问FacebookAuthProvider
类。