FBSDKLoginMangerLoginResult, NSError Swift 7.3.1

FBSDKLoginMangerLoginResult, NSError Swift 7.3.1

我正在尝试使用文档的 firebase 提供。也许我把它从 obj 转换错了。 C、请看下文

override func viewDidLoad() {
    super.viewDidLoad()

    facebookLoginBtn.addTarget(self, action: #selector(self.facebookLoginBtnPress), forControlEvents: .TouchUpInside)
}

    // MARK Facebook btn pressed
    @IBAction func facebookLoginBtnPress(sender: AnyObject) {

    let login = FBSDKLoginManager()

    login.logInWithReadPermissions(["email"], fromViewController: self, handler: {(facebookResult: FBSDKLoginManagerLoginResult, facebookError: NSError?) -> Void in

        if facebookError != nil {

        } else if facebookResult.isCancelled {
            let accessToken = FBSDKAccessToken.currentAccessToken().tokenString
        }
    })

}

这是对象。 C

// Handle clicks on the button
[myLoginButton 
 addTarget:self 
 action:@selector(loginButtonClicked) forControlEvents:UIControlEventTouchUpInside];

// Once the button is clicked, show the login dialog
-(void)loginButtonClicked
{
 FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
 [login
   logInWithReadPermissions: @[@"public_profile"]
      fromViewController:self
                 handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    if (error) { 
       NSLog(@"Process error");
    } else if (result.isCancelled) {
       NSLog(@"Cancelled");
    } else {
       NSLog(@"Logged in");
    }
  }];
}

这是错误

无法将类型“(FBSDKLoginMangerLoginResult, NSError?) -> Void”的值转换为预期的参数类型'FBSDKLoginMangerRequestTokenHandler!'

抱歉,我只是在看,我只是强行打开了 FBSDKLoginMangerLoginResult 的包装,不确定这是否是好的做法,但现在可以使用了。

当我使用 fb 或 gmail 并在开发者证书中创建时,我在 7.3.1 中也遇到了很多错误,因此请尝试降级到 7.2.1,这对任何地方都没有问题。

//使用此方法登录fb butn -(void)loginWithFbBtnMethod { FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];

if ([FBSDKAccessToken currentAccessToken])
{
    NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);
    [self fetchUserInfo];
}
else
{
    [login logInWithReadPermissions:@[@"email"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
     {
         if (error)
         {
             [self.view makeToast:@"Login process error" duration:2.0 position:@"center"];
             NSLog(@"Login process error");
         }
         else if (result.isCancelled)
         {
             [self.view makeToast:@"User cancelled login" duration:2.0 position:@"center"];
             NSLog(@"User cancelled login");
         }
         else
         {
             NSLog(@"Login Success");
             if ([result.grantedPermissions containsObject:@"email"])
             {
                 NSLog(@"result is:%@",result);
                [self fetchUserInfo];
             }
             else
             {
             }
         }
     }];
}

}

//用户详情获取方法