메타 데이터의 끝으로 건너뛰기
메타 데이터의 시작으로 이동

You are viewing an old version of this content. View the current version.

현재와 비교 View Version History

« 이전 버전 2 다음 »


초기화 및 상태변화 이벤트 처리


SDK 초기화

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Initialization and Status Change Event Processing SDK Example'.

using KakaoGame.API;

KGTApplication.InitSDK();

스타트 (Start) 하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Initialization and Status Change Event Processing SDK Example'.

using KakaoGame.API;

KGTApplication.Start((result) =>
{
    if (result.IsSuccess)
    {
        // Start 성공
        if (KGTPlayer.IsLoggedIn) 
        {
            // 자동 로그인 성공
            // 플랫폼에서 발급한 현재 Player의 ID
            string playerId = KGTPlayer.CurrentPlayer.PlayerId;
            // 플랫폼 액세스 토큰
            string accessToken = KGTPlayer.AccessToken;
            // 현재 IDP 인증 정보를 가져옴
            var idpProfile = KGTPlayer.CurrentPlayer.IdpProfile;
            // [TODO] 게임 서버 로그인 및 게임 화면으로 이동
        } 
        else 
        {
            // 자동 로그인 정보 없음, 로그인 API 호출
        }
    }
    else 
    {
        if (result.code == KGTResultCode.NetworkFailure ||
            result.code == KGTResultCode.ServerTimeout ||
            result.code == KGTResultCode.ServerConnectionFailed) 
        {
            // [TODO] 네트워크 에러가 발생한 경우에는 유저에게 네트워크 이슈로 스타트에 실패했음을 알리고 재시도
        } 
        else 
        {
            // [TODO] 유저에게 에러가 발생했음을 알림. 에러 원인 추적을 위해 에러코드도 포함된 문구이면 좋음.
        }
    }
});

Pause 하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Initialization and Status Change Event Processing SDK Example'.

using KakaoGame.API;
 
// appDelegate의 백그라운드 이동 함수에서 구현
// [주의] OnApplicationPause 구현합니다.
// [주의] OnApplicationFocus에서는 구현하지 않도록 합니다.
void OnApplicationPause(bool paused) {
    // 게임이 백그라운드로 이동되었을 때 실행해야 할 메소드
    // Pause API는 항상 성공을 반환합니다.
    // 따라서 게임에서 별도로 result를 체크하지 않으셔도 됩니다.
    if (paused)
    {
        KGTApplication.Pause((result) => {});
    }
}

Resume 하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Initialization and Status Change Event Processing SDK Example'.

using KakaoGame.API;
 
// appDelegate의 백그라운드 이동 함수에서 구현
// [주의] OnApplicationPause 구현합니다.
// [주의] OnApplicationFocus에서는 구현하지 않도록 합니다.
void OnApplicationPause(bool paused) {
    if (!paused) // 포그라운드로 이동한 상태
    {
        // 게임이 포그라운드로 이동되었을 때 실행해야 할 메소드
        KGTApplication.Resume((result) => 
        {
            if (result.IsSuccess) 
            {
                // [TODO] resume이 성공 한 경우 게임 화면을 재개합니다.
            } 
            else 
            {
                // [TODO] resume이 실패 한 경우 인증 실패 면 로그인 화면으로, 그외의 경우는 에러 팝업을 띄우고 재시도 여부를 확인합니다.
                if (result.code == KGTResultCode.AuthFailure ||
                    result.code == KGTResultCode.IdpAuthFailure) 
                {
                    // [TODO] 인증 실패의 경우 시작 화면으로 이동해서 다시 신규 로그인 flow를 수행합니다.
                } 
                else 
                {
                    // [TODO] 나머지 에러가 발생한 경우 경우 에러 안내 후 resume 을 재시도 합니다.
                }
            }
        });
    }
}

윈도우즈 환경에서 자동로그인 설정하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Initialization and Status Change Event Processing SDK Example'.

using KakaoGame.API;

// 자동로그인사용 유무를 세팅, 세팅하지 않으면 사용하지 않음 상태로 세팅
// 자동로그인사용설정으로 로그인이 성공하면 자동로그인정보가 생성됨
// 자동로그인정보가 존재하면 다음 KGTApplication의 start시에 자동로그인이 진행됨으로 자동로그인정보를 제거하려면 로그아웃을 진행해야함
bool useAutoLogin = true;
KGTApplication.UseAutoLogin = useAutoLogin;

로그인


매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Login SDK Example'.

기본 로그인 UI를 사용하지 않는 로그인하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Login SDK Example'.

