FBSDKAccessToken currentAccessToken在登录后没有被更新

编程入门 行业动态 更新时间:2024-10-27 17:18:55
本文介绍了FBSDKAccessToken currentAccessToken在登录后没有被更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我实施了一个完美的Facebook登录按钮。然而,在用户成功登录到Facebook并返回到应用程序之后, [FBSDKAccessToken currentAccessToken] 返回 NO 。我添加了一个观察者,看看我想要的代码是否在返回到应用程序后运行:

I implemented a Facebook login button which works perfectly fine. However, after user successfully logs in into Facebook and goes back to the app, [FBSDKAccessToken currentAccessToken] returns NO. I added an observer to see if the code I want is running after returning back to the app:

-(void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkLogIn)name :UIApplicationWillEnterForegroundNotification object:nil]; } -(void)checkLogIn { NSLog(@"IN CHECK LOG IN"); if ([FBSDKAccessToken currentAccessToken]) { NSLog(@"Access Token Activated"); } }

之后退回登录后该应用程序正在调用 checkLogIn 方法,但 [FBSDKAccessToken currentAccessToken] 仍返回 NO 。 但是,当我按下iPhone上的主页按钮后,它会更改为YES,然后返回到应用程序。

And after Log In when I return to the app the checkLogIn method is being called but [FBSDKAccessToken currentAccessToken] still returns NO. However, it changes to YES after I press home button on iPhone and go back to the app.

如何立即更新,所以我可以向用户显示另一个视图控制器?

How can it be updated immediately, so I can show user another view controller?

更新: 我找到了在回到应用程序后执行正确的代码的方式。关键是使用 FBSDKAccessTokenDidChangeNotification 是通知中心。所以最终的结果将是这样的:

UPDATE: I found out the way to execute proper code after getting back to the app. The key is to use FBSDKAccessTokenDidChangeNotification is Notification Center. So final result will be like this:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkLogIn) name: FBSDKAccessTokenDidChangeNotification object:nil];

该方式令牌将被更新,它将工作。

That way token will be updated and it will work.

推荐答案

请检查您的appDelegate类并实现FB SDK所需的所有方法。我附加的屏幕截图相同。

Please check your appDelegate class and implement all the required methods of FB SDK. I am attaching a screenshot for the same.

更多推荐

FBSDKAccessToken currentAccessToken在登录后没有被更新

本文发布于:2023-10-24 03:02:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522752.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:FBSDKAccessToken   currentAccessToken

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!