Search code examples
iosobjective-cparse-platformfacebook-loginfacebook-ios-sdk

'user' is always nil in logInInBackgroundWithReadPermissions in Parse iOS SDK


I'm using Facebook SDK with Parse SDK in user Login. Using 'logInInBackgroundWithReadPermissions' to perform login, Even though user is authenticated the app, 'user' is always nil in the response. And error is:

Error Domain=com.facebook.sdk.login Code=304 "The operation couldn’t be completed. (com.facebook.sdk.login error 304.)"

Here is my Implementation:

• Basic configuration:
I have configured every thing in .plist and followed guidelines at link1, link2

• Imported frameworks:

enter image description here

• Implementation in Appdelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [Parse setApplicationId:@"I have used real key here" clientKey:@"I have used real key here"];
    [PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions];
    return YES; }


- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    [FBSDKAppEvents activateApp];
}

• Login Implementation:

NSArray *fbPermissions = [[NSArray alloc] initWithObjects: @"public_profile", nil];
    [PFFacebookUtils logInInBackgroundWithReadPermissions:fbPermissions block:^(PFUser *user, NSError *error) {
        if (!user) {
            NSLog(@"Uh oh. The user cancelled the Facebook login.");
        }
        else if (user.isNew) {
            NSLog(@"User signed up and logged in through Facebook!");
        } else {
            NSLog(@"User logged in through Facebook!");
        }
    }];

But in the call back, 'user' is always nil. Did anyone face the same issue?
- Thanks in advance.


Solution

  • I was not able to find out cause for the issue. But I just deleted all frameworks related to Parse and Facebook and Re-added all of them. It worked fine. So, there is no issue in the code.