i am NewBie with Facebook login in iOS for Facebook login i make one FbView and I write a code for Fetch email and Name of User then it was Give me User name as i want but Email Address are getting as Null Please Give me Solution for this.
Here my Code like as
- (void)viewDidLoad
{
[super viewDidLoad];
self.fbView.readPermissions = @[@"public_profile", @"email", @"user_friends"];
self.fbView.delegate=self;
if (FBSession.activeSession.state == FBSessionStateOpen
|| FBSession.activeSession.state == FBSessionStateOpenTokenExtended)
{
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (!error) {
NSLog(@"Email %@",[user objectForKey:@"email"]);
NSLog(@"User Name %@",user.username);
}
}];
}
And also i write a method For fetch Email like as
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user
{
NSLog(@"User Name %@",user.name);
NSLog(@"Email %@",[user objectForKey:@"email"]);
}
But it was Give me NULL
Value Please Give me Solution for it.
As per your second method, try like this,
-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user
{
NSString *userDetails = [NSString stringWithFormat:@"%@",user];
NSString *fb_userEmail = [user objectForKey:@"email"];
}
userDetails
will return you all the user details in a single string object. fb_userEmail
will return users email id.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.