My facebook access token is null despite the fact that the button shows that I\'m logged in. Anyone know why this would be?
From RootViewController.m
You could build the logic around waiting for FBSDKAccessTokenDidChangeNotification
notification in your ViewController's code.
In your AppDelegate.m
:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
// add observer BEFORE FBSDKApplicationDelegate's - application:didFinishLaunchingWithOptions: returns
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(fbAccessTokenDidChange:)
name:FBSDKAccessTokenDidChangeNotification
object:nil];
return [[FBSDKApplicationDelegate sharedInstance] application: application didFinishLaunchingWithOptions: launchOptions];
}
- (void)fbAccessTokenDidChange:(NSNotification*)notification
{
if ([notification.name isEqualToString:FBSDKAccessTokenDidChangeNotification]) {
if ([FBSDKAccessToken currentAccessToken]) {
// token is ready to be used in the app at this point
}
}
}