Parse provides simple Facebook login where it saves Access Token and limited user info. Inside your viewcontroller where you have implemented PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate delegates just call Facebook request as mentioned here:-
This is the delegate method where you can make a call to Facebook Request.
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user
Here is the complete code:-
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user{
BOOL isLinkedToFacebook = [PFFacebookUtils isLinkedWithUser:user]; // this line of code gives you login type of user
if (isLinkedToFacebook) {
NSMutableDictionary* params = [NSMutableDictionary dictionary];
[params setValue:@"id,name,email" forKey:@"fields"];
[FBRequestConnection startWithGraphPath:@"me" parameters:params HTTPMethod:nil completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSDictionary *FBuser = (NSDictionary *) result;
// small, normal, large, square
NSString *userImageURL = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=normal", [FBuser valueForKey:@"id"]];
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc]initWithDictionary:FBuser];
[responseDict setValue:userImageURL forKey:@"profileUrl"];
NSLog(@"Facebook User info is -> %@", responseDict);
}
}];
}
}
For more facebook info you can add facebook fields in params dictionary.
Happy Coding!!!
0 Comment(s)