Ios – -canOpenURL: failed for URL: “fbauth2:/” (OSStatus error -10814.)”

facebookios

i'm adding Facebook and Google signup in my application but i have this issue

The operation couldn’t be completed. -10814

in the Facebook login and i don't know how to solve it, this is my app delegate code for the openUrl:

 func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any])
        -> Bool {

            if let fbSDKAppId = FBSDKSettings.appID(), url.scheme!.hasPrefix("fb\(fbSDKAppId)"), url.host == "authorize" {
            var shouldOpen :Bool = FBSDKApplicationDelegate.sharedInstance().application(application,  open: url, sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String!,annotation:options[UIApplicationOpenURLOptionsKey.annotation])
            return shouldOpen
            }
            else {
                return GIDSignIn.sharedInstance().handle(url,
                                                     sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
                                                     annotation: [:])
                }

            }

what i can do?

Best Answer

now I used the latest SDK v4.26.0 downloaded from here and I followed the link for steps to install for FB. and my code is

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];

if ([[[UIDevice currentDevice] systemVersion] floatValue] <= 9) {
    // After iOS9 we can not use it anymore
    login.loginBehavior = FBSDKLoginBehaviorSystemAccount;
} else {
    login.loginBehavior = FBSDKLoginBehaviorWeb;
}

NSArray *permission = [[NSArray alloc] initWithObjects:@"email",@"public_profile",@"user_friends", nil];
NSLog( @"### running FB sdk version: %@", [FBSDKSettings sdkVersion] );

[login logInWithReadPermissions:permission fromViewController:(UIViewController *)self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    [self removeActivityIndicatorWithBg:activityIndicator];

    if (error) {
        NSLog(@"Process error");
    } else if (result.isCancelled) {
        NSLog(@"Cancelled");
    } else {
        NSLog(@"Logged in%@",result.grantedPermissions);
    }
}];

here i used the login behavior as FBSDKLoginBehaviorSystemAccount and I get the error as

(- error: "The operation couldn’t be completed. -10814)

so in my simulator or device contains no accounts setup in system settings for facebook. then it comes on the following block

if (error) {
    NSLog(@"Process error");
}

if I print the error,

No Facebook account. There are no Facebook accounts configured. You can add or create a Facebook account in Settings.

so I changed the loginBehavior from FBSDKLoginBehaviorSystemAccount to FBSDKLoginBehaviorWeb, I got all OP with out error

Related Topic