In order to connect to facebook in my ios app i\'m using FBLoginVIew from Facebook SDK for iOS.
It shows a nice FB Login Button, but I want to use my own image and t
change text in the Facebook resource bundle en.lproj Localizable.strings ... i suppose it works
When I'm writing this, Facebook has already released version 3.0 of their SDK for iOS.
ozba's answer is sort of working but, from my opinion, it shouldn't be used.
My solution is really simple. In Facebook's downloaded folder, FacebookSDK, you have a folder named Samples. There, you must look in the SessionLoginSample. You can see that they have an ordinary Round Rect Button, which, through the ViewController that owns it, that has the FBLoginViewDelegate, it can change text depending on the FBSession state. Trust me, it's really simple.
According to latest Facebook Login For iOS Version 2.3.
You can use the following code snippet to login via any any Custom UIButton.
- (void)loginWithFacebook:(id) sender {
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"public_profile",@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Process error
} else if (result.isCancelled) {
// Handle cancellations
} else {
// Login Successful here
// Check for any particular permissions you asked
if ([result.grantedPermissions containsObject:@"email"]) {
// Do work
}
}
}];
}
Here is the link: https://developers.facebook.com/docs/facebook-login/ios/v2.3#login-apicalls
Please, read the README file in Facebook SDK. You have to add the Row - FacebookBundleName in info.plist and put it a name for your bundle. Then, add a bundle to your project with this name and put into folders named "lang.lproj": for example: en.lproj - it.lproj - fr.lproj - es.lproj.... Into this folders you have to add the Localizable.strings file, then you can localize a lot of phrases, like:
"FBLV:LogOutButton" = "Log Out";
"FBLV:LogInButton" = "Log In";
"FBLV:LoggedInAs" = "Logged in as: %@";
"FBLV:LoggedInUsingFacebook" = "Logged in using Facebook";
"FBLV:LogOutAction" = "Log Out";
"FBLV:CancelAction" = "Cancel";
Hope it helps you!
Since the latest version 4.X Facebook SDK ,
The Custom Login is made easier, Use FBSDKLoginManager
In My case I created a good looking Button in Photoshop and simply put it on top of faceBook button. (I know that Apple doesn't advice to put view on button But iterating on the subviews doesn't look nice to me). Hard to understand why such company as FB didn't provide simple way to do it.
UIImageView *fbImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"facebookButton.png"]];
CGRect newFrame = fBButtonFrame;
newFrame.origin.x = 0; newFrame.origin.y = 0;
[fbImageView setFrame:newFrame];
[fbImageView setUserInteractionEnabled:NO];
FBLoginView *loginView = [[FBLoginView alloc] init];
[loginView setFrame:fBButtonFrame];
[loginView addSubview:fbImageView];
[self.view addSubview:loginView];