Facebook的API快速当前用户是零

我有一个Facebook的API的问题。 login和成功解开用户令牌后,我有一个用户configuration文件的问题:它是零。

func updateLoginStatus() { if let _ = AccessToken.current { let currentUser = UserProfile.current userName.text = currentUser?.fullName userPictureView = UserProfile.PictureView(frame: blankUserImage.frame, profile: currentUser) userPictureView!.clipsToBounds = true userPictureView!.layer.cornerRadius = userPictureView!.bounds.width/2 popUpView.addSubview(userPictureView!) isLogged = true updateLabels() } else { isLogged = false userPictureView?.removeFromSuperview() updateLabels() } } 

即使我尝试通过使用let userProfile = UserProfile(userId: (AccessToken.current?.userId)!)来获取configuration文件手册,它也会在所有参数中都为零,但它已经初始化了用户。 有趣的是,与该UserProfile.current它具有用户照片。 它可能是什么? 如何通过其他方法获取完整的用户名?

这个问题也在Android中发生。 获得访问令牌后,您应该加载configuration文件(在android中监听configuration文件更改)。 我写了一个示例,并在swift 3,Facebook iOS SDK 4.21.0中进行了testing。 那么你可以得到更新的用户。

 if let _ = FBSDKAccessToken.current() { if let currentUser = FBSDKProfile.current() { print("current user got: \(currentUser)") } else { print("current user not got") FBSDKProfile.loadCurrentProfile(completion: { profile, error in if let updatedUser = profile { print("finally got user: \(updatedUser)") } else { print("current user still not got") } }) } }