Why does this method never called? who can help me to review my code, i am a green hand.
here is my *.h file
@interface LoginViewController : UIViewController <FBSessionDelegate,FBRequestDelegate,FBDialogDelegate> {
Facebook *facebook;
IBOutlet UITextField *_txt;
NSString *facebookUserID;
I want to get the faceboo user ID,So i called the API ‘[facebook requestWithGraphPath:@”me” andDelegate:self];’
- (void) fbDidLogin
{
NSLog(@"[LOGIN] Used did login");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
// User has logged in to Facebook, now get their userId from Facebook
[facebook requestWithGraphPath:@"me" andDelegate:self];
}
I know below method will get the user ID,but it never called.
- (void)request:(FBRequest *)request didLoad:(id)result
{
NSLog(@"Inside didLoad");
if ([result isKindOfClass:[NSArray class]])
{
result = [result objectAtIndex:0];
}
// When we ask for user infor this will happen.
if ([result isKindOfClass:[NSDictionary class]])
{
//NSDictionary *hash = result;
NSLog(@"Name: %@", [result objectForKey:@"name"]);
self.facebookUserID = [result objectForKey:@"id"];
NSLog(@"ID: %@", [result objectForKey:@"id"]);
}
}
You need to implement the openURL or handleOpenURL (the latter is prior to ios 4.2). It needs to be implemented in your app delegate, not your view controller.
See fbDidLogin not called. openURL will result in fbDidLogin getting called