I'm running the most recent version of XCode and Swift. I'm trying to implement Facebook Login; however, I keep on running into persistent errors.
First I am getting this:
-canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
I implemented the solutions listed here yet still no luck . How to use Facebook iOS SDK on iOS 10
I've tried double checking Keychain Access On, Reinstalling FacebookSDK, implementing it in various different ways such as: http://ashishkakkad.com/2015/05/facebook-login-swift-language-ios but I can't seem to get around this.
Here is my login result: Optional(<FBSDKLoginManagerLoginResult: 0x170251550>
Not sure if that is right. Also I get this error though I don't have network loss on and my wifi is perfectly connected. Could not successfully update network info during initialization.
@IBAction func fbLoginButtonPressed(_ sender: AnyObject) {
let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
fbLoginManager.logIn(withReadPermissions: ["email"], from: self) { (result, error) in
print("Here is the result", result)
print("Here is the error" , error)
if (error == nil){
print("the error is nil")
let fbloginresult : FBSDKLoginManagerLoginResult = result!
//commenting if statement out temporarily for debugging purposes
// if(fbloginresult.grantedPermissions.contains("email"))
// {
print("email is contained and printing result")
self.getFBUserData()
fbLoginManager.logOut()
// }
}
}
}
func getFBUserData(){
if((FBSDKAccessToken.current()) != nil){
FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start(completionHandler: { (connection, result, error) -> Void in
print("inside get FB user data")
if (error == nil){
self.dict = result as! [String : AnyObject]
print(result!)
print(self.dict)
}
})
}
}
Why is this occurring and how can this be resolved?
I realized the problem was in the App Delegate https://gist.github.com/codegefluester/f797dd723e93e545b855525a4b9ab057
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
// Override point for customization after application launch.
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
public func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
app,
open: url as URL!,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation]
)
}
public func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
application,
open: url as URL!,
sourceApplication: sourceApplication,
annotation: annotation)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.