using KakaoGame.API;

KGTIdpCode idpCode = KGTIdpCode.Kakao;

KGTPlayer.Login(idpCode, (result) =>
{
    if (result.IsSuccess) 
    {
        // 로그인 성공 처리.
        // 플랫폼에서 발급한 현재 Player의 ID
        string playerId = KGTPlayer.CurrentPlayer.PlayerId;
        // 플랫폼 액세스 토큰
        string accessToken = KGTPlayer.AccessToken;
        // 현재 IDP 인증 정보를 가져옴
        var idpProfile = KGTPlayer.CurrentPlayer.IdpProfile;
        // [TODO] 게임 서버 로그인 및 게임 화면으로 이동
    } 
    else 
    {
        // 로그인 실패 처리.
        if (result.code == KGTResultCode.NetworkFailure ||
            result.code == KGTResultCode.ServerTimeout ||
            result.code == KGTResultCode.ServerConnectionFailed) 
        {
            // [TODO] 네트워크 에러가 발생한 경우에는 로그인 재시도 요청 하여야 합니다.
        } 
        else if (result.code == KGTResultCode.Forbidden) 
        {
            // [TODO] CBT기간동안 허용된 유저외에는 인증이 불가능 할 수 있습니다. 유저에게 안내메시지 노출 이후, 확인 클릭시, 앱을 종료하도록 구현합니다.
        } 
        else if (result.code == KGTResultCode.UserCanceled) 
        {
            // [TODO] 사용자가 로그인 진행 중 취소한 상황이므로 로그인 화면을 유지 하여야 합니다.
        } 
        else 
        {
            // [TODO] 나머지 에러가 발생한 경우에는 에러 안내 후 로그인 재시도 요청 하여야 합니다.
            // 에러코드 및 로그 확인 후 원인 파악이 필요합니다.
        }
    });
});

런처를 통해서 로그인하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Login SDK Example'.

using KakaoGame.API;

// 런처를 통해서 전달 받은 bridgeToken
string bridgeToken = "";

KGTPlayer.LoginWithBridgeToken(bridgeToken, (result) =>
{
    if (result.IsSuccess) 
    {
        // 로그인 성공 처리.
        // 플랫폼에서 발급한 현재 Player의 ID
        string playerId = KGTPlayer.CurrentPlayer.PlayerId;
        // 플랫폼 액세스 토큰
        string accessToken = KGTPlayer.AccessToken;
        // 현재 IDP 인증 정보를 가져옴
        var idpProfile = KGTPlayer.CurrentPlayer.IdpProfile;
        // [TODO] 게임 서버 로그인 및 게임 화면으로 이동
    } 
    else 
    {
        // 로그인 실패 처리.
        if (result.code == KGTResultCode.NetworkFailure ||
            result.code == KGTResultCode.ServerTimeout ||
            result.code == KGTResultCode.ServerConnectionFailed) 
        {
            // [TODO] 네트워크 에러가 발생한 경우에는 로그인 재시도 요청 하여야 합니다.
        } 
        else if (result.code == KGTResultCode.Forbidden) 
        {
            // [TODO] CBT기간동안 허용된 유저외에는 인증이 불가능 할 수 있습니다. 유저에게 안내메시지 노출 이후, 확인 클릭시, 앱을 종료하도록 구현합니다.
        } 
        else if (result.code == KGTResultCode.UserCanceled) 
        {
            // [TODO] 사용자가 로그인 진행 중 취소한 상황이므로 로그인 화면을 유지 하여야 합니다.
        } 
        else 
        {
            // [TODO] 나머지 에러가 발생한 경우에는 에러 안내 후 로그인 재시도 요청 하여야 합니다.
            // 에러코드 및 로그 확인 후 원인 파악이 필요합니다.
        }
    });
});

로그아웃


매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Logout SDK Example'.

기본 로그아웃 UI를 사용하지 않는 로그아웃하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Logout SDK Example'.

using KakaoGame.API;

KGTPlayer.Logout(false, (result) =>
{
    if (result.IsSuccess) 
    {
        // 로그아웃 성공
        // [TODO] 시작 화면으로 돌아가기
    } 
    else 
    {
        // 로그아웃 실패
    }
});

탈퇴


  • 탈퇴 UI를 개발사에서 직접 구현하고 싶을 경우(탈퇴 UI를 사용하고 싶지 않은 경우)를 위해서, 탈퇴 API가 제공됩니다.

기본 탈퇴 UI를 사용하지 않는 탈퇴하기

