6

I am using Xcode 7.0, testing on iOS 9.0.2 and using Facebook SDK 4.7.0. Code=308 "(null)" issue occur in iOS 9.I am using objective-c code in my project. how to resolve this? Below attach my code.

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

 [login logInWithReadPermissions:@[@"public_profile",@"email", @"user_friends"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error){

    if ([FBSDKAccessToken currentAccessToken]) { startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

             if (!error) {
             }

         }];

    }
}];
Cœur
  • 37,241
  • 25
  • 195
  • 267
Anbu
  • 101
  • 1
  • 10

5 Answers5

4

iOS9.2.1

This fixes my 308 issues

Open as 'source code', plist file, search for LSApplicationQueriesSchemes, then add/modify as needed.

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbauth2</string>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fbshareextension</string>
</array>
dklt
  • 1,703
  • 1
  • 12
  • 12
1

Try this code :

 FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    login.loginBehavior = FBSDKLoginBehaviorWeb;
    [login logInWithReadPermissions:@[@"email"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
         if (error)
         {
             // Process error
         }
         else if (result.isCancelled)
         {
             // Handle cancellations
         }
         else
         {
             if ([result.grantedPermissions containsObject:@"email"])
             {
                 NSLog(@"result is:%@",result);
                 [self fetchUserInfo];
                 [login logOut];
             }
         }
     }];
Dharmesh Dhorajiya
  • 3,976
  • 9
  • 30
  • 39
  • Thank You so much.It's working now @Dharmesh.I have one doubt iOS 9 app facebook login not using facebook app.now showing one pop up.this pop not maintane access token so I have login multiple time any solution? – Anbu Oct 27 '15 at 14:21
1
 - (IBAction)facebookClick:(id)sender {
    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
     [login logOut];
    login = [[FBSDKLoginManager alloc] init];
    login.loginBehavior = FBSDKLoginBehaviorWeb;
    [login logInWithReadPermissions:@[@"email"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        if (error)
        {
                 NSLog(@"Process error");
             //   [login logOut];
         } else if (result.isCancelled) {
             NSLog(@"Cancelled");
            // [login logOut];
         } else {
             NSLog(@"Logged in");
             [self getUserInformation];
         }
     }];
}
Tunaki
  • 132,869
  • 46
  • 340
  • 423
0

I think it is related to the new iOS 9 url handling scheme

You need to add the trusted urls to your plist under LSApplicationQueriesSchemes key

Related question

Community
  • 1
  • 1
Laszlo
  • 2,803
  • 2
  • 28
  • 33
  • Hi @Tuss Please explain breifly? I try to facebook login iOS9 device through error responce – Anbu Oct 28 '15 at 07:49
  • Hi @Tuss I try to facebook login iOS 9 device getting error responce Error Domain=com.facebook.sdk.login Code=308 "(null)" My Appdelegate code return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; – Anbu Oct 28 '15 at 08:12
  • 1
    Info.plist code LSApplicationQueriesSchemes fbapi fb-messenger-api fbauth2 fbshareextension I don't know What I am missing. – Anbu Oct 28 '15 at 08:16
0

For iOS 10 with xCode 8

Set ON your project's Keychain Sharing within Capabilities tab. target

Mohit Tomar
  • 5,173
  • 2
  • 33
  • 40