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") } }) } }
- FBSDKLoginManager logInWithReadPermissions:fromViewController:处理程序:完成不调用应用程序第一次运行
- ABMultiValueGetCount – kABPersonSocialProfileProperty总是返回0? 我怎样才能从地址簿获得Facebook的细节?
- 如何使用Facebook iOS SDK 4.x“重新申请”电子邮件许可?
- 与iOS应用程序共享与facebook的超链接
- Facebook ShareDialog总是返回,完成时取消
- NSJSONSerialization与Facebook iOS SDK 3.5崩溃
- 如何检测用户何时从Facebook上删除应用程序
- xcode中的Facebook SDK Singleton
- iOS:将Facebook Likebutton添加到本机iPhone应用程序