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

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

현재와 비교 View Version History

« 이전 버전 4 다음 »


Initialization and Status Change Event Processing


App Event Method Initialization (iOS Only)

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

import KakaoGameTube

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

	var window: UIWindow?
	
	override init() {
		KGTApplication.setSwizzleAppDelegate(delegate: AppDelegate.description())
	}

}

SDK Initialization

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

import KakaoGameTube

/**
 * When using a single app
 */
let config = KGTConfig(appId: "909428",
                       appSecret: "c3c38bbfa3828b342d946e9770c974d0",
                       appVersion: "1.0.0",
                       market: "appStore",
                       ageRating: "14",
                       serverType: .QA,
                       logLevel: .Verbose)

/**
 * When using an app group
 */
let apps: [String : String] = [ "909428" : "c3c38bbfa3828b342d946e9770c974d0",
                                "921478" : "5891c32124ca35821890a0bc1cec77a5"]
let config = KGTConfig(appGroupId: "tubeAppGroup",
                       apps: apps,
                       appVersion: "1.0.0",
                       market: "appStore",
                       ageRating: "14",
                       serverType: .QA,
                       logLevel: .Verbose)

KGTApplication.initSDK(config)

Start

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

import KakaoGameTube

KGTApplication.start { error in
	if error.isSuccess {
		// When the start is successful
				
		// Whether auto-login is enabled
		let isLoggedIn = KGTPlayer.isLoggedIn
				
		if isLoggedIn {
			// The current Player ID issued by the platform
			let playerId = KGTPlayer.currentPlayer?.playerId
					
			// Platform access token
			let accessToken = KGTPlayer.accessToken
					
			// Retrieve the current IDP authentication information
			let idpProfile = KGTPlayer.currentPlayer?.idpProfile
					
			// [TODO] Move to the game screen.
		} else {
			// [TODO] If auto-login is not enabled, move to the login screen.
		}
				
	} else {
		// If the start fails - since initialization failed, retry start or close the app.
				
		if error.code == KGTErrorCode.networkFailure ||
			error.code == KGTErrorCode.serverTimeout ||
			error.code == KGTErrorCode.serverConnectionFalied {
			// [TODO] If a network error occurs, notify the user of the failure due to a network issue and retry.
		} else {
			// [TODO] If other errors occur, provide error guidance and request a retry. - If the issue persists, check the error code and logs to determine the cause.
		}
	}
}

Pause

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

import KakaoGameTube
 
KGTApplication.pause()

Resume

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

import KakaoGameTube
 
KGTApplication.resume { error in
	if error.isSuccess {
		// [TODO] If resume is successful, resume the game screen.
	} else {
		// [TODO] If resume fails, move to the login screen if authentication fails, or show an error popup and check whether to retry for other errors.
		if error.code == KGTErrorCode.authFailure ||
			error.code == KGTErrorCode.idpAuthFailure {
			// [TODO] If authentication fails, move to the start screen and perform the login flow again.
		} else {
			// [TODO] For other errors, provide error guidance and retry resume. If the issue persists, consider closing the app.
		}
	}
})

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'.

import KakaoGameTube

// Set the IdpCode for login
let idpCode = KGTIdpCode.Kakao

// Login with a specific IDP
KGTPlayer.login(with: idpCode) { error in
	if error.isSuccess {
		// IDP login and platform login successful

        // The current Player ID issued by the platform
		let playerId = KGTPlayer.currentPlayer?.playerId
					
		// Platform access token
		let accessToken = KGTPlayer.accessToken
					
		// Retrieve the current IDP authentication information
		let idpProfile = KGTPlayer.currentPlayer?.idpProfile

		// [TODO] Since login was successful, proceed to the game screen.
	} else {
		// IDP login or platform login failed
		// [TODO] If login fails, inform the user and retry.

        if error.code == KGTErrorCode.networkFailure ||
			error.code == KGTErrorCode.serverTimeout ||
			error.code == KGTErrorCode.serverConnectionFailed {
			// [TODO] If a network error occurs, request a login retry.
		} else if error.code == KGTErrorCode.blockedByPolicy {
			// [TODO] Login attempt from a blocked country code or IP range. Handle this accordingly.
        } else if error.code == KGTErrorCode.userCanceled {    
			// [TODO] The user canceled the login process, so the login screen should remain.
		} else {
			// [TODO] For other errors, inform the user and request a login retry. - Check the error code and logs to identify 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'.

import KakaoGameTube

// Logout request
KGTPlayer.logout(showUI: false) { error in
    if error.isSuccess {
        // Logout successful

        // [TODO] Return to the start screen
    } else {
        // Logout failed
    }
})

Unregistration


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

Unregistering Without Using the Default Unregistration UI

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

import KakaoGameTube

// Unregister request
KGTPlayer.unregister(showUI: false) { error in 
    if error.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'.

import KakaoGameTube

// Set the IdpCode you want to log in with
let idpCode = KGTIdpCode.Kakao

// Connect to a specific IDP account
KGTPlayer.connect(idpCode: idpCode) { error in 
    if error.isSuccess {
        // IDP connection successful
        // Player ID does not change.
    } else {
        // IDP connection failed

        if error.code == KGTErrorCode.invalidParameter {
            // Invalid parameter was passed
        } else if error.code == KGTErrorCode.notAuthorized {
            // The user is not currently logged in
        } else if error.code == KGTErrorCode.invalidState {
            // The current authenticated IDP is not eligible for account connection
        } else if error.code == KGTErrorCode.alreadyUsedIdpAccount {
            // The account is already connected
        } else {
            // Other errors occurred
        }
    }
})

Profile


Retrieve My Information

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

import KakaoGameTube

let localPlayer = KGTPlayer.currentPlayer

Retrieve My IDP Information

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

import KakaoGameTube

let idpProfile = KGTPlayer.currentPlayer?.idpProfile

System Information


Retrieve Language Code

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

import KakaoGameTube

let languageCode = KGTSystem.languageCode

Retrieve Country Code

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

import KakaoGameTube

let countryCode = KGTSystem.countryCode

Retrieve IP-based Country Code

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

import KakaoGameTube

let countryCode = KGTSystem.geoCountryCode

Retrieve Device ID

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

import KakaoGameTube

let deviceId = KGTSystem.deviceId

Retrieve Device Model

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

import KakaoGameTube

let deviceModel = KGTSystem.deviceModel

Retrieve OS Name

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

import KakaoGameTube

let osName = KGTSystem.osName

Retrieve Network Connection Status

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

import KakaoGameTube

let isNetworkConnected = KGTSystem.isNetworkConnected

Retrieve Connected Network Type

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

import KakaoGameTube

let networkType = KGTSystem.networkType

Kakao Integration Feature


Setting Up KakaoTalk Game Message Reception

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

import KakaoGameTube
import KakaoGameTubeKakao

// Display the view to set the KakaoTalk game message reception settings
KGTKakaoTalk.showSetting { error, isAllowedMe in
    if error.isSuccess {
        // Successfully set the KakaoTalk game message reception settings
        let isAllowedMe = isAllowedMe // Whether message reception is allowed
    } else if error.code == KGTErrorCode.notKakaoTalkUser {
        // The logged-in user is not a 'KakaoTalk' user. This occurs when the user is only registered with KakaoStory and not KakaoTalk.
    } else {
        // Failed to set the KakaoTalk game message reception settings
    }
})

Retrieve KakaoTalk Profile

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

import KakaoGameTube
import KakaoGameTubeKakao

// Display the view to set the KakaoTalk game message reception settings
KGTKakaoTalk.showSetting { error, isAllowedMe in
    if error.isSuccess {
        // Successfully set the KakaoTalk game message reception settings
        let isAllowedMe = isAllowedMe // Whether message reception is allowed
    } else if error.code == KGTErrorCode.notKakaoTalkUser {
        // The logged-in user is not a 'KakaoTalk' user. This occurs when the user is only registered with KakaoStory and not KakaoTalk.
    } else {
        // Failed to set the KakaoTalk game message reception settings
    }
})

Retrieve KakaoTalk Game Friend List

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

import KakaoGameTube
import KakaoGameTubeKakao

// Retrieve the list of game friends
KGTKakaoTalk.friends { error, players in
    if error.isSuccess {
        // Successfully retrieved KakaoTalk game friends list.
        for player in players {
            if let kakaoFriendProfile = player.idpProfile as? KGTKakaoFriendProfile {
                // You can now access kakaoFriendProfile properties here
            }
        }
    } else if error.code == KGTErrorCode.notKakaoTalkUser {
        // The logged-in user is not a 'KakaoTalk' user. This occurs when the user is only registered with KakaoStory and not KakaoTalk.
    } else {
        // Failed to retrieve KakaoTalk game friends list
    }
})

Sending KakaoTalk Game Messages

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

import KakaoGameTube
import KakaoGameTubeKakao

// Friend object retrieved via the friends API
let kakaoProfile: KGTKakaoFriendProfile = // Kakao profile (KGTKakaoFriendProfile object)

// [TODO] Set the template ID
let templateId = ""

// [TODO] Set the arguments for the message template
var argumentDic: [String: Any]? = [:]
argumentDic?["rog_link"] = "test=100&hello20111"
argumentDic?["bruce2"] = "test=100&hello=20111"

// Send KakaoTalk game message
KGTKakaoTalk.sendGameMessage(kakaoProfile: kakaoProfile, templateId: templateId, argumentDic: argumentDic) { error in
    if error.isSuccess {
        // Successfully sent KakaoTalk chat message
    } else {
        if error.code == KGTErrorCode.messageSettingDisabled {
            // The recipient has set to block messages
        } else if error.code == KGTErrorCode.exceedDailyUsage {
            // The daily quota for sending messages in a specific app (regardless of recipient) has been exceeded
        } else if error.code == KGTErrorCode.exceedMonthlyUsage {
            // The monthly quota for sending messages to a specific person in a specific app has been exceeded
        } 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'.

import KakaoGameTube
import KakaoGameTubeKakao

// [TODO] Set whether to display as a popup
let isSingle = true

// [TODO] Set whether to display as a popup
let isPopup = true

// [TODO] Set the template ID
let templateId = ""

// [TODO] Set the arguments for the message template
var argumentDic: [String: Any]? = [:]
argumentDic?["rog_link"] = "test=100&hello20111"
argumentDic?["bruce2"] = "test=100&hello=20111"

KGTKakaoTalk.sendInviteMessage(isSingle: isSingle, isPopup: isPopup, templateId: templateId, argumentDic: argumentDic) { error, users in
    if error.isSuccess {
        // Successfully sent KakaoTalk invite message
        for user in users {
            // Check the list of users who received the invite message
        }
    } else {
        // Failed to send to all users (common cause needs to be returned)
        if error.code == KGTErrorCode.messageSettingDisabled {
            // The recipient has set to block messages
        } else if error.code == KGTErrorCode.exceedDailyUsage {
            // The daily quota for sending messages in a specific app (regardless of recipient) has been exceeded
        } else if error.code == KGTErrorCode.exceedMonthlyUsage {
            // The monthly quota for sending messages to a specific person in a specific app has been exceeded
        } else {
            // Failed to send KakaoTalk invite message
        }
    }
})

Adding a KakaoTalk Channel

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

import KakaoGameTube
import KakaoGameTubeKakao

// [TODO] Set the channel ID
let channelId = 0

KGTKakaoTalk.addChannel(channelId: channelId) { error in
    if error.isSuccess {
        // Successfully added the channel
    } else if error.code == KGTErrorCode.notKakaoTalkUser {
        // The logged-in user is not a KakaoTalk user. For example, they might only be a Kakao Story user and not a KakaoTalk user.
    } else {
        // Failed to add the channel
    }
})
  • 레이블 없음

0 댓글

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