Question

I'm trying to integrate a Facebook login into my app, and been doing so for the past two days without luck.

The login-button works: It logs me in and then changes text to "log out".

However, nothing else works. I can't get the name, I've tried placing random NSLog statements around in my code, but the only ones that prints are the ones in viewDidLoad. Nothing else.

Here's my code (I'm using a graphical implementation of the button btw)

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

  NSLog(@"Print 1");
  // Call FBAppCall's handleOpenURL:sourceApplication to handle Facebook app responses
  BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];

  // You can add your app-specific url handling code here if needed

  return wasHandled;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSLog(@"Print 2");
  // Override point for customization after application launch.
  [FBLoginView class];
  self.loginView.readPermissions = @[@"basic_info", @"email", @"user_likes"];
  NSLog(@"Initiating the FBLoginView");
  return YES;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
  NSLog(@"Print 3");
  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  if (self) {
    NSLog(@"Print 4");
  }
  return self;
}

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user {
  NSLog(@"Print 5");
}

- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {
  NSLog(@"Print 6");
}

- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view.
  NSLog(@"Print 7");
}

- (void)didReceiveMemoryWarning
{
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}

I'm very unsure as to where I'm gonna place the readPermissions, but I've tried nearly everything. I've also tried different stuff like

FBLoginView *loginView = [[FBLoginView alloc] init];
loginView.readPermissions = @[@"basic_info", @"email", @"user_likes"];

etc, but nothing works. Right now I have connected the loginView to my .h file via an IBOutlet, not sure if that's how it's done though. Facebooks guide online is really bad at this...

Can anyone help me? Why doesn't any of my NSLog statements print anything except the one in viewDidLoad?

Was it helpful?

Solution

You are forgetting to assign the delegate property of the login method. You need

self.loginView.delegate = self;

or else the delegate methods will never be called

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top