无法在Facebook ios SDK中获取电子邮件ID登录的人 [英] Unable to get Email Id Of logged person in Facebook ios SDK

查看:90
本文介绍了无法在Facebook ios SDK中获取电子邮件ID登录的人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Facebook的应用程序上从Facebook获取用户数据(公开资料,电子邮件)。在实现登录过程之后,我可以获取用户的个人头像姓,名字和URL,但电子邮件我得到的是null我已经通过获得公开的个人资料和Emial.的权限,但我没有收到该人的电子邮件。

I am working on a Facebook IOS app to fetch user data(Public Profile,Email) from the Facebook.After implementing login process i am able to fetch first name,last name and url for profile picture of the User but the email i am getting is null. i have passed the permission for getting public Profile and Emial.but i am not getting Email Of the person.

我正在使用facebook SDK for ios V4.0.1

I am using facebook SDK for ios V4.0.1

这是我的代码

        [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
                                     parameters:@{@"fields": @"first_name, last_name, picture, email"}]
                              startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {                    
NSString *firstName = [NSString stringWithFormat:@"%@",[result objectForKey:@"first_name"]];

NSString *lastName = [NSString stringWithFormat:@"%@",[result objectForKey:@"last_name"]];
NSString *email = [NSString stringWithFormat:@"%@",[result objectForKey:@"email"]];
NSString *picurl = [NSString stringWithFormat:@"%@",[result objectForKey:@"picture"]];

 NSLog(@"email is %@", [result objectForKey:@"email"]);

 NSLog(@"picture is %@", [result objectForKey:@"picture"]);
 }
 else{
 NSLog(@"%@", [error localizedDescription]);
}
 }];

我得到以下输出:

email is (null)
picture is {
    data =     {
        "is_silhouette" = 0;
        url = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/p50x50 **************_************_n.jpg?oh=ed5fd60c770cb5f34424b3fcfb4ca174&oe=559F472D&__gda__=1437970763_989a264cf7ec16f5d51b0a58b7e7f609";
    };
}

为什么我没有收到用户的电子邮件地址

why i am not getting Email Address of the User

推荐答案

记录时。您必须要求用户发送电子邮件,否则您将收到电子邮件(null)。

While logging. You must ask user permission for email or else you would get email as (null).

不会提取电子邮件ID

FBSDKLoginButton *loginView = [[FBSDKLoginButton alloc] init];
 loginView.readPermissions =  @[@"public_profile"];

如果您使用上述权限登录,那么您将无法获取电子邮件标识,它将永远返回(null)。

IF you login with above permission then you would not be able to get email id it will always be return (null).

将通过公开个人资料获取电子邮件ID

FBSDKLoginButton *loginView = [[FBSDKLoginButton alloc] init];
loginView.readPermissions =  @[@"email"];

我们的应用程序在成功登录后会自动获取public_profile权限,但没有收到电子邮件。

Our app gets public_profile permission automatically upon any successful login but it does not get email.

同样适用于自定义登录。

Same goes for custom login as well.

请参阅: https://developers.facebook.com/docs/facebook-login/ios/v2.3#login-apicalls

这篇关于无法在Facebook ios SDK中获取电子邮件ID登录的人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