I am new to iPhone programming.Using below code i am login into Facebook and fetching data.But here problem is if click on the Loginwithfacebook button Facebook dialog box o
If you are willing to, you can also do it with Parse :
- (IBAction)facebookRegistrationButtonPressed {
// The permissions requested from the user
NSArray *permissionsArray = @[@"email", @"user_about_me", @"publish_actions", @"status_update", @"manage_pages", @"publish_stream"];
// Login PFUser using Facebook
[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
if (!user) {
if (!error) {
NSLog(@"Uh oh. The user cancelled the Facebook login.");
} else {
NSLog(@"Uh oh. An error occurred: %@", error);
}
} else if (user.isNew) {
NSLog(@"User with facebook signed up and logged in!");
[self processFacebookRequest];
} else {
NSLog(@"User with facebook logged in!");
[self processFacebookRequest];
}
}];
}
- (void)processFacebookRequest {
FBRequest *request = [FBRequest requestForMe];
// Send request to Facebook
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// result is a dictionary with the user's Facebook data
NSDictionary *userData = (NSDictionary *)result;
NSString * email = [result objectForKey:@"email"];
NSString *facebookID = userData[@"id"];
NSLog(@"facebookID = %@", facebookID);
} else {
NSLog(@"error : %@", error.localizedDescription);
}
}];
}