Advertisement
Guest User

Untitled

a guest
Aug 7th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. - (void)signUpUser:(NSString *)username password:(NSString *)password email:(NSString *)email completion:(void (^)(FIRUser *user, NSError *error))completion {
  2. [[FIRAuth auth]
  3. createUserWithEmail:email
  4. password:password
  5. completion:^(FIRUser *user, NSError *error) {
  6. FIRDatabaseReference *ref = [[FIRDatabase database] reference];
  7. FIRDatabaseReference *userRef = [[ref child:@"users"] child:username];
  8. [userRef observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
  9. if (snapshot && snapshot.value[@"uid"] == nil) {
  10. [userRef setValue:user.uid forKey:@"uid"];
  11. }
  12. }
  13. withCancelBlock:^(NSError * _Nonnull error) {
  14. NSLog(@"%@", error.localizedDescription);
  15. }];
  16. }];
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement