在你的 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 中不会触发。在 ios 6 中,将触发以下方法。
- (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];
}
}