Shahriyar Ahmed
Shahriyar Ahmed

Reputation: 94

Facebook SDK not giving user Email id

Facebook sdk not returning user email_id in json object. Tried so many methods but found no solution. Things which were required for facebook implementation

1-change other linker flag to (-ObjC)

2-make a url Scheme

3-add facebook_id and name in project pList

4-using a UIView in storyboard and assigning FBLoginView class to it.

5-allocating and initing and giving read permissions.

here's the code for giving permission :

_fbLoginVIew =[[FBLoginView alloc] init];

_fbLoginVIew.delegate=self;

_fbLoginVIew.readPermissions= @[@"public_profile", @"email", @"user_friends"];

and delegate method that returns the user information :

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user
{

    defaults=[NSUserDefaults standardUserDefaults];

    [defaults setValue:user.name forKey:@"name"];

    [defaults setValue:[user objectforkey:@"email"] forkey:@"email"];

    [defaults synchronize];

}

but after implementing all these things and searching for solution i am still stuck on my problem. please help in solving this problem.

Thanks

Upvotes: 1

Views: 339

Answers (2)

mohitdream4u
mohitdream4u

Reputation: 166

This problem is due to user restrict his/her email to shown up in timeline

so you can't access for that when you only allowing permission for this

Upvotes: 1

Fahri Azimov
Fahri Azimov

Reputation: 11770

Actually it's very simple. You should just give proper readPermissions when initializing the FBLoginView like:

FBLoginView *loginView = 
    [[FBLoginView alloc] initWithReadPermissions:
        @[@"public_profile", @"email", @"user_friends"]];

or, if you are creating login view on interface builder:

self.loginView.readPermissions = @[@"public_profile", @"email", @"user_friends"];

in viewDidLoad of your view controller.

For future help on Facebook, please read this

Good Luck!

Upvotes: 0

Related Questions