【发布时间】:2017-07-29 16:30:36
【问题描述】:
我需要为登录到应用程序的每个用户创建并使用包含所有详细信息(uid、名称等)的数据库条目
我在存储用户数据以便在 Android 中使用 Firebase 使用和检索用户个人资料信息时遇到问题。我在旧版本的 Firebase 上找到了这个 documentation,但这似乎不再起作用了。
有谁知道如何重现上述代码以使其适用于新版本的 Firebase?非常感谢。
编辑 - 下面的代码:
final Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.authWithPassword("jenny@example.com", "correcthorsebatterystaple",
new Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
// Authentication just completed successfully :)
Map<String, String> map = new HashMap<String, String>();
map.put("provider", authData.getProvider());
if(authData.getProviderData().containsKey("displayName")) {
map.put("displayName", authData.getProviderData().get("displayName").toString());
}
ref.child("users").child(authData.getUid()).setValue(map);
}
@Override
public void onAuthenticationError(FirebaseError error) {
// Something went wrong :(
}
});
【问题讨论】:
标签: android firebase firebase-realtime-database firebase-authentication