i need to use the facebook api:
in the appdelegate.m I have this code:
// Initialize Facebook
facebook = [[Facebook alloc] initWithAppId:@"MY_TOKEN" andDelegate:self];
// Check and retrieve authorization information
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
after, in another view I have this:
AppDelegate* dlg = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSArray *permissions = [[NSArray alloc] initWithObjects:@"offline_access", nil];
if (![[dlg facebook] isSessionValid]) {
[[dlg facebook] authorize:permissions];
}
and works fine: call safari with the authorization to use my app, I click Ok to authorize and my app is called again… my app visualize the last view before the authorize, but the event
- (void)fbDidLogin
{
NSLog(@"fbDidLogin");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
}
in AppDelegate.m (my appdelegate have FBSessionDelegate) is not fired (also the other events of FBSessionDelegate like fbDidNotLogin are not fired…
where is my error?
thanks in advance
I think you forgot about this two methods and perhaps forgot to add your Facebook app id to URL types in info file. for more detail
// Pre 4.2 support
// For 4.2+ support