2014-01-21 10 views
10

私のアプリケーションには3つのログイン方法があります。それらの1つはFacebookにログインしています。しかしFacebookのボタンをクリックすると、アクセス許可の問い合わせがあります。OKをクリックすると、エラーFBErrorCategoryUserCancelledが返されます。これはすべてのデバイスで起こるわけではなく、一部のデバイスで発生します。ここに私のコードです -私のアプリケーションでfacebookでログイン中にエラーFBErrorCategoryUserCancelledを常に返す

if ([[FBSession activeSession]isOpen]) { 
    /* 
    * if the current session has no publish permission we need to reauthorize 
    */ 
    if ([[[FBSession activeSession]permissions]indexOfObject:@"publish_actions"] == NSNotFound) { 

     [[FBSession activeSession] requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"] defaultAudience:FBSessionDefaultAudienceFriends 
               completionHandler:^(FBSession *session,NSError *error){ 

                [ProgressHUD dismiss]; 
                self.view.userInteractionEnabled = YES; 

               }]; 

    }else{ 

     [self fetchUserDetails]; 
    } 

}else{ 
    /* 
    * open a new session with publish permission 
    */ 
    [FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"] 
             defaultAudience:FBSessionDefaultAudienceOnlyMe 
              allowLoginUI:YES 
            completionHandler:^(FBSession *session, FBSessionState status, NSError *error) { 
             if (!error && status == FBSessionStateOpen) { 

              [self fetchUserDetails]; 

             }else{ 

              NSLog(@"error"); 

              if ([FBErrorUtility shouldNotifyUserForError:error]) { 
               alertTitle = @"Facebook Error"; 
               alertMessage = [FBErrorUtility userMessageForError:error]; 

               // This code will handle session closures that happen outside of the app 
               // You can take a look at our error handling guide to know more about it 
               // https://developers.facebook.com/docs/ios/errors 
              } else if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryAuthenticationReopenSession) { 
               alertTitle = @"Session Error"; 
               alertMessage = @"Your current session is no longer valid. Please log in again."; 

               // If the user has cancelled a login, we will do nothing. 
               // You can also choose to show the user a message if cancelling login will result in 
               // the user not being able to complete a task they had initiated in your app 
               // (like accessing FB-stored information or posting to Facebook) 

              } else if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryUserCancelled) { 
               NSLog(@"user cancelled login"); 

               alertTitle = @"Facebook Error"; 
               alertMessage = @"System login cancelled"; 

               // For simplicity, this sample handles other errors with a generic message 
               // You can checkout our error handling guide for more detailed information 
               // https://developers.facebook.com/docs/ios/errors 
              } else { 
               alertTitle = @"Something went wrong"; 
               alertMessage = @"Please try again later."; 
               NSLog(@"Unexpected error:%@", error); 
              } 

               [[[UIAlertView alloc] initWithTitle:alertTitle 
                      message:alertMessage 
                      delegate:nil 
                    cancelButtonTitle:@"OK" 
                    otherButtonTitles:nil] show]; 

              [ProgressHUD dismiss]; 
              self.view.userInteractionEnabled = YES; 

             } 
            }]; 
} 

私は助けていただければ幸いです。ありがとうございます。

答えて

0

私の場合は、Facebookブックアプリのサンドボックスモードがまだオンになっていたため、FBErrorCategoryUserCancelledがアプリの管理者/開発者/テスター以外の誰かのために発生していました。 、Facebookでサンドボックスモードをオフにし、それは「あなたが一般の人々に、このアプリとそのすべてのライブ機能が利用できるようにしたいですか?」と言う https://developers.facebook.com/apps/YOUR_FACEBOOK_APP_ID/review-status/

見に行く、それがYESであることを作るために

。 (このオプションにアクセスするには、連絡先電子メールを挿入する必要があります)。

また、まだアプリを公開したくない場合は、テスターをアプリの管理者/開発者/テスターに​​招待してください。あなたが招待を受け入れる前に、招待を受け入れる必要があります。

+0

ありがとうございました。しかし私はすでにそれをYESにしました。別の方法がありますか? – Smita

関連する問題