gpt4 book ai didi

facebook-ios-sdk - 尽管通过 FBSDKLoginButton 登录,但 ios Facebook SDK v4.x 访问 token 为 null

转载 作者:行者123 更新时间:2023-12-04 01:51:16 26 4
gpt4 key购买 nike

尽管按钮显示我已登录,但我的 facebook 访问 token 为空。有人知道为什么会这样吗?

从 RootViewController.m

- (void)viewDidLoad {
[super viewDidLoad];

self->login_button = [[FBSDKLoginButton alloc] init];
self->login_button.center = self.view.center;
[self.view addSubview:self->login_button];

FBSDKAccessToken* access_token =[FBSDKAccessToken currentAccessToken];
NSLog(@"Access Token, %@",access_token);
}

来自 ApplicationDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

[self.window setRootViewController:[[RootViewController alloc] init]];

[self.window makeKeyAndVisible];

[self.window setBackgroundColor:[UIColor purpleColor]];
[FBSDKLoginButton class];
return [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
}

我的 -ObjC 链接器标志也已设置

最佳答案

需要首先调用 FBSDKApplicationDelegate 来解析缓存的 token 。由于您正在立即设置根 View Controller ,因此会在 FBSDKApplicationDelegate 之前调用您的 viewDidLoad。相反,您可以将 FBSDKApplicationDelegate 向上移动:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[FBSDKLoginButton class];
BOOL r = [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

[self.window setRootViewController:[[RootViewController alloc] init]];

[self.window makeKeyAndVisible];

[self.window setBackgroundColor:[UIColor purpleColor]];


return r;
}

关于facebook-ios-sdk - 尽管通过 FBSDKLoginButton 登录,但 ios Facebook SDK v4.x 访问 token 为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29434392/

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