...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame @main class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? override init() { KGTApplication.setSwizzleAppDelegate(delegate: AppDelegate.description()) } } |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame /** * 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) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame KGTApplication.start { error in if error.isSuccess { // If the start is successful // Check if auto-login is enabled let isLoggedIn = KGTPlayer.isLoggedIn if isLoggedIn { // The current Player's 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 the 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 that the start failed due to a network issue and retry. } else { // [TODO] If other errors occur, provide an error notification and request a retry of the start process. - If the issue persists, check the error code and logs to determine the cause. } } } |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame KGTApplication.pause() |
Resume
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame KGTApplication.resume { error in if error.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 error.code == KGTErrorCode.authFailure || error.code == KGTErrorCode.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. - If the issue persists, close the app. } } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame // 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's 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 prompt them to retry. if error.code == KGTErrorCode.networkFailure || error.code == KGTErrorCode.serverTimeout || error.code == KGTErrorCode.serverConnectionFailed { // [TODO] If other errors occur, provide an error notification and prompt the user to retry logging in. } 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] 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. } } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame // Logout request KGTPlayer.logout(showUI: false) { error in if error.isSuccess { // Logout successful // [TODO] Return to the start screen } else { // Logout failed } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame // Unregister request KGTPlayer.unregister(showUI: false) { error in if error.isSuccess { // Unregistration successful // [TODO] Return to the start screen } else { // Unregistration failed } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame // 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 } } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let localPlayer = KGTPlayer.currentPlayer |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let idpProfile = KGTPlayer.currentPlayer?.idpProfile |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let languageCode = KGTSystem.languageCode |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let countryCode = KGTSystem.countryCode |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let countryCode = KGTSystem.geoCountryCode |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let deviceId = KGTSystem.deviceId |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let deviceModel = KGTSystem.deviceModel |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let osName = KGTSystem.osName |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let isNetworkConnected = KGTSystem.isNetworkConnected |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame let networkType = KGTSystem.networkType |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame import KakaoGameTubeKakaoKakaoGameKakao // 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 as per the settings } 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 } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame import KakaoGameTubeKakaoKakaoGameKakao // 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 } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame import KakaoGameTubeKakaoKakaoGameKakao // 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 message reception to be disabled. } else if error.code == KGTErrorCode.exceedDailyUsage { // Occurs when the daily quota for sending messages to a specific app (regardless of the recipient) is exceeded. } else if error.code == KGTErrorCode.exceedMonthlyUsage { // Occurs when the monthly quota for sending messages to a specific person for a specific app is exceeded. } else { // Failed to send KakaoTalk chat message } } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame import KakaoGameTubeKakaoKakaoGameKakao // [TODO] Set whether to display as a popup window let isSingle = true // [TODO] Set whether to display as a popup window 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 message reception to be disabled. } else if error.code == KGTErrorCode.exceedDailyUsage { // Occurs when the daily quota for sending messages to a specific app (regardless of the recipient) is exceeded. } else if error.code == KGTErrorCode.exceedMonthlyUsage { // Occurs when the monthly quota for sending messages to a specific person for a specific app is exceeded. } else { // Failed to send KakaoTalk invite message } } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame import KakaoGameTubeKakaoKakaoGameKakao // [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 } }) |
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame import KakaoGameTubeKakao |
Retrieve the count of friends to whom I sent an invite message
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube import KakaoGameTubeKakao KakaoGameKakao // set event ID. let eventId = 0 // Retrieve the list of friends to whom I sent an invite message. KGTKakaoInvitation.joiners(eventId: eventId) { error, players in if error.isSuccess { // Successfully retrieve the list of friends. // Retrieve the list of players I have invited. if players.isEmpty { // No users have joined the app. } else { // There are users who have joined the app. for player in players { // Recipient’s player ID let playerId = player.playerId let kakaoProfile = player.idpProfile as? KGTKakaoFriendProfile // Recipient’s nickname let nickname = kakaoProfile?.nickname // Recipient’s profile thumbnail image let thumbnailImageUrl = kakaoProfile?.thumbnailImageUrl // Recipient’s withdrawal history inquiry. Use the corresponding flag when displaying the withdrawal status information in the UI. let isUnregistered = kakaoProfile?.isUnregistered } } } 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 the list of friends. } } |
Retrieve the count of friends to whom I sent an invite message
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
import KakaoGameKakao
// set event ID.
let eventId = 0
KGTKakaoInvitation.receiversCount(eventId: eventId) { error, totalReceiversCount, joinersCount in
if error.isSuccess {
// Successfully retrieve the count of friends to whom I sent an invite message.
} 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 the count of friends.
}
} |