I am using the latest Facebook iOS SDK 3.0
I need a help in in the login process:
First I declare this property in AppDelegate.h:
@property (nonatomic, strong) FBSession *session;
and in ViewController class I get this to use it in the code as this:
AppDelegate *delegate = [[UIApplication sharedApplication]delegate];
[delegate.session someproperty];
I also have this method in ViewController that get called from viewDidLoad:
-(void)login
{
AppDelegate *delegate = [[UIApplication sharedApplication]delegate];
[delegate.session accessToken];
NSLog(@"%d",delegate.session.isOpen);
if (!delegate.session.isOpen)
{
delegate.session = [[FBSession alloc] init];
if (delegate.session.state == FBSessionStateCreatedTokenLoaded)
{
[delegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error)
{
NSLog(@"%d", delegate.session.isOpen); // First Line //////////////////
}];
}
NSLog(@"%@", delegate.session.description); // Second Line //////////////////
}
}
After the facebook app get authorized the firs NSLog print zero, and the second NSLog indicate that the session state is FBSessionStateCreated not FBSessionStateOpen?
this is the output for the second NSLog:
2012-08-16 18:37:24.327 Facebook3[2418:f803] <FBSession: 0x6890ff0, state: FBSessionStateCreated, loginHandler: 0x0, appID: 193716877424306, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x6890f20>, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:()>
What I am missing here.
Note : in the app setting at https://developers.facebook.com I configure the app as this: 1- Configured for iOS SSO: Enabled 2- iOS Native Deep Linking: Enabled 3- iOS Bundle ID : com.mycompany.appname