Facebook SDK iOS use user data -
how user name, user image, user email when login: didcompletewithresult: err: method called in facebook sdk ios version 4.4. want set these values properties.
- (void)loginbutton:(fbsdkloginbutton *)loginbutton didcompletewithresult:(fbsdkloginmanagerloginresult *)result error:(nserror *)error { if (error) { } else if (result.iscancelled) { } else { //i want user info here , set values properties. self.username = self.userimage = self.useremail = } }
if know other solutions, please tell me it.
try this
fbsdkloginmanager *login = [[fbsdkloginmanager alloc] init]; [login loginwithreadpermissions:@[@"email",@"user_photos"] handler:^(fbsdkloginmanagerloginresult *result, nserror *error) { if ([result.grantedpermissions containsobject:@"email"]) { [self fetchdata] } }];
and in fetchdata method
- (void)fetchdata { [[[fbsdkgraphrequest alloc] initwithgraphpath:@"me" parameters:nil] startwithcompletionhandler:^(fbsdkgraphrequestconnection *connection, id result, nserror *error) { if (!error) { dlog(@"fetched user:%@", result); self.userfirstname = [result objectforkey:@"first_name"]; self.userlastname = [result objectforkey:@"last_name"]; self.useremail = [result objectforkey:@"email"]; nsstring *facebookid = [result objectforkey:@"id"]; self.userprofileimage = [nsstring stringwithformat:@"https://graph.facebook.com/%@/picture?type=large", facebookid]; dlog(@"url=%@",self.userprofileimage); } }]; }
Comments
Post a Comment