gpt4 book ai didi

ios - FB 用户 emailID 未获取

转载 作者:行者123 更新时间:2023-11-29 03:35:28 26 4
gpt4 key购买 nike

我无法从 Facebook 用户检索电子邮件 ID。我正在获取电子邮件的许可并记录以进行验证,因为它正在工作。但它不起作用。我不确定我去了哪里错了。挣扎了很长时间。任何人都可以帮助我。以下是我的代码。提前致谢。

-(IBAction)btnClicked{
// Initialize a session object
FBSession *session = [[FBSession alloc] init];
// Set the active session
[FBSession setActiveSession:session];
// Open the session
[session openWithBehavior:FBSessionLoginBehaviorWithFallbackToWebView
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// Respond to session state changes,
// ex: updating the view
if ([session isOpen]) {
// Session is open
NSArray *permissions = [NSArray arrayWithObjects:@"email", nil];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:NO
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {

[self sessionStateChanged:session state:state error:error];
}];
NSLog(@"Session is open");
[self populateDetails];

} else {
// Session is closed
NSLog(@"Session is closed");
}
}];
}
-(void)populateDetails{
if (FBSession.activeSession.isOpen) {

[[FBRequest requestForMe]startWithCompletionHandler:^(FBRequestConnection *connection,NSDictionary<FBGraphUser> *user, NSError *error) {
if(!error){

NSLog(@"email %@",[user objectForKey:@"email"]);
}
else
{
NSLog(@"NW Issue");
}
}
}

最佳答案

检查这个

if (FBSession.activeSession.isOpen) {
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (!error) {
self.nameLabel.text = user.name;
self.emailLabel.text = [user objectForKey:@"email"];
}
}];
}




NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", nil];
[FBSession sessionOpenWithPermissions:permissions completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
[self facebookSessionStateChanged:session state:state error:error];
}];

关于ios - FB 用户 emailID 未获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19241222/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com