0

I added the facebook login with this method:

PFFacebookUtils.logInInBackgroundWithReadPermissions(permissionsArray, block: { (user: PFUser?, error: NSError?) -> Void in
        if let user = user {
            if user.isNew {
                println("User signed up and logged in through Facebook!");
            } else {
                println("User logged in through Facebook!");
            }
        } else {
            println("Uh oh. The user cancelled the Facebook login.");
        }
    })

But the block is never executed. There is no error message. I followed the Parse Tutorial and did all these steps. Maybe someone can help?

2 Answers 2

0

I don't think you have implemented the following in your AppDelegate. Just check that these methods are defined like this:

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

              return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication withSession:[PFFacebookUtils session]]; 

          }


-(void)applicationDidBecomeActive:(UIApplication )application 
        { 

            [FBAppCall handleDidBecomeActiveWithSession:[PFFacebookUtils session]]; 

        }

-(void)applicationWillTerminate:(UIApplication )application { 

         [[PFFacebookUtils session] close]; 
    }

For Swift, follow the below procedures:-

/ Import this header into your Swift bridge header file
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>

// AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    Parse.setApplicationId("parseAppId", clientKey:"parseClientKey")
    PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
    return true
}

In your app delegate, add the following handlers:

func applicationDidBecomeActive(application: UIApplication) {
    FBSDKAppEvents.activateApp()
}
func application(application: UIApplication,
    openURL url: NSURL,
    sourceApplication: String?,
    annotation: AnyObject?) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

Reffered from this link:-here

3
  • How to do this with Facebook SDK 4?
    – Fee Braun
    May 27, 2015 at 8:18
  • How to do this means?? You just have to define the following methods @FeeBraun
    – Vizllx
    May 27, 2015 at 8:24
  • I was just wondering because FBAppCall doesn't exist anymore it is now FBSDKApplicationDelegate so i was not sure if I need to add the session somewhere.
    – Fee Braun
    May 27, 2015 at 8:38
0

I managed to solve this problem. My Facebook App was the problem, I changed the app bundle and everything, but it was still referring to the wrong iOS App. So I had to create a new one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.