我是新來的swift,並試圖學習如何使用SDK從Facebook讀取數據。Facebook SDK獲取用戶圖片
下面是我添加的代碼:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if (FBSDKAccessToken.currentAccessToken() != nil)
{
// User is already logged in, do work such as go to next view controller.
println("User is already logged in")
}
else
{
let loginView : FBSDKLoginButton = FBSDKLoginButton()
self.view.addSubview(loginView)
FBSDKProfile.enableUpdatesOnAccessTokenChange(true)
loginView.center = self.view.center
loginView.readPermissions = ["public_profile", "email", "user_friends", "user_photos"]
loginView.delegate = self
}
}
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
println("User Logged In")
if ((error) != nil)
{
// Process error
}
else if result.isCancelled {
// Handle cancellations
}
else {
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if result.grantedPermissions.contains("email")
{
println("\(result.grantedPermissions)")
// Do work
}
}
}
當我運行我的應用程序的Xcode模擬器提供了以下警告: 「一些下面沒有被批准的Facebook的權限」,這讓我的選擇提交審查。是否因爲我試圖獲得「user_photos」的讀取權限?我正在嘗試閱讀用戶公開個人資料以及所有公共圖片。請讓我知道我的下一步要實現上述目標應該是什麼。
您必須先將您的應用程序提交給Facebook,然後才能使用此功能。 – atulkhatri