0
我一直很煩惱這一整天。我已經遵循了所有文檔,並閱讀了關於堆棧溢出的所有問題 - 但我無法使用最新的FB SDK獲取該死的電子郵件地址。Facebook的SDK沒有得到電子郵件
我的代碼是:
ImpLog(@"Signupweh...");
if(fbSession == nil) {
fbSession = [[FBSession alloc] initWithAppID:@"XXXX"
permissions:@[@"email", @"user_birthday", @"publish_stream", @"offline_access"]
defaultAudience:FBSessionDefaultAudienceEveryone
urlSchemeSuffix:@"xxxx"
tokenCacheStrategy:nil];
ImpLog(@"Setting active session");
[FBSession setActiveSession:fbSession];
}
[FBSession setDefaultAppID:@"xxxx"];
[FBSession openActiveSessionWithReadPermissions:@[@"email", @"user_birthday", @"publish_stream", @"offline_access"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
ImpLog(@"Contents: %@ | Error: %@ | Denied: %@\n",session.description, error.description, session.declinedPermissions);
if(status == FBSessionStateOpen || FBSessionStateCreated) {
ImpLog(@"Open session!");
} else {
ImpLog(@"Not open");
}
FBRequest* loginRequest = [FBRequest requestForMe];
[loginRequest startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser>* result, NSError *error) {
NSDictionary* uData = (NSDictionary*)loginRequest;
ImpLog(@"Got data:\n%@",result);
ImpLog(@"Got me (%@) with mail: %@", result.name, result[@"email"]);
}];
}];
我得到
它讓我(我的名字)跟郵件:(空)。
同樣,當我打印結果(NSDictionary *)的內容時,就沒有電子郵件。正如你所看到的,我要求電子郵件許可。 user_birthday權限也很好。
任何想法?