问题描述
我无法弄清楚如何将用户登录到我的应用程序。 [FBSDKAccessToken currentAccessToken]
为零,所以我打电话:
[[FBSDKLoginManager alloc] init] logInWithPublishPermissions:@ [@publish_actions] handler:...];
根据包含的示例项目。这将切换到Facebook应用程序,但消息说您已经授权应用名称。我点击确定,然后返回到应用程序,但 grantedPermissions
和 rejectPermissions
都是
对于结果, isCancelled
是 YES
。 [FBSDKAccessToken currentAccessToken]
仍然是 nil
。
不知道我应该如何获得 currentAccessToken
来填写。在我看来,对 logInWithPublishPermissions $ c $你应该尝试在AppDelegate中添加doFinishLaunchingWithOptions:
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>
请参阅:
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!