I am trying to use the doc's firebase provides. Maybe I converted it wrong from obj. C. Please see below.
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
}
})
}
This is the obj. 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");
}
}];
}
This is the error
Cannot convert value of type '(FBSDKLoginMangerLoginResult, NSError?) -> Void' to expected argument type 'FBSDKLoginMangerRequestTokenHandler!'
// use this method in login with fb butn -(void)loginWithFbBtnMethode { 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
{
}
}
}];
}
}
//user details getting method