FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:在app首次运行时未调用完成 [英] FBSDKLoginManager logInWithReadPermissions: fromViewController: handler: completion not called on app first run

查看:1041
本文介绍了FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:在app首次运行时未调用完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个支持Facebook登录的应用程序,出于某种原因 FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:在安装后第一次运行我的应用程序时未调用。如果我只是杀了我的应用程序(即使没有尝试登录Facebook或做任何事情:尝试首先打开登录或不改变任何东西)并再次打开它,它完美地工作。

I have a Facebook login-enabled app and for some reason FBSDKLoginManager logInWithReadPermissions: fromViewController: handler: is not called on the very first run of my app after installation. If I just kill my app (even without trying to login to Facebook or do anything: trying to login on first open or not doesn't change anything) and open it again, it works perfectly.

为什么?

(我检查过传递给方法的视图控制器不是nil并且是当前的视图控制器)

(I've checked the view controller passed to the method is not nil and is the current view controller)

这是我的登录代码:

+(void)loginWithFacebookWithCompletion:(ULCompletion)completion{
    [[[FBSDKLoginManager alloc] init] logInWithReadPermissions:FACEBOOK_READ_PERMISSIONS fromViewController:[ULMasterViewController instance] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        if(result.token){
          ...
        }
[...]

其余的无关紧要因为根本没有调用完成块(甚至没有错误)。我有 FACEBOOK_READ_PERMISSIONS 硬编码:

The rest is irrelevant as the completion block is not called at all (not even with an error). I've got the FACEBOOK_READ_PERMISSIONS hardcoded:

#define FACEBOOK_READ_PERMISSIONS(@ [@ user_friends,@user_birthday,@email,@user_photos])

最后, [ULMasterViewController实例] 是有效的(不是nil,并且在层次结构中有其视图(否则它会抱怨视图不在hiearchy中,也尝试过)。

And finally, [ULMasterViewController instance] is valid (not nil, and has its view in hierarchy (otherwise it complains about view not being in hiearchy, also tried that)).

推荐答案

这适用于我的情况。

1.在界面中创建FBloginManager的实例。

1 .Create instance of FBloginManager in interface.

FBSDKLoginManager *manager

2.ViewDidLoad中的初始化。

2 .Initialise in ViewDidLoad.

manager = [FBSDKLoginManager new]

3.最后使用FBLoginManager的这个实例调用登录权限方法。

3 .And finally call login permission method using this instace of FBLoginManager.

这篇关于FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:在app首次运行时未调用完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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