1
我已經整合Facebook登錄我app.But林無法獲取用戶數據,即不能進入用戶的詳細信息環路 在Appdelegate.m從Facebook登錄xcode獲取用戶數據?
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"email",
@"user_likes",
nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
}
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
switch (state) {
case FBSessionStateOpen:
if (!error) {
// We have a valid session
NSLog(@"User session found");
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *user,
NSError *error) {
if (!error) {
NSLog(@"%@",user);
}}];
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed:
[[FBSession activeSession] closeAndClearTokenInformation];
break;
default:
break;
}
if (error) {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
}
但是,我發現用戶的NSLog NSLog的的(@」 %@「,用戶)即使打開會話也會打印bcoz NSLog(@」找到用戶會話「)打印 是這樣嗎?
您能告訴我們您是如何開啓會議的嗎? (大概類似'[FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:]' –
我編輯了我的代碼,可以看看並糾正我的錯誤 – Sindhia
如何在沒有記錄任何內容的情況下知道會話已打開? –