FBSDKLoginManager logInWithPublishPermissions 总是返回 isCancelled=YES [英] FBSDKLoginManager logInWithPublishPermissions always returns isCancelled=YES

查看:30
本文介绍了FBSDKLoginManager logInWithPublishPermissions 总是返回 isCancelled=YES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚如何将用户登录到我的应用中.[FBSDKAccessToken currentAccessToken] 为零,所以我调用:

I am having trouble figuring out how to log a user into my app. [FBSDKAccessToken currentAccessToken] is nil, so I am calling:

[[[FBSDKLoginManager alloc] init] logInWithPublishPermissions:@[@"publish_actions"] handler:…];

根据包含的示例项目.这会切换到 Facebook 应用程序,但消息显示您已经授权应用程序名称.".我单击确定",它返回到应用程序中,但是 grantedPermissionsdeclinedPermissions 在结果上都是 nil,并且 isCancelledYES.[FBSDKAccessToken currentAccessToken] 仍然是 nil.

as per the included sample project. This switches to the Facebook app, but the message says "You have already authorized App Name.". I click OK and it goes back into the app, but grantedPermissions and declinedPermissions are both nil on the result, and isCancelled is YES. [FBSDKAccessToken currentAccessToken] is still nil.

我不知道应该如何填写 currentAccessToken.在我看来,对 logInWithPublishPermissions 的调用应该这样做,但它不是.

I can't figure out how I'm supposed to get currentAccessToken to be filled in. It seems to me the call to logInWithPublishPermissions should do that, but it isn't.

推荐答案

你应该尝试在你的 AppDelegate didFinishLaunchingWithOptions 中添加:

You should try adding in your AppDelegate didFinishLaunchingWithOptions :

return [[FBSDKApplicationDelegate sharedInstance] application:application
                                    didFinishLaunchingWithOptions:launchOptions];

当用户登录时,这会得到你 [FBSDKAccessToken currentAccessToken].

This would get u [FBSDKAccessToken currentAccessToken] when user is logged in.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
}

如果此方法不存在于 AppDelegate 中,则会导致取消状态.

If this method is not present into AppDelegate then it results into cancelled state.

参考:https://developers.facebook.com/docs/ios/getting-started#startcoding

这篇关于FBSDKLoginManager logInWithPublishPermissions 总是返回 isCancelled=YES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