我正在尝试使用文档的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");
}
}];
}
这是错误
无法将类型为"(FBSDKLoginMarkerLoginResult,NSError?)->Void"的值转换为预期的参数类型"FBSDKLOGinMarkerRequestTokenHandler!"
//使用fb-butn登录时使用此方法-(void)使用FbBtnMethod登录{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
{
}
}
}];
}
}
//获取方法的用户详细信息
对不起,我只是在看,我只是强行打开了FBSDKLoginMarkerLoginResult不确定这是否是一个好的做法,但它现在有效。
在7.3.1中,当使用fb或gmail并在开发人员中创建证书时,我也遇到了很多错误,所以尝试降级到7.2.1,这在任何地方都可以。