2012-12-15 2 views
1

나는 사용자 데이터가 Appdelegate.mxcode에서 페이스 북 로그인으로 사용자 데이터를 가져 오는 중입니까?

- (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을 (찾을 해달라고 얻을 내 app.But 임없는에서 페이스 북의 로그인을 통합 한 @ " % @ ", user) bcoz NSLog (@"User session found ")가 출력됩니다. Y가 맞습니까?

+0

세션을 어떻게 여는 지 보여줄 수 있습니까? (아마도'[FBSession openActiveSessionWithReadPermissions : allowLoginUI : completionHandler :]'와 같은 것일 것입니다. –

+0

내 코드를 수정했습니다. 제발 실수를 저 지르세요. – Sindhia

+0

아무 것도 기록되지 않으면 어떻게 세션이 열렸는지 어떻게 알 수 있습니까? –

답변

0

나는 한 시간 후에 로그인 한 후에 다시 블록에 들어올 수 없었던 동일한 문제를 겪었습니다. 나는 mysession의 인스턴스 대신에 mysession 클래스를 반환한다고 생각했습니다. 문제가 해결 될 수 있습니다.

- (BOOL)application:(UIApplication *)application 
      openURL:(NSURL *)url 
    sourceApplication:(NSString *)sourceApplication 
     annotation:(id)annotation { 

    return [mysession handleOpenURL:url]; 
} 
관련 문제