gpt4 book ai didi

ios - FBSDKAccessToken currentAccessToken 登录后未更新

转载 作者:技术小花猫 更新时间:2023-10-29 11:00:41 24 4
gpt4 key购买 nike

我实现了一个 Facebook 登录按钮,效果非常好。但是,在用户成功登录 Facebook 并返回到应用后,[FBSDKAccessToken currentAccessToken] 返回 NO。我添加了一个观察者,以查看返回应用程序后我想要的代码是否正在运行:

-(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。

如何立即更新它,以便我可以向用户显示另一个 View Controller ?

更新:回到应用程序后,我找到了执行正确代码的方法。关键是使用FBSDKAccessTokenDidChangeNotification是Notification Center。所以最后的结果会是这样的:

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

这样 token 将被更新并且它会起作用。

最佳答案

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

enter image description here

关于ios - FBSDKAccessToken currentAccessToken 登录后未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30205396/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com