我正在通過facebook在ios應用程序中進行登錄集成,其中在應用程序啓動期間向用戶顯示警報,以及何時用戶單擊「確定」按鈕警告視圖,然後FB登錄對話框顯示給用戶。問題是當我點擊主頁按鈕並重新啓動應用程序以顯示警報時,然後單擊確定後不顯示用戶Facebook登錄對話框。我使用了Facebook ios sdk 3.0和xcode 4.5 gm。 *有趣的是,當我殺從背景的每一件事工作正常的應用程序。*以下是在應用程序代碼都完成下水爲Facebook黑色屏幕出現在Facebook身份驗證後,facebook對話框未顯示
if (!self.session.isOpen)
{
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"user_likes",
@"read_stream",@"publish_stream",@"email",
nil];
self.session = [[FBSession alloc] initWithPermissions:permissions];
if (self.session.state == FBSessionStateCreatedTokenLoaded)
{
// even though we had a cached token, we need to login to make the session usable
[self.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
}];
}
}
這就是我所說的方法時,對警報的OK按鈕用戶點擊查看
-(IBAction) facebookLogin
{
if (self.session.isOpen)
{
[self.session closeAndClearTokenInformation];
}
else
{
if (self.session.state != FBSessionStateCreated) {
// Create a new, logged out session.
self.session = [[FBSession alloc] init];
}
[self.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
if (error) {
NSLog(@"dex is %@",error.description);
}
}];
}
}