あなたのAppDelegateでメソッドを変更します
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
NSString *urlString = [url absoluteString];
if ([urlString hasPrefix:@"fb://xxxxxxxxxxxx"]) {
[FBSession.activeSession handleOpenURL:url];
returnValue = YES;
}
return returnValue;
}
また
ただし、これはIOS 6ではトリガーされないことに注意してください。ios6では、次のメソッドがトリガーされます。
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [FBSession.activeSession handleOpenURL:url];
}
ログインまたは切断によりセッションの状態が変化した場合、FBsessionは次のメソッドを呼び出し、ケースを処理する必要があります。
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState)state
error:(NSError *)error {
switch (state) {
case FBSessionStateOpen: {
//update permissionsArrat
[self retrieveUSerPermissions];
if (!needstoReopenOldSession) {
//First User information
[self getUserInformation:nil];
}
NSNotification *authorizationNotification = [NSNotification notificationWithName:facebookAuthorizationNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotification:authorizationNotification];
}
case FBSessionStateClosed: {
break;
}
case FBSessionStateClosedLoginFailed: {
[FBSession.activeSession closeAndClearTokenInformation];
break;
}
default:
break;
}
if (error) {
NSNotification *authorizationNotification = [NSNotification notificationWithName:faceBookErrorOccuredNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotification:authorizationNotification];
}
}