I'm getting this error when trying to log in with Facebook:
Optional(Error Domain=com.facebook.sdk.core Code=3 "(null)" UserInfo={com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Unknown error building URL.})
I read in other posts it's a bug in version sing 4.39.0 of FBSDKLoginKit and the solution is downgrading to 4.38.o Now that gave me another error: Firebase Auth Interop/FIRAuth Interop.h' file not found in the FIRAuth.m #import <FirebaseAuthInterop/FIRAuthInterop.h>
As I'm new to social logins and the guide in Facebook developer page is not up to date with swift and some is in obj-c I might mistranslated it to swift. Can you spot where is the problem?
Also FBSDKLogin framework is highlighted in red in frameworks folder, and all the framework inside pods/Frameworks folder.
Here's the code:
AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge], completionHandler: ({_,_ in
}))
UNUserNotificationCenter.current().delegate = self
var error: NSError?
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
} catch let error1 as NSError{
error = error1
print("could not set session. err:\(error!.localizedDescription)")
}
do {
try AVAudioSession.sharedInstance().setActive(true)
} catch let error1 as NSError{
error = error1
print("could not active session. err:\(error!.localizedDescription)")
}
window?.tintColor = UIColor.blue
// Use Firebase library to configure APIs
FirebaseApp.configure()
// goggle only
GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
GIDSignIn.sharedInstance().delegate = self
// Facebook SDK
// FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
// return true
}
The open URL where I put both Google sign in and Facebook:
// start google sign in methods
@available(iOS 9.0, *)
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any])
-> Bool {
// google only
// return
// GIDSignIn.sharedInstance().handle(url,
// sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
// annotation: options[UIApplicationOpenURLOptionsKey.annotation])
// both google and facebook
let googleDidHandle = GIDSignIn.sharedInstance().handle(url,
sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation])
guard let source = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String else { return false }
let annotation = options[UIApplicationOpenURLOptionsKey.annotation] as? String
let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: source, annotation: annotation)
// return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: source, annotation: annotation)
return googleDidHandle || facebookDidHandle
}
The login vc with Facebook method where I get the error:
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
if error == nil {
print("User just logged in via Facebook")
let credentials = FacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
Auth.auth().signInAndRetrieveData(with: credentials) { (user, error) in
if (error != nil) {
print("Facebook authentication failed")
} else {
print("Facebook authentication succeed")
}
}//)
} else {
print("An error occured the user couldn't log in")
print(error)
}
}