cocos2d-x iOS Sign in to Game Center 창이 안뜨는 현상

 iOS Game Center를 작업하다가 보면 위와 같이 사용자가 게임 센터에 로그인하지 않은 상태에서 게임을 실행하면

Sign in to Game Center

Use Existing Account
Create New Account
Cancel

 다이얼로그 창이 뜨게됩니다. 이때 Cancel을 누르고 나서 앱을 다시 실행하거나 하면 이 창이 아예 안 뜨는 증상이 있습니다.

else if ( error != nil )
{
       CCLOG("GameCenter Error %s %d", [[error domain] UTF8String], [error code]);
}

 이런식으로 로그를 찍었을 때

Cocos2d: GameCenter Error GKErrorDomain 2

 위와 같은 에러 로그가 남습니다. 애플 개발자 센터를 보면,

GKErrorCancelled = 2,
GKErrorCancelled


The requested operation was canceled.
Available in iOS 4.1 and later.


 이런 에러 코드입니다.

 구글링을 해보니 Cancel을 3번 했을 때 그 이후부터 다이얼로그가 안나온다고 하네요. 이는 애플 개발자 센터에도 없는 내용이라고 합니다. 뭐 예전 글들이라 지금은 업데이트 되었을 수도 있겠죠. 해결방법은 사용자에게 메세지를 띄워 게임센터 전용 앱에서 직접 로그인을 하도록 유도하는 것이겠죠.

 개발자가 직접 메세지를 안 띄워줘도 3번째 Cancel일 때는 알아서 뜨게 됩니다.

Game Center Disabled

Sign in with the Game Center application to enable.

 이런 창이 뜨죠. 친절하게 게임 센터 앱으로 로그인을 해서 활성화를 하라고 하네요. iOS 버전마다 다이얼로그가 조금 다를 듯합니다. 저는 일단 5.1이구요. 6.x에서는 Disable할꺼냐고 물어보는데 여기서 Disable하면 다음 게임 실행시부터는 다이얼로그가 뜨지 않습니다.

 문제는 이 후 실행부터 입니다. 게임 센터 앱에서 로그인을 안한 사용자가 게임을 실행해서 게임 센터 버튼을 누르는데 작동이 안된다라고 생각할 수 있습니다.


[localPlayer authenticateWithCompletionHandler:^(NSError* error)
         {
             CCLOG("GameCenter Result authenticateLocalPlayer");
             if( localPlayer.isAuthenticated )
             {
                 CCLOG("GameCenter LocalPlayer alias - %s", [localPlayer.alias UTF8String]);
                 CCLOG("GameCenter LocalPlayer ID - %s", [localPlayer.playerID UTF8String]);
                 this->iLastErrorCode = 0;
             }
             else if ( error != nil )
             {
                 CCLOG("GameCenter Error %s %d", [[error domain] UTF8String], [error code]);
                 this->iLastErrorCode = error.code;
             }
         }];


 아무리 인증 요청을 해도 아무런 다이얼로그 창도 뜨지도 않습니다. GKErrorCancelled 에러 코드만 남죠. 이걸 활용해서 개발중인 App 내에서 특정 버튼을 눌렀을 때 예외 처리를 해야겠죠.

if( isAuthenticate() == false )
    {
        if( getLastErrorCode() == GKErrorCancelled )
            CCMessageBox("Sign in with Game Center application to enable", "Game Center" );
        
        return;
    }
 이런식으로요. 물론 에러가 떨어졌을 때 바로 메세지 박스 출력해도 되겠지만요.


 참고
http://www.flashfellow.com/the-requested-operation-has-been-cancelled-gamecenter-error/2011/06
http://stackoverflow.com/questions/4576032/ios-development-strange-problem-with-authenticating-game-center-user

댓글

이 블로그의 인기 게시물

'xxx.exe' 프로그램을 시작할 수 없습니다. 지정된 파일을 찾을 수 없습니다.

goorm IDE에서 node.js 프로젝트로 Hello World Simple Server 만들어 띄워보기

애드센스 수익을 웨스턴 유니온으로 수표대신 현금으로 지급 받아보자.