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

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

问题描述

我无法弄清楚如何将用户登录到我的应用程序。 [FBSDKAccessToken currentAccessToken] 为零,所以我打电话:

  [[FBSDKLoginManager alloc] init] logInWithPublishPermissions:@ [@publish_actions] handler:...]; 

根据包含的示例项目。这将切换到Facebook应用程序,但消息说您已经授权应用名称。我点击确定,然后返回到应用程序,但 grantedPermissions rejectPermissions 都是 对于结果, isCancelled YES [FBSDKAccessToken currentAccessToken] 仍然是 nil



不知道我应该如何获得 currentAccessToken 来填写。在我看来,对 logInWithPublishPermissions

  return [[FBSDKApplicationDelegate sharedInstance]应用程序:应用程序
didFinishLaunchingWithOptions:launchOptions];

这将得到你 [FBSDKAccessToken currentAccessToken] 当用户登录时。



   - (BOOL)应用程序:(UIApplication *)应用程序openURL:(NSURL *)url sourceApplication :( NSString *)sourceApplication注释:(id)注释{
return [[FBSDKApplicationDelegate sharedInstance]应用程序:应用程序
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}

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

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


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:…];

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.

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.

解决方案

You should try adding in your AppDelegate didFinishLaunchingWithOptions :

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

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

and

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

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

Refer to : https://developers.facebook.com/docs/ios/getting-started#startcoding

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

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