2015-01-26 97 views
0

我正在使用Parse查找需要用戶通過Facebook登錄的iOS應用程序。現在,當用戶登錄一個對象在用戶中創建,但只顯示他們的Facebook ID。我怎樣才能改變這一點,以便Parse將收集用戶的姓名,電子郵件,身份證,性別等......?謝謝!解析Facebook用戶獲取用戶類的信息

編輯: 這是我在ViewController中觸發登錄的當前代碼。

let permissions = ["public_profile", "email", "user_friends"] 

    PFFacebookUtils.logInWithPermissions(permissions, { 
     (user: PFUser!, error: NSError!) -> Void in 
     if user == nil { 
      NSLog("Uh oh. The user cancelled the Facebook login.") 
     } else if user.isNew { 
      NSLog("User signed up and logged in through Facebook!") 
     } else { 
      NSLog("User logged in through Facebook!") 
     } 
    }) 
} 

由於「user_profile」包括第一和最後一個名字,我怎麼解析這個保存在用戶類?

回答

0

你可以嘗試類似的東西來獲取用戶的基本信息。爲了獲得更多信息,您必須設置正確的permissions

[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
    if (error) { 
     NSLog(@"!!! ERROR !!! = %@", [error localizedDescription]); 
    } else { 
     self.email = result[@"email"]; 
     self.firstname = result[@"first_name"]; 
     self.lastname = result[@"last_name"]; 
     self.facebookId = result[@"id"]; 
     if (result[@"birtday"]) { 
      self.birthday = result[@"birthday"]; 
     } 
    } 
}];