我已经实现了 FB 登录,但从未收到回调...在 .plist 中,我确实添加了 FacebookAppID 和 FacebookDisplayName
这是我的代码。它是我问题中的所有相关代码
-(IBAction)btnLoginWithFBClick:(id)sender {
_session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];
[_session resume];
if (![_session isConnected]) {
_loginDialog = nil;
_loginDialog = [[FBLoginDialog alloc] init];
_loginDialog.delegate = self;
[_loginDialog show];
}
else {
NSLog(@"logado");
- (void)dialogDidSucceed:(FBDialog *)dialog {
if ([dialog isMemberOfClass:[FBLoginDialog class]]) {
NSLog(@"[FBLoginDialog::dialogDidSucceed] just did succeed");
} else if ([dialog isMemberOfClass:[FBPermissionDialog class]]) {
NSLog(@"[FBPermissionDialog::dialogDidSucceed] update user status");
// [self facebookUpdateUserStatus];
}
}
- (void)session:(FBSession*)session didLogin:(FBUID)uid {
[self getFacebookName];
[_loginDialog setHidden:YES];
}
- (void)session:(FBSession*)session willLogout:(FBUID)uid {
//_logoutButton.hidden = YES;
_facebookName = nil;
}
- (void)getFacebookName {
NSString* fql = [NSString stringWithFormat:
@"select uid,name, email, sex, pic from user where uid == %lld", _session.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
[[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
}
- (void)dialogCompleteWithUrl:(NSURL *)url {
if (![[url absoluteString] isEqualToString:@"fbconnect://success#="]) { // your msg
NSLog(@"ae");
}
}
- (void)request:(FBRequest*)request didLoad:(id)result {
if ([request.method isEqualToString:@"facebook.fql.query"]) {
NSArray* users = result;
NSDictionary* user = [users objectAtIndex:0];
NSLog(@"Usuario facebook: %@", user);
NSString *identifier = [user objectForKey:@"uid"];
NSString *name = [user objectForKey:@"name"];
NSString *email = [user objectForKey:@"email"];
NSString *sex = [user objectForKey:@"sex"];
}
}
我已经在 Facebook 应用程序中设置了 Apple Id、Bundle id 等,我确实在谷歌上寻找解决方案,但没有任何效果......知道吗?