Hi, you can watch one controller. You can refer to this tutorial to access Facebook. integrate login with fax book
Important steps
Step 1: create the Facebook application in the developer application and set up the info.plist file
Step 2: Login Action Code
- (IBAction)signInWithFacebookClicked:(id)sender {
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile",@"email",@"user_friends"]
allowLoginUI:YES
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
[FBRequestConnection startWithGraphPath:@"me"
parameters:@{@"fields": @"first_name,last_name, email"}
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"FBresponse: =>%@",result);
}
else{
NSLog(@"%@", [error localizedDescription]);
}
}];
}];
}
Step 3: Callback
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[FBAppCall handleDidBecomeActive];
}
Step 4: Then process the FBSession block as per your requirement. hope this helps.
source
share