Appdelegate.m ファイルに次のコードを書き込むことで、fb セッションを確認できます。
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
[self performSelector:@selector(checkingFBsession) withObject:nil afterDelay:1.0];
}
-(void)checkingFBsession
{
self.successfb= [[self facebook] isSessionValid];
NSString *str = [[NSUserDefaults standardUserDefaults]objectForKey:@"access_token"];
[str retain];
NSLog(@"%@",str);
if (self.successfb || str) {
NSLog(@"session is valid !");
accessToken=self.facebook.accessToken;
[[NSUserDefaults standardUserDefaults]setObject:accessToken forKey:@"access_token"];
[[NSUserDefaults standardUserDefaults]synchronize];
accessToken = nil;
accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"access_token"];
[accessToken retain];
NSLog(@"at%@",accessToken);
NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request addPostValue:[[NSUserDefaults standardUserDefaults]objectForKey:@"access_token"] forKey:@"access_token"];
// [request addPostValue:@"123456" forKey:@"telephone"];
[request startAsynchronous];
}
}