我已經將Facebook iOS SDK運行在我已經工作了幾個月的應用中。在這一點上,我主要使用SDK來實現SSO。iOS iOS facebook SDK:登錄已經過身份驗證
由於我已經開始使用iOS 6.0,我一直在看到一個問題,即「使用您的FB賬戶使用MY_APP登錄」模式阻止了我當前的視圖。
奇怪的是,用戶已經通過身份驗證,並明顯授權使用我的應用程序。事實證明,我可以得到用戶的電子郵件地址等。
注意到如果點擊「X」它將關閉並且一切正常(用戶通過認證/授權)也很重要。如果我登錄告訴我,它顯示「MY_APP已經授權」模式,我不能點擊「好」按鈕,但我可以點擊「X」,再次讓我回到我的視圖與用戶認證和授權。
在這裏你可以看到它:
爲了驗證我打電話的appdelegate
下面的方法:
[appDelegate openSessionWithAllowLoginUI:YES];
以下是我的appdelegate相關FB方法:
// FACEBOOK STUFF
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [NSArray arrayWithObjects: @"email", nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self sessionStateChanged:session state:status error:error];
}];
}
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState)state
error:(NSError *)error {
// FBSample logic
// Any time the session is closed, we want to display the login controller (the user
// cannot use the application unless they are logged in to Facebook). When the session
// is opened successfully, hide the login controller and show the main UI.
switch (state) {
case FBSessionStateOpen: {
FBCacheDescriptor *cacheDescriptor = [FBFriendPickerViewController cacheDescriptor];
[cacheDescriptor prefetchAndCacheForSession:session];
[self sendAuthenticationStatusChangedNotification];
}
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed:
// FBSample logic
// Once the user has logged in, we want them to be looking at the root view.
[FBSession.activeSession closeAndClearTokenInformation];
//[self showLoginView];
break;
default:
break;
}
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// FBSample logic
// We need to handle URLs by passing them to FBSession in order for SSO authentication
// to work.
return [FBSession.activeSession handleOpenURL:url];
}
編輯1
我注意到,這是在我的手機之一,但不是其他。沒有工作的手機安裝了舊版本的FB應用程序。更新FB應用程序停止了這個問題的發生。我仍然對修復感興趣,以避免其他人遇到同樣的問題。
EDIT 2
問題都消失了一點,但現在又回來了即使在安裝了新的Facebook應用程序。請幫忙!