2012-09-27 53 views
1

我正在通過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); 
     } 
    }]; 

    } 
} 

回答

0

按照這個文件在Facebook developer

它解釋瞭如何處理登錄和註銷功能。按照它的說法執行,完美地工作。而且你也可以使用最新的3.1 sdk。

0

這是一個古老的問題,但無論如何。 當我沒有更新我的AppDelegate時,我有同樣的行爲。在迅速它應該看起來像這樣:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { 
    return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) 
} 

func applicationWillResignActive(application: UIApplication) { 

    FBSDKAppEvents.activateApp() 
} 

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
    // Some code was here 

    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) 
} 
相關問題