2015-09-17 35 views
0

我設置登錄行爲FBSDKLoginBehaviorSystemAccount並嘗試登錄,然後我的應用程序從Facebook的設置獲取詳細信息,然後它給我在這個類別的成功響應FBSDKLoginManagerLoginResult對象,其中包括標記字符串和用戶ID 。但是,如果在Facebook的設置中沒有添加賬戶,那麼這將用戶移動到Facebook應用程序,並且在認證之後移回應用程序,但是這返回nil令牌並且沒有其他細節。我不知道爲什麼會發生這種情況,我在後面添加了一些代碼。我希望每個人都明白我的問題,那些在iOS開發中從Facebook執行登錄的人,而有人仍然沒有,然後好心告訴我會添加更多的細節。登錄從Facebook應用程序返回零回覆iOS的iOS令牌

if (![self isCurrentAccessTokenValid]) { 
     self.FBLoginManager.loginBehavior = FBSDKLoginBehaviorSystemAccount; 
     [self.FBLoginManager logInWithReadPermissions:@[ @"email",@"public_profile",@"user_friends"] handler: 
     ^(FBSDKLoginManagerLoginResult *result, NSError *error) { 
      block(result, error); 
      NSLog(@"%@",result.token.tokenString); 
      NSLog(@"%@",result.token.userID); 
      //NSLog(@"%hhd",result.isCancelled); 

      [FBSDKAccessToken setCurrentAccessToken:result.token]; 

     }]; 
    } else { 
     [self fetchUserProfile:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
      block(result, error); 
     }]; 
    } 

尋找有用的迴應。謝謝。

+0

您檢查'result',但你必須在'error'值? – Larme

回答

0

試試這個

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; 
    [login 
    logInWithReadPermissions: @[@"public_profile", @"email", @"user_friends"] 
    handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { 
     if (error) { 
      NSLog(@"Process error"); 
     } else if (result.isCancelled) { 
      NSLog(@"Cancelled"); 
     } else { 
      NSLog(@"Logged in");    
     } 
    }]; 
相關問題