1.1. Initialization and Status Change Processing example

1.1. Initialization and Status Change Processing example

 


1.1.1. SDK Initialization (only for iOS, Unreal)

Add the initialization code of the Kakao Game SDK to the application’s AppDelegate.m file. Copy and paste the initialize function.

iOS

#import <KakaoGame/KakaoGame.h>    // SDK init +(void) initialize {     // KakaoGame SDK initialize     [KGSession initializeSDKWithAppDelegateClassName:NSStringFromClass([AppDelegate class])]; }

Unreal

If you support an Unreal Windows environment, you must invoke the SDK's initialization API before any other API at the start of the game.

#include "KakaoGame.h"   FKGSession::Initialize();

1.1.2. Start

When a game is started, it must call the Start function to notify the Kakao Game SDK that it has been started.

UI functions such as platform announcements, update news, and term agreements are performed when the Start function of the Kakao Game SDK is called. If there exists a prior user login record, the automatic login function is also performed, and the result is sent through the callback function inputted in the game when the method is called.

Therefore, the game can use the results to decide whether to authenticate the user first or whether to resume a previous game.

Unity

using Kakaogame.SDK;   // Start KGSession.Start(     (result, isAuthorized) => {         if (result.isSuccess) {             // Start successful             if (isAuthorized) {                 // Automatic login check                 // Current player’s ID issued by the platform                 string playerId = KGLocalPlayer.currentPlayer.playerId;                 // platform access token                 string accessToken = KGSession.accessToken;                 // Current player’s ID issued by the platform                 var idpProfile = KGLocalPlayer.currentPlayer.idpProfile;                 // [TODO] Move to the game server login and game screen             } else {                 ; // No automatic login details exist, move to the login             }         } else {             if (error.code == KGErrorNetworkFailure ||                 error.code == KGErrorServerTimeout ||                 error.code == KGErrorServerConnectionFailed) {                 // [TODO] If a network error has occurred, notify the user Start has failed due to a network issue and try again             } else {                 // [TODO] Notify the user of the error. The statement should preferably include the error code so that the user can track the cause of the error.             }         }     });

Android

iOS

Windows Sync

Windows Async

 Unreal

1.1.3. Pause

If the game is moved to the background, the game must call the Pause API to notify the Kakao Game SDK that it has become inactive.

When the Pause API is called, the Kakao Game SDK disconnects the connected session and stops periodically sending heartbeats to prevent battery consumption.

Unity

Android

iOS

 Unreal

1.1.4. Resume

If the game is moved back to the foreground from the background, it must call the Resume API to notify the Kakao Game SDK that it has become active.

The Kakao Game SDK checks whether the authentication has expired when the Resume method is called and restores the session depending on the check. The result is then sent through the callback function inputted in the game when the method is called.

The game can use the results to decide whether to authenticate the user again or whether to resume a previous game.

Unity

Android

iOS

Unreal

1.1.5. Adding a new Intent receive setting (Android only)

Add a callback inside MainActivity of the game as shown below.

If you do not add this setting, there will be a problem checking your game's funnel through 'game-play' page on KakaoTalk. Please be sure to add.

And when using Unity, set the corresponding MainActivity as the main activity in Unity Assets / Plugins / Android / AndroidManifest.xml file. If you use Kacao Game Unity SDK, it will be set automatically.

Android

1.1.6. Control pop-up exposure to allow user tracking(Applicable when iOS 3.10.13 or higher is applied)

When SDK 3.10.13 or higher is applied, iOS 14 users can display the user tracking permission pop-up.

It can be controlled by the Info.plist property value in the Xcode project.

 

Set the "SHOW_ADID_USAGE_POPUP" key as above and set the value to Boolean type.

  • Enable tracking popup exposure function ON: Set the value to "YES" or "1"

  • Enable tracking pop-up exposure function OFF: Set the value to "NO" or "0" / Remove the "SHOW_ADID_USAGE_POPUP" key itself

In iOS 15 or later, the point of the user tracking permission popup call (Start API based on SDK) can no longer be called immediately after the app is launched, and it has been changed so that it can be used only after the app is fully launched.

For reference, if a 3rd-party SDK other than KakaoGameSDK exposes a user tracking permission popup, you must also change the API to be called after the app is fully executed

1.1.9. Async Callback function setting (Windows only)

Callback function setting is added for UI display when calling Async function.
In the game's Main, add a callback and call the connection function as shown below. If this setting is not added, execution will not be completed when an Async function that requires a screen call is called.

Windows