2012-11-08 3 views
2

친구 벽에 링크를 공유하기 위해 iOS 앱에 Facebook sdk 3.1을 사용했습니다. 나는 페이스 북은 게시 할 수 없습니다 때문에 추가 오류 "작업을 완료 할 수 없습니다"com.facebook.sdk 오류 2를 반환하고 계정의 일부iOS 로그인 문제의 Facebook SDK 3.1

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

myAppDelegate = self; 

AudioViewController *viewController = [[AudioViewController alloc] init]; 
self.navController = [[UINavigationController alloc] initWithRootViewController:viewController]; 
[self.navController setNavigationBarHidden:YES]; 
viewController = nil; 


self.window.rootViewController = self.navController; 
[self.window makeKeyAndVisible]; 

if (![self openSessionWithAllowLoginUI:NO]) { 
    // No? Display the login page. 
    [self performSelector:@selector(login) withObject:nil afterDelay:0.5]; 
} 

return YES; 
} 

- (void)login{ 
[self openSessionWithAllowLoginUI:YES]; 
} 

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI { 
return [FBSession openActiveSessionWithReadPermissions:nil 
              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: { 
     DLOG(@"session open"); 
    } 
     break; 
    case FBSessionStateClosed: { 

     DLOG(@"session closed"); 


     [FBSession.activeSession closeAndClearTokenInformation]; 


    } 
     break; 
    case FBSessionStateClosedLoginFailed: { 


     DLOG(@"session Failed"); 


    } 
     break; 
    default: 
     break; 
} 

[[NSNotificationCenter defaultCenter] postNotificationName:WVSessionStateChangedNotification 
                object:session]; 

if (error) { 
    DLOG(@"error = %@",error); 
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Error: %@", 
                   [AppDelegate FBErrorCodeDescription:error.code]] 
                 message:error.localizedDescription 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
    [alertView show]; 
} 
} 

아래로 아래 applicationDidFinishLaunching 메소드에서 새 세션을 열려고 페이스 북에서.

여기에 뭔가 잘못하고 있습니까? 도움이 될 것입니다.

+0

로그인 중에이 오류가 발생합니까? –

+0

는 u는 당신이 오프 주제 –

+0

페이스 북의 로그인되어보기에서 페이스 북의 메소드를 추가 않았지만, API를 통해 친구의 벽에 게시가 사용되지 않으며 2 월 6 일 이후에 사용할 수 없습니다, 2013 –

답변

1

나는 동일한 문제가 있었고 openSessionWithAllowLoginUI : TRUE를 통해 NSTimer를 호출하여 해결했습니다. 그 이유는

if (![self openSessionWithAllowLoginUI:NO]) { 
    // No? Display the login page. 
    [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(login) userInfo:nil repeats:NO]; 
} 

, 우리는 다른 스레드에서 FB 세션을 얻을 수없는, 하나 우리는 메인 쓰레드 또는 다른 (배경) 스레드를 사용합니다. 귀하의 코드에서 세션 가용성을 확인할 때 주 스레드를 사용하고 로그인 할 때는 performSelector 기능을 통해 다른 스레드를 사용합니다.

희망, 도움이 될 것입니다.

감사합니다.

+0

감사합니다, 그것은 작동하는 솔루션을 @woodenlabs .. !!! – Dishant