기본 탈퇴 UI를 사용하지 않는 탈퇴하는 예제입니다.

using KakaoGame.API;

KGTPlayer.Unregister(false, (result) =>
{
    if (result.IsSuccess) 
    {
        // 탈퇴 성공
        // [TODO] 시작 화면으로 돌아가기
    } 
    else 
    {
        // 탈퇴 실패
    }
});

계정 연결


매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Account Linking SDK Example'.

기본 계정 연결 UI를 사용하지 않는 계정 연결하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Account Linking SDK Example'.

using KakaoGame.API;

KGTIdpCode idpCode = KGTIdpCode.Kakao;

KGTPlayer.Connect(idpCode, (result) =>
{
    if (result.IsSuccess) 
    {
        // 계정 연결 성공
    } 
    else if (result.code == KGTResultCode.NotAuthorized) 
    {
        // 현재 인증이 안되어 있는 경우
    }
    else if (result.code == KGTResultCode.InvalidState) 
    {
        // 이미 연결되어 있는 경우
    }
    else if (result.code == KGTResultCode.AlreadyUsedIDPAccount) 
    {
        // 이미 사용중인 IDP계정으로 연결을 시도한 경우
    }
    else 
    {
        // 그 밖의 에러
    }
});

프로필


내 정보 조회하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Profile SDK Example'.

using KakaoGame.API;

KGTPlayer player = KGTPlayer.CurrentPlayer;

내 IDP 정보 조회하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Profile SDK Example'.

using KakaoGame.API;

KGTIdpProfile idpProfile = KGTPlayer.CurrentPlayer.IdpProfile;

시스템 정보


언어 코드 가져오기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

string languageCode = KGTSystem.LanguageCode;

국가 코드 가져오기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

string countryCode = KGTSystem.CountryCode;

IP 기반 국가 코드 가져오기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

string geoCountryCode = KGTSystem.GeoCountryCode;

기기 아이디 가져오기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

string deviceId = KGTSystem.DeviceId;

기기 모델 가져오기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

string deviceModel = KGTSystem.DeviceModel;

OS 이름 가져오기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

string osName = KGTSystem.OsName;

네트워크 연결 여부 가져오기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

bool isNetworkConnected = KGTSystem.IsNetworkConnected;

연결된 네트워크 타입 가져오기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

string networkType = KGTSystem.NetworkType;

설정된 게임 언어 코드 가져오기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

string gameLanguageCode = KGTSystem.GameLanguageCode;

게임 언어 코드 설정하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_System Information SDK Example'.

using KakaoGame.API;

var languageCode = KGTLanguageCode.Device;
KGTSystem.SetGameLanguageCode(languageCode);

카카오 연동 기능


카카오톡 게임 메시지 수신 여부 설정하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Kakao Integration Feature SDK Example'.

using KakaoGame.API;

KGTKakaoTalk.ShowSetting((result) => 
{
    if (result.IsSucces) 
    {
        // 카카오톡 게임 메시지 수신 여부 설정 성공
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우.
    }
    else 
    {
        // 카카오톡 게임 메시지 수신 여부 설정 실패
    }
});

카카오톡 프로필 조회하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Kakao Integration Feature SDK Example'.

using KakaoGame.API;

KGTKakaoTalk.TalkProfile((result) => 
{
    if (result.IsSucces) 
    {
        // 카카오톡 프로필 조회 성공
        KGTKakaoTalkProfile talkProfile = result.Content;
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우.
    }
    else 
    {
        // 카카오톡 프로필 조회 실패
    }
});

카카오톡 게임 친구 목록 조회하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Kakao Integration Feature SDK Example'.

using KakaoGame.API;

KGTKakaoTalk.Friends((result) => 
{
    if (result.IsSucces) 
    {
        var players = result.Content;
        // 카카오톡 게임 친구 목록 조회 성공.
        foreach(var player in players) {
            var kakaoProfile = (KGTKakaoProfile)player.IdpProfile; // 게임 메세지 전송시 사용
        }
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우.
    }
    else 
    {
        // 카카오톡 게임 메시지 수신 여부 설정 실패
    }
});

카카오톡 게임 메시지 보내기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Kakao Integration Feature SDK Example'.

using KakaoGame.API;

// Friends API를 통해
KGTKakaoFriendProfile kakaoProfile; // 카카오 프로필(KGTKakaoFriendProfile 객체)

// [TODO] 템플릿 Id 설정
string templateId;
  
// [TODO] 메시지 템플릿에 설정한 인자 설정
Dictionary<string, object> argumentDic = new Dictionary<string, object>();

KGTKakaoTalk.SendGameMessage(kakaoProfile, tempalteId, argumentDic, (result) => 
{
    if (result.IsSucces) 
    {
        // 카카오톡 채팅 메시지 보내기 성공.
    }
    else if (result.code == KGTResultCode.MessageSettingDisabled) 
    {
        // 받은이가 메시지 수신 거부를 설정한 경우
    }
    else if (result.code == KGTResultCode.ExceedDailyUsage) 
    {
        // 한명이 특정 앱에 대해 보낼 수 있는 하루 쿼터(받는 사람 관계없이) 초과시 발생
    }
    else if (result.code == KGTResultCode.ExceedMonthlyUsage) 
    {
        // 한명이 특정 앱에 대해 특정인에게 보낼 수 있는 한달 쿼터 초과시 발생
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우.
    }
    else 
    {
        // 카카오톡 채팅 메시지 보내기 실패.
    }
});

카카오톡 친구 초대 메시지 전송하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Kakao Integration Feature SDK Example'.

using KakaoGame.API;

// [TODO] 팝업창으로 띄울지 여부 설정
bool isSingle;

// [TODO] 팝업창으로 띄울지 여부 설정
bool isPopup;
  
// [TODO] 템플릿 Id 설정
string templateId;
  
// [TODO] 메시지 템플릿에 설정한 인자 설정
Dictionary<string, object> argumentDic = new Dictionary<string, object>();

KGTKakaoTalk.SendInviteMessage(isSingle, isPopup, tempalteId, argumentDic, (result) =>
{
    if (result.IsSucces) 
    {
        // 요청 성공
    }
    else
    {
        // 요청 실패
        if (result.code == KGTResultCode.MessageSettingDisabled)
        {
            // 받은이가 메시지 수신 거부를 설정한 경우.
        }
        else if (result.code == KGTResultCode.ExceedDailyUsage)
        {
            // 한명이 특정 앱에 대해 보낼 수 있는 하루 쿼터(받는 사람 관계없이) 초과시 발생.
        }
        else if (result.code == KGTResultCode.ExceedMonthlyUsage)
        {
            // 한명이 특정 앱에 대해 특정인에게 보낼 수 있는 한달 쿼터 초과시 발생.
        }
        else if (result.code == KGTResultCode.NotKakaoTalkUser)
        {
            // 로그인 한 유저가 '카카오톡' 유저가 아닙니다.
        }
        else
        {
            // 그 밖의 에러
        }
    }
});

카카오톡 채널 추가하기

매크로 처리 오류 'excerpt-include' : No link could be created for 'EN_Kakao Integration Feature SDK Example'.

using KakaoGame.API;

// [TODO] 채널 Id 설정
int channelId;

KGTKakaoTalk.AddChannel(channelId, (result) => 
{
    if (result.IsSucces) 
    {
        // 친구 추가하기 성공
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우.
    }
    else
    {
        // 친구 추가하기 실패
    }
});

구글 게임


업적 달성 화면 보여주기

매크로 처리 오류 'excerpt-include' : User 'null' does not have permission to view the page 'EN_구글 게임 SDK 예제'.

using KakaoGame.API;

KGTGoogleGamesAchievements.ShowAchievementView();

업적 달성

매크로 처리 오류 'excerpt-include' : User 'null' does not have permission to view the page 'EN_구글 게임 SDK 예제'.

using KakaoGame.API;

// [TODO] 업적 아이디 설정
var id = "";

KGTGoogleGamesAchievements.Unlock(id);

업적 노출하기

매크로 처리 오류 'excerpt-include' : User 'null' does not have permission to view the page 'EN_구글 게임 SDK 예제'.

using KakaoGame.API;

// [TODO] 업적 아이디 설정
var id = "";

KGTGoogleGamesAchievements.Reveal(id);

업적 단계 증가

매크로 처리 오류 'excerpt-include' : User 'null' does not have permission to view the page 'EN_구글 게임 SDK 예제'.

using KakaoGame.API;

// [TODO] 업적 아이디 설정
var id = "";
var numSteps = 0;

KGTGoogleGamesAchievements.SetSteps(id, numSteps);

업적 단계 설정

매크로 처리 오류 'excerpt-include' : User 'null' does not have permission to view the page 'EN_구글 게임 SDK 예제'.

using KakaoGame.API;

// [TODO] 업적 아이디 설정
var id = "";
var numSteps = 0;

KGTGoogleGamesAchievements.Increment(id, numSteps);

  • 레이블 없음