My APP's Facebook login wont work and I cant seem to figure out why.
In my .h
file i added #import "FBConnect.h"
and @interface MyImageViewControllerViewController : UIViewController<UINavigationControllerDelegate, FBSessionDelegate, FBRequestDelegate>
and i have my Facebook *facebook;
iVar.
I implement all of the methods that are required (As said in the Tutorial) this is how I did it. ( I wont post everything coz I think it'll be pointless)
-(BOOL)facebooking{
facebook = [[Facebook alloc] initWithAppId:FB_APP_ID andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
[facebook authorize:nil];
}
return YES;
}
And
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
UIAlertView *a = [[UIAlertView alloc] initWithTitle:@"Token" message:[facebook accessToken] delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
[a show];
}
Now when I call the facebooking
method it starts up the safari on my Facebook APP
auth page, i press Okay
it goes back to my iOS
app but for some reason the fbDidLogin
isn't called. neither is fbDidNotLogin
. Is there a place that i need to point to them somehow?
Thank you.
Have you implementing this methode ?
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [facebook handleOpenURL:url];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.