Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-canOpenURL: failed for URL: "fbauth2:/" (OSStatus error -10814.)"

Tags:

ios

facebook

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?

like image 223
bero Avatar asked Sep 20 '17 10:09

bero


2 Answers

Worked after adding openUrl with options:

Facebook documentation

Note that application:openURL:options: is only available in iOS 9 and above. If you are building with an older version of the iOS SDK, you can use:

- (BOOL)application:(UIApplication *)application 
            openURL:(NSURL *)url 
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {

  BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
    openURL:url
    sourceApplication:sourceApplication
    annotation:annotation
  ];
  // Add any custom logic here.
  return handled;
} 
like image 147
Vishnu_a93 Avatar answered Oct 27 '22 01:10

Vishnu_a93


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

like image 8
Anbu.Karthik Avatar answered Oct 27 '22 00:10

Anbu.Karthik