При отправке запроса на создание нового пользователя, если пользователь пытается отправить с недопустимым электронным письмом, приложение аварийно завершает работу (I.E. без знака @). Есть ли способ проверить, действительно ли письмо является действительным через Firebase или это то, что мне нужно для проверки стороны приложения?Проверка электронной почты с firebase для iOS
Я получаю ошибку в консоли:
* Нагрузочного приложение из-за неперехваченное исключение 'InvalidEmail', причина: 'jfkdsla; fjdk является недопустимым адресом электронной почты'
NSString *url = [NSString stringWithFormat:@"https://myapp.firebaseio.com/users/%@", displayName.text];
Firebase *dataRef = [[Firebase alloc] initWithUrl:url];
[dataRef observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
NSLog(@"Ref %@", snapshot.value);
snapshotValue = snapshot.value;
}];
if (snapshotValue == NULL) {
AppDelegate *appDelegate= (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.authClient createUserWithEmail:email.text password:password.text andCompletionBlock:^(NSError* error, FAUser*user) {
if (error != nil) {
// Error
NSLog(@"ERROR CODE: %d",error.code);
NSLog(@"ERROR: %@",error);
if (error.code == -9999) {
email.textColor = [UIColor redColor];
}
} else {
NSLog(@"Created %@",user.userId);
Firebase *userRef = [[Firebase alloc] initWithUrl:[NSString stringWithFormat:@"https://myapp.firebaseio.com/users/%@",displayName.text]];
[[userRef childByAppendingPath:@"name"] setValue:fullName.text];
[[userRef childByAppendingPath:@"user_id"] setValue:user.userId];
Firebase *userCredentials = [[Firebase alloc] initWithUrl:[NSString stringWithFormat:@"https://myapp.firebaseio.com/users/%@/credentials",displayName.text]];
[[userCredentials childByAppendingPath:@"email"] setValue:email.text];
[[userCredentials childByAppendingPath:@"password"] setValue:password.text];
AppDelegate *appDelegate= (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.authClient loginWithEmail:email.text andPassword:password.text
withCompletionBlock:^(NSError* error, FAUser* user) {
if (error != nil) {
NSLog(@"There was an error logging in to this account: %@",error);
} else {
NSLog(@"logged in");
[self dismissViewControllerAnimated:NO completion:nil];
[appDelegate.window.rootViewController presentViewController:appDelegate.tabBarController animated:YES completion:nil];
}
}];
}
}];
}
else {
displayName.textColor = [UIColor redColor];
}
}
есть ли с ode или snippet, который показывает, что вы делаете с * результатом * из Firebase? можете ли вы также показать код, который извлекает текст текстового поля адреса электронной почты? –
Вот мой код для создания нового пользователя. –