fbDidLogin never called (facebook-ios-sdk)

前端 未结 10 810
花落未央
花落未央 2020-12-20 05:09

I\'m using a pop up Facebook dialog for the user login and the publishing of a post on his/her stream

NSMutableDictionary* params = [NSMutableDictionary dict         


        
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-20 05:56

    You only have to implement that method within your App Delegate as this...

        - (void)fbDidLogin {
        NSLog(@"DID LOGIN!");
    
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:[[self facebook] accessToken] forKey:@"FBAccessTokenKey"];
        [defaults setObject:[[self facebook] expirationDate] forKey:@"FBExpirationDateKey"];
        [defaults synchronize];
    
    }
    

    The mistake your are making is that you are implementing this method in your Custom View.

    EDIT:

    The above code works perfect, but if you want to get the control on your custom viewcontroller you can maintain that code on your appDelegate and add this code on your CustomViewController:

         delegate= (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
        [delegate facebook].sessionDelegate=self;
    

    So, you will able to override fbDidLogin within your CustomViewController, don't forget add the FBSessionDelegate on your CustomViewController.h (Header).

    Kind Regards.

提交回复
热议问题