App could not authenticate with Facebook and Firebase after conversion to swift 3 syntax
In My app also Facebook and Google Login not working in iOS 10. So I have made ON keychain sharing and it works. Like
It may help. Tell me if not.
Facebook iOS Swift SDK: Not getting callback
Turns out I was missing the AppDelegate part to handle url opens:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return SDKApplicationDelegate.shared.application(application,
open: url,
sourceApplication: sourceApplication,
annotation: annotation)
}
Login with facebook not working ios
Finally I found the solution. I guess this was iOS 9.3 specific issue.
I had to change openUrl
method code in AppDelegate.
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options {
return [[FBSDKApplicationDelegate sharedInstance] application:app
openURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
}
I changed to this and it worked. Hope it helps someone else.
need to link firebase anonymous account to google login or facebook login account on firebase
This isn't an error this the way it's supposed to work. When you sign a user in anonymously Firebase assigns a UID to that anonymous user. Once that user is linked to a proper account that account is assigned the UID from the anonymous user.
What you're doing is signing an existing user in anonymously, which assigns them a new UID. Then you're trying to link that UID with an existing account. The error you are getting is correct. The account credentials are already in use from the first time you linked the previous anonymous account.
Once a user creates an account (i.e. their anonymous account is linked) they need to continue to use that account.
This means you can either not let them sign in anonymously anymore or you can just leave them signed in.
Convert an anonymous account to a permanent account
Link Multiple Auth Providers to an Account on iOS
How to check if user needs to re-authenticate using Firebase Authentication
Swift 3
I had to do this yesterday when trying to delete a user. One thing to note is FIRAuthErrorCodeCredentialTooOld
is now FIRAuthErrorCode.errorCodeRequiresRecentLogin
What I did was trigger a UIView
to ask for log in details if that error is thrown. Since I was using email and password, that's what I collected from the user in my example.
private func deleteUser() {
//get the current user
guard let currentUser = FIRAuth.auth()?.currentUser else { return }
currentUser.delete { (error) in
if error == nil {
//currentUser is deleted
} else {
//this gets the error code
guard let errorCode = FIRAuthErrorCode(rawValue: error!._code) else { return }
if errorCode == FIRAuthErrorCode.errorCodeRequiresRecentLogin {
//create UIView to get user login information
let loginView = [yourLoginUIViewController]
self.present(loginView, animated: true, completion: nil)
}
}
}
Once I had the login information I ran this function to reauthenticate the user. In my case I ran it the loginView
in the above code if the login in was successful:
func reauthenticateUserWith(email: String, password: String) {
FIRAuth.auth()?.signIn(withEmail: email, password: password) { (user, error) in
if error == nil {
//display UIView to delete user again
let deleteUserView = deleteUserView()
present(deleteUserView, animated: true, completion: nil)
} else {
//handle error
print(error!.localizedDescription)
}
}
}
The deleteUserView
in my case calls deleteUser()
on a button tap from the user. You can also use UIAlertController
in place of the custom UIView
s, but that's up to you.
Hope this helps.
How to Handle Firebase Auth exceptions on flutter
(21/02/20) EDIT: This answer is old and the other answers contains cross platform solutions so you should look at theirs first and treat this as a fallback solution.
The firebase auth plugin doesn't really have a proper cross-platform error code system yet so you have to handle errors for android and ios independently.
I'm currently using the temporary fix from this github issue: #20223
Do note since its a temp fix, don't expect it to be fully reliable as a permanent solution.
enum authProblems { UserNotFound, PasswordNotValid, NetworkError }
try {
FirebaseUser user = await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: password,
);
} catch (e) {
authProblems errorType;
if (Platform.isAndroid) {
switch (e.message) {
case 'There is no user record corresponding to this identifier. The user may have been deleted.':
errorType = authProblems.UserNotFound;
break;
case 'The password is invalid or the user does not have a password.':
errorType = authProblems.PasswordNotValid;
break;
case 'A network error (such as timeout, interrupted connection or unreachable host) has occurred.':
errorType = authProblems.NetworkError;
break;
// ...
default:
print('Case ${e.message} is not yet implemented');
}
} else if (Platform.isIOS) {
switch (e.code) {
case 'Error 17011':
errorType = authProblems.UserNotFound;
break;
case 'Error 17009':
errorType = authProblems.PasswordNotValid;
break;
case 'Error 17020':
errorType = authProblems.NetworkError;
break;
// ...
default:
print('Case ${e.message} is not yet implemented');
}
}
print('The error is $errorType');
}
Related Topics
Box Shadow Spread Bug in Webkit in iOS 7 on Retina Ipads
Get Path to Subdirectory in Resources Folder
Passing Arguments to @Selector Method
Shared Iad Banner Bannerviewdidloadad Not Being Called
Cloudkit Push Notifications on Record Update Stopped Working
How to Request Photo Gallery Permissions in iOS a Second Time
Why [Uiscreen Mainscreen].Bounds] Is Not Returning Full Screen Size
View Height Problems (Continued)
Retrieve All Child Value to a Label in Table View Cell
How to Present Uiview (Xib) as Alert View in Swift
How to Print Name of The Day of The Week
Opencv Error: Assertion Failed on iOS
How to Fetch Images from Photo Library Within Range of Two Dates in iOS
Applying Different Attributes for Different Portions of an Nsattributedstring