2014-02-05 52 views
2

我已經使用facebook新的sdk獲取用戶信息。但是當我在設備上運行時,它給了我這樣的錯誤:「操作無法完成(com.facebook.sdk錯誤2.)」。而且我還通過設備設置在Facebook上簽名。iPhone中的Facebook sdk錯誤

回答

0

這工作對我來說:

轉到您的iPhone的設置應用程序。
打開你的Facebook設置

向下滾動到你的應用程序,並確保您的應用允許Facebook的 互動。


這可能發生在任何設備上,因此在你的應用程序,你必須確保正確處理此錯誤。我想你會給用戶反饋爲什麼使用Facebook登錄失敗,並要求用戶檢查他們的設備上的Facebook設置。

- (void)facebookSessionStateChanged:(FBSession *)session state:(FBSessionState)state error:(NSError *)error 
{ 
    switch (state) { 
     case FBSessionStateOpen: 
      // handle successful login here 
     case FBSessionStateClosed: 
     case FBSessionStateClosedLoginFailed: 
      [FBSession.activeSession closeAndClearTokenInformation]; 

      if (error) { 
       // handle error here, for example by showing an alert to the user 
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Could not login with Facebook" 
                   message:@"Facebook login failed. Please check your Facebook settings on your phone." 
                   delegate:nil 
                 cancelButtonTitle:@"OK" 
                otherButtonTitles:nil]; 
       [alert show]; 
      } 
      break; 
     default: 
      break; 
    } 
+0

從哪裏我必須寫這個代碼。 – Hitendra

+0

把它放在.m文件中的任何地方... –

0

首先檢查你的包標識符,並確保它是一樣的,你有https://developers.facebook.com/,而應用程序註冊後,你輸入。

+0

是的,我在Facebook和應用程序中使用了相同的標識符 – Hitendra