2013-04-15 1 views
9

iOS6 소셜 프레임 워크를 기반으로 앱을 만들고 있습니다. 제대로 작동했지만 몇 달 후 이상한 오류가 발생했습니다. 있는 NSDictionary에 수입 JSON 페이스 북 데이터의페이스 북의 액세스 토큰 만료 됨 - iOS 6 소셜 프레임 워크

내 NSLog는 다음과 같습니다

profiledictionary: { 
error = { 
code = 190; 
"error_subcode" = 463; 
message = "Error validating access token: Session has expired at unix time 1365610034. The current unix time is 1366032783."; 
type = OAuthException; 

내 액세스 토큰이 만료 보이지만하지 iOS6의 사회 프레임 워크 자동으로 알아서하기로?

내가 해결할 수있는 방법과 그와 같은 미래의 문제를 피하는 방법에 대한 아이디어가 있으니 실제 앱을 게시 할 수 있습니까?

답변

13

는 마지막으로 ... 그것을 가지고있는 NSDictionary 객체 (이 경우 토큰 만료에 대한 페이스 북의 오류) "오류"라는 이름이 있다면 확인하는 것이 필요했다, 그래서 방법을 호출하는 경우 ACAccount 갱신 :

if([self.profileDictionary objectForKey:@"error"]!=nil) 
{ 
[self attemptRenewCredentials]; 
} 

-(void)attemptRenewCredentials{ 
    [self.accountStore renewCredentialsForAccount:(ACAccount *)self.facebookAccount completion:^(ACAccountCredentialRenewResult renewResult, NSError *error){ 
     if(!error) 
     { 
      switch (renewResult) { 
       case ACAccountCredentialRenewResultRenewed: 
        NSLog(@"Good to go"); 
        [self getFacebookAccount]; 
        break; 
       case ACAccountCredentialRenewResultRejected: 
        NSLog(@"User declined permission"); 
        break; 
       case ACAccountCredentialRenewResultFailed: 
        NSLog(@"non-user-initiated cancel, you may attempt to retry"); 
        break; 
       default: 
        break; 
      } 

     } 
     else{ 
      //handle error 
      NSLog(@"error from renew credentials%@",error); 
     } 
    }]; 
} 
+1

나는 오늘 당신의 질문과 대답을지지했다. 너는 내 피부를 구했다! 지구상 어디에서 찾았습니까? 정말 고마워. 도움이 될 – Douglas

+0

다행;) –

관련 문제