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

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

현재와 비교 View Version History

« 이전 버전 5 다음 »


Initialization and Status Change Event Processing


SDK Initialization

매크로 처리 오류 '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 successful
        if (KGTPlayer.IsLoggedIn) 
        {
            // Auto login successful
            // The current Player's ID issued by the platform
            string playerId = KGTPlayer.CurrentPlayer.PlayerId;
            // Platform access token
            string accessToken = KGTPlayer.AccessToken;
            // Retrieve the current IDP authentication information
            var idpProfile = KGTPlayer.CurrentPlayer.IdpProfile;
            // [TODO] Log in to the game server and proceed to the game screen
        } 
        else 
        {
            // No auto login information, call the login API
        }
    }
    else 
    {
        if (result.code == KGTResultCode.NetworkFailure ||
            result.code == KGTResultCode.ServerTimeout ||
            result.code == KGTResultCode.ServerConnectionFailed) 
        {
            // [TODO] In case of a network error, notify the user that the start failed due to network issues and retry
        } 
        else 
        {
            // [TODO] Notify the user that an error occurred. It would be helpful to include the error code in the message for tracking the cause.
        }
    }
});

Pause

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

using KakaoGame.API;

// Implement in the background transition function of appDelegate
// [Note] Implement in OnApplicationPause.
// [Note] Do not implement in OnApplicationFocus.
void OnApplicationPause(bool paused) {
    // Method to be executed when the game moves to the background
    // The Pause API always returns success.
    // Therefore, you do not need to check the result separately in the game.
    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;

// Implement in the background transition function of appDelegate
// [Note] Implement in OnApplicationPause.
// [Note] Do not implement in OnApplicationFocus.
void OnApplicationPause(bool paused) {
    if (!paused) // When moved to the foreground
    {
        // Method to be executed when the game moves to the foreground
        KGTApplication.Resume((result) => 
        {
            if (result.IsSuccess) 
            {
                // [TODO] If resume is successful, resume the game screen.
            } 
            else 
            {
                // [TODO] If resume fails, navigate to the login screen if it’s an authentication failure; otherwise, show an error popup and check if the user wants to retry.
                if (result.code == KGTResultCode.AuthFailure ||
                    result.code == KGTResultCode.IdpAuthFailure) 
                {
                    // [TODO] In case of authentication failure, move to the start screen and perform the new login flow again.
                } 
                else 
                {
                    // [TODO] If other errors occur, provide an error notification and retry the resume.
                }
            }
        });
    }
}

Setting Up Auto Login in a Windows Environment

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

using KakaoGame.API;

// Set whether to use auto-login; if not set, it defaults to not using auto-login.
// When auto-login is enabled and login is successful, auto-login information is generated.
// If auto-login information exists, the next time KGTApplication starts, auto-login will proceed automatically. 
// To remove the auto-login information, you must log out.
bool useAutoLogin = true;
KGTApplication.UseAutoLogin = useAutoLogin;

Login


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

Logging In Without Using the Default Login 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) 
    {
        // Handle successful login.
        // The current Player's ID issued by the platform
        string playerId = KGTPlayer.CurrentPlayer.PlayerId;
        // Platform access token
        string accessToken = KGTPlayer.AccessToken;
        // Retrieve the current IDP authentication information
        var idpProfile = KGTPlayer.CurrentPlayer.IdpProfile;
        // [TODO] Log in to the game server and proceed to the game screen
    } 
    else 
    {
        // Handle login failure.
        if (result.code == KGTResultCode.NetworkFailure ||
            result.code == KGTResultCode.ServerTimeout ||
            result.code == KGTResultCode.ServerConnectionFailed) 
        {
            // [TODO] If a network error occurs, prompt the user to retry logging in.
        } 
        else if (result.code == KGTResultCode.Forbidden) 
        {
            // [TODO] During the CBT period, authentication may not be possible for users who are not allowed. Display a notification to the user, and after clicking confirm, implement the app to exit.
        } 
        else if (result.code == KGTResultCode.UserCanceled) 
        {
            // [TODO] Since the user canceled during the login process, the login screen should be maintained.
        } 
        else 
        {
            // [TODO] If other errors occur, provide an error notification and prompt the user to retry logging in.
            // It is necessary to check the error code and logs to determine the cause.
        }
    }
});

Logging In Through the Launcher

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

using KakaoGame.API;

// The bridgeToken received through the launcher
string bridgeToken = "";

KGTPlayer.LoginWithBridgeToken(bridgeToken, (result) =>
{
    if (result.IsSuccess) 
    {
        // Handle successful login.
        // The current Player's ID issued by the platform
        string playerId = KGTPlayer.CurrentPlayer.PlayerId;
        // Platform access token
        string accessToken = KGTPlayer.AccessToken;
        // Retrieve the current IDP authentication information
        var idpProfile = KGTPlayer.CurrentPlayer.IdpProfile;
        // [TODO] Log in to the game server and proceed to the game screen
    } 
    else 
    {
        // Handle login failure.
        if (result.code == KGTResultCode.NetworkFailure ||
            result.code == KGTResultCode.ServerTimeout ||
            result.code == KGTResultCode.ServerConnectionFailed) 
        {
            // [TODO] If a network error occurs, prompt the user to retry logging in.
        } 
        else if (result.code == KGTResultCode.Forbidden) 
        {
            // [TODO] During the CBT period, authentication may not be possible for users who are not allowed. Display a notification to the user, and after clicking confirm, implement the app to exit.
        } 
        else if (result.code == KGTResultCode.UserCanceled) 
        {
            // [TODO] Since the user canceled during the login process, the login screen should be maintained.
        } 
        else 
        {
            // [TODO] If other errors occur, provide an error notification and prompt the user to retry logging in.
            // It is necessary to check the error code and logs to determine the cause.
        }
    }
});

Logout


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

Logging Out Without Using the Default Logout UI

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

using KakaoGame.API;

KGTPlayer.Logout(false, (result) =>
{
    if (result.IsSuccess) 
    {
        // Logout successful
        // [TODO] Return to the start screen
    } 
    else 
    {
        // Logout failed
    }
});

Unregistration


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

Unregistering Without Using the Default Unregistration UI

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

using KakaoGame.API;

KGTPlayer.Unregister(false, (result) =>
{
    if (result.IsSuccess) 
    {
        // Unregistration successful
        // [TODO] Return to the start screen
    } 
    else 
    {
        // Unregistration failed
    }
});

Account Linking


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

Linking Accounts Without Using the Default Account Linking 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) 
    {
        // Account connection successful
    } 
    else if (result.code == KGTResultCode.NotAuthorized) 
    {
        // When the current session is not authenticated
    }
    else if (result.code == KGTResultCode.InvalidState) 
    {
        // When the account is already connected
    }
    else if (result.code == KGTResultCode.AlreadyUsedIDPAccount) 
    {
        // When attempting to connect with an IDP account that is already in use
    }
    else 
    {
        // Other errors
    }
});

Profile


Retrieve My Information

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

using KakaoGame.API;

KGTPlayer player = KGTPlayer.CurrentPlayer;

Retrieve My IDP Information

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

using KakaoGame.API;

KGTIdpProfile idpProfile = KGTPlayer.CurrentPlayer.IdpProfile;

System Information


Retrieve Language Code

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

using KakaoGame.API;

string languageCode = KGTSystem.LanguageCode;

Retrieve Country Code

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

using KakaoGame.API;

string countryCode = KGTSystem.CountryCode;

Retrieve IP-based Country Code

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

using KakaoGame.API;

string geoCountryCode = KGTSystem.GeoCountryCode;

Retrieve Device ID

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

using KakaoGame.API;

string deviceId = KGTSystem.DeviceId;

Retrieve Device Model

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

using KakaoGame.API;

string deviceModel = KGTSystem.DeviceModel;

Retrieve OS Name

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

using KakaoGame.API;

string osName = KGTSystem.OsName;

Retrieve Network Connection Status

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

using KakaoGame.API;

bool isNetworkConnected = KGTSystem.IsNetworkConnected;

Retrieve Connected Network Type

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

using KakaoGame.API;

string networkType = KGTSystem.NetworkType;

Retrieve Set Game Language Code

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

using KakaoGame.API;

string gameLanguageCode = KGTSystem.GameLanguageCode;

Set Game Language Code

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

using KakaoGame.API;

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

Kakao Integration Feature


Setting Up KakaoTalk Game Message Reception

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

using KakaoGame.API;

KGTKakaoTalk.ShowSetting((result) => 
{
    if (result.IsSuccess) 
    {
        // Successfully set the KakaoTalk game message reception settings
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // The logged-in user is not a 'KakaoTalk' user. This occurs when the user is not a KakaoTalk user, such as in the case of a user who is only registered for KakaoStory.
    }
    else 
    {
        // Failed to set the KakaoTalk game message reception settings
    }
});

KakaoTalk Profile Retrieval

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

using KakaoGame.API;

KGTKakaoTalk.TalkProfile((result) => 
{
    if (result.IsSuccess) 
    {
        // Successfully retrieved KakaoTalk profile
        KGTKakaoTalkProfile talkProfile = result.Content;
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // The logged-in user is not a 'KakaoTalk' user. This occurs when the user is not a KakaoTalk user, such as in the case of a user who is only registered for KakaoStory.
    }
    else 
    {
        // Failed to retrieve KakaoTalk profile
    }
});

Retrieving KakaoTalk Game Friend List

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

using KakaoGame.API;

KGTKakaoTalk.Friends((result) => 
{
    if (result.IsSuccess) 
    {
        var players = result.Content;
        // Successfully retrieved KakaoTalk game friends list.
        foreach(var player in players) {
            var kakaoProfile = (KGTKakaoProfile)player.IdpProfile; // Used when sending game messages
        }
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // The logged-in user is not a 'KakaoTalk' user. This occurs when the user is not a KakaoTalk user, such as in the case of a user who is only registered for KakaoStory.
    }
    else 
    {
        // Failed to retrieve KakaoTalk game message reception settings
    }
});

Sending KakaoTalk Game Messages

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

using KakaoGame.API;

// Through the Friends API
KGTKakaoFriendProfile kakaoProfile; // Kakao profile (KGTKakaoFriendProfile object)

// [TODO] Set the template Id
string templateId;
  
// [TODO] Set the arguments for the message template
Dictionary<string, object> argumentDic = new Dictionary<string, object>();

KGTKakaoTalk.SendGameMessage(kakaoProfile, templateId, argumentDic, (result) => 
{
    if (result.IsSuccess) 
    {
        // Successfully sent a KakaoTalk chat message.
    }
    else if (result.code == KGTResultCode.MessageSettingDisabled) 
    {
        // The recipient has set message reception to be disabled.
    }
    else if (result.code == KGTResultCode.ExceedDailyUsage) 
    {
        // Occurs when the daily quota for sending messages to a specific app (regardless of the recipient) is exceeded.
    }
    else if (result.code == KGTResultCode.ExceedMonthlyUsage) 
    {
        // Occurs when the monthly quota for sending messages to a specific person for a specific app is exceeded.
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // The logged-in user is not a 'KakaoTalk' user. This occurs when the user is not a KakaoTalk user, such as in the case of a user who is only registered for KakaoStory.
    }
    else 
    {
        // Failed to send KakaoTalk chat message.
    }
});

Sending KakaoTalk Friend Invitation Messages

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

using KakaoGame.API;

// [TODO] Set whether to display as a popup window
bool isSingle;

// [TODO] Set whether to display as a popup window
bool isPopup;
  
// [TODO] Set the template Id
string templateId;
  
// [TODO] Set the arguments for the message template
Dictionary<string, object> argumentDic = new Dictionary<string, object>();

KGTKakaoTalk.SendInviteMessage(isSingle, isPopup, templateId, argumentDic, (result) =>
{
    if (result.IsSuccess) 
    {
        // Request successful
    }
    else
    {
        // Request failed
        if (result.code == KGTResultCode.MessageSettingDisabled)
        {
            // The recipient has set message reception to be disabled.
        }
        else if (result.code == KGTResultCode.ExceedDailyUsage)
        {
            // Occurs when the daily quota for sending messages to a specific app (regardless of the recipient) is exceeded.
        }
        else if (result.code == KGTResultCode.ExceedMonthlyUsage)
        {
            // Occurs when the monthly quota for sending messages to a specific person for a specific app is exceeded.
        }
        else if (result.code == KGTResultCode.NotKakaoTalkUser)
        {
            // The logged-in user is not a 'KakaoTalk' user.
        }
        else
        {
            // Other errors
        }
    }
});

Adding a KakaoTalk Channel

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

using KakaoGame.API;

// [TODO] Set the channel Id
int channelId;

KGTKakaoTalk.AddChannel(channelId, (result) => 
{
    if (result.IsSuccess) 
    {
        // Successfully added friend
    }
    else if (result.code == KGTResultCode.NotKakaoTalkUser)
    {
        // The logged-in user is not a 'KakaoTalk' user. This occurs when the user is not a KakaoTalk user, such as in the case of a user who is only registered for KakaoStory.
    }
    else
    {
        // Failed to add friend
    }
});

Google Games


Show Achievement Screen

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

using KakaoGame.API;

KGTGoogleGamesAchievements.ShowAchievementView();

Achievement Unlocked

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

using KakaoGame.API;

// [TODO] Set the achievement ID
var id = "";

KGTGoogleGamesAchievements.Unlock(id);

Display Achievement

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

using KakaoGame.API;

// [TODO] Set the achievement ID
var id = "";

KGTGoogleGamesAchievements.Reveal(id);

Increase Achievement Level

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

using KakaoGame.API;

// [TODO] Set the achievement ID
var id = "";
var numSteps = 0;

KGTGoogleGamesAchievements.SetSteps(id, numSteps);

Set Achievement Level

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

using KakaoGame.API;

// [TODO] Set the achievement ID
var id = "";
var numSteps = 0;

KGTGoogleGamesAchievements.Increment(id, numSteps);

  • 레이블 없음

0 댓글

로그인 상태가 아닙니다. 변경하는 경우 익명으로 표기됩니다. 이미 계정이 있다면 로그인을 원하실 수 있습니다.