私は新しいFirebaseに慣れていません。新しいユーザーを作成するにはどうすればよいですか?以下のコードは私がサインアップし、auth
新しいユーザーです。 Firebase Database
の「得意先」でこの新しいユーザーを作成する必要がある場合、追加するコードは何ですか?ありがとう! Firebase iOS - Save DataFirebaseユーザーの作成方法は?
2
A
答えて
3
FIRAuth.auth()?.createUserWithEmail(email, password: password, completion: { (user, err) in
if err != nil {
self.showAlert("Can't Register", msg: "Please enter email and password")
} else {
NSUserDefaults.standardUserDefaults().setValue(user?.uid, forKey: "uid")
FIRDatabase.database().reference().child("Customers").setValue([user!.uid : "true"])
//Or if you want to save the users Details too:-
/*
FIRDatabase.database().reference().child("Customers").setValue([user!.uid : ["email" : email,"password" : password]])
*/
self.performSegueWithIdentifier("toSecondVC", sender: self)
}
})
はまた、私はこれを読んで示唆する
var values = [Any : Any] // This is a dictionary where you can store user details
values["userUID"] = // user's uid
values["usersName"] = // user's name
// etc.
let customerRef = databaseReference.child("Customers") // You could also add a child with the user's UID in order to identify each user
customerRef.updateChildValues(values, withCompletionBlock: { (error, ref) in
if error != nil {
// display error.code and error.localizedDescription to user if needed
} else if ref != [] {
// Success!
// If needed, save the user to NSUserDefaults and perfrom a segue to another ViewController
} else {
// There was an error, but not sure what happened. Let the user know how they can fix the problem (maybe add the details to the database later)
}
})
0
答えは上記正しいですが、私はそれをこのようにやってお勧めします:
FIRAuth.auth()?.createUserWithEmail(email, password: password, completion: { (user, err) in
if err != nil {
self.showAlert("Can't Register", msg: "Please enter email and password")
} else {
NSUserDefaults.standardUserDefaults().setValue(user?.uid, forKey: "uid")
FIRAuth.auth()?.signInWithEmail(email, password: password, completion: { (user, error) in
})
self.performSegueWithIdentifier("toSecondVC", sender: self)
}
})
関連する問題
- 1. Firebase認証ユーザーの作成
- 2. ユーザーを作成中にユーザーのFirebase setDisplayName
- 3. 新しいFirebaseユーザーを作成する - 正しい方法
- 4. Firebaseを使用して新規ユーザーのカスタムURLを作成する方法は?
- 5. Firebaseコンソールからユーザーを作成するFirebase?
- 6. firebase uidの生成方法
- 7. firebaseのカスタムユーザープロパティを作成する方法は?
- 8. Firebase:確認コードの生成方法は?
- 9. ユーザー作成ウィザードでユーザーにアクティベーションコードを送信する方法は?
- 10. Firebaseで新しいDatabaseErrorインスタンスを作成する方法は?
- 11. Firebaseを使ってパブリック/プライベートユーザプロファイルを作成する方法は?
- 12. Firebaseポッドに応じてカスタムポッドライブラリを作成する方法は?
- 13. アプリで/ユーザーを作成する方法
- 14. Django Rest Frameworkユーザーモデルの拡張方法、ユーザーの作成方法
- 15. joomlaユーザー作成時にデータベース表を作成する方法
- 16. 作成されたユーザーの作成方法、作成日、変更されたユーザー、テーブルの変更日
- 17. Firebase:ユーザーが他のユーザーのアカウントを作成できるようにします。
- 18. Firebase:アップデートまたは作成
- 19. Firebaseの名前、ユーザー名などで新しいユーザーを作成します
- 20. ユーザー登録前のFirebaseデータベースのスキャン方法は?
- 21. Meteorアプリケーションのサーバー状態とユーザー、状態の作成方法は?
- 22. ユーザーごとにユーザーIDを取得する方法Firebase android?
- 23. ユーザー検索機能の作成方法は?
- 24. ユーザーのログイン状況チェッカーを作成する方法は?
- 25. deviseユーザー用のプロファイルを作成する方法は?
- 26. ユーザー指定のレコード数でハイブテーブルを作成する方法は?
- 27. Firebaseで匿名ユーザーが作成された回数
- 28. JavascriptとFirebase 3 - 電子メールとパスワードでユーザーを作成する
- 29. 自動サインインなしでFirebaseユーザーをiosに作成
- 30. firebaseを使用してリーダーボードを作成する方法
こんにちはドラヴィダを、ありがとうございました!うまくいきます!ハッピー・フライデー! – developermike