2014-07-22 41 views
2

當我這樣做:FBLoginView沒有得到用戶的電子郵件

- (void) viewDidLoad { 
    [_fbLoginView setReadPermissions:@[@"public_profile", @"email"]]; 
    [_fbLoginView setDelegate:self]; 
} 

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView 
          user:(id<FBGraphUser>)user { 
    self.profilePictureView.profileID = user.id; 
    self.nameLabel.text = user.name; 
} 

我只是得到:

(lldb) po user 
{ 
    "first_name" = Name; 
    gender = female; 
    id = 1459547723244130; 
    "last_name" = Surname; 
    link = "https://www.facebook.com/app_scoped_user_id/1459547723244130/"; 
    locale = "en_US"; 
    name = "Name Surname"; 
    timezone = 1; 
    "updated_time" = "2014-06-30T08:07:59+0000"; 
    verified = 1; 
} 

即使當我通知應用程序需要我的電子郵件地址。

如何使用FBLoginView從Facebook獲取用戶電子郵件?

+1

Graph Explorer是否顯示您的電子郵件地址:https://developers.facebook.com/tools/explorer?method=GET&path=me%3Ffields%3Did%2Cname%2Cemail&version=v2.0如果不是,請看一看在你的Facebook個人資料,並檢查電子郵件地址是否結束'@ facebook.com' – Tobi

+0

問題是圖形API不顯示我的電子郵件地址!問題是我的FB測試帳戶沒有確認電子郵件地址,所以沒有發送。 – squixy

+0

那麼,當您的測試帳戶沒有確認的電子郵件,那麼這是行不通的。正如文檔中所述:'如果沒有有效的電子郵件地址可用,則不會返回此字段 – Tobi

回答

1

對於檢查權限點擊Here

enter image description here

viewController.h

@interface ViewController : UIViewController<FBLoginViewDelegate> 

viewController.m

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    FBLoginView *loginView = [[FBLoginView alloc] init]; 
    loginView.center = self.view.center; 
    loginView.readPermissions = @[@"public_profile", @"email", @"user_friends"]; 
    [loginView setDelegate:self]; 
    [self.view addSubview:loginView]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 

後成功登錄稱爲波紋管的委託方法

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

self.profilePictureView.profileID = user.id; 
    self.nameLabel.text = user.name; 

} 
相關問題