FBSDKLoginManager token with email address

I am trying to register in my iOS application via facebook SDK

I use FBSDKLoginManager to login to facebook, from which I get the AccessToken, which I checked.

https://graph.facebook.com/me?access_token=tokenstring

I received the name and ID in response, but I need to get an email and to register on Qiuckblox .

I downloaded the q-municate application (based on quickblox.com) from github and checked the token.
I have the same tokens, but the result is different. How so? Maybe I need to set some settings in facebook?

    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logOut];

[login logInWithReadPermissions:@[@"email", @"public_profile", @"user_friends"]
             fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {

    if (error) {
        // Process error
        NSLog(@"%@",error.localizedDescription);
    }
    else if (result.isCancelled) {
        // Handle cancellations
    }
    else {
        NSLog(@"%@",result.token.tokenString);

        if ([result.grantedPermissions containsObject:@"email"]) {
            NSLog(@"Granted all permission");
            if ([FBSDKAccessToken currentAccessToken]) {
                [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, link, first_name, last_name, picture.type(large), email, birthday, bio ,location ,friends ,hometown , friendlists"}] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                    if (!error) {
                        NSLog(@"%@",result);
                    }
                }];
            }
        } else {
            NSLog(@"Not granted");
        }
    }
}];

here are the screenshots:

http://screencast.com/t/9KNK9HIb

http://screencast.com/t/BDsfYVZi

+4
2

:

https://graph.facebook.com/v2.5/me?fields=id,name,email,gender&access_token=<access_token>

0
    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, first_name, last_name, picture.type(large), email"}]

     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error)
         {
             NSLog(@"results:%@",result);

             NSString *email = [result objectForKey:@"email"];
          }

0

Source: https://habr.com/ru/post/1620800/


All Articles