목차 | ||
---|---|---|
|
초기화 및 상태변화 이벤트 처리
...
Initialization and Status Change Event Processing
...
App Event Method Initialization (iOS Only)
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame @main class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? override init() { KGTApplication.setSwizzleAppDelegate(delegate: AppDelegate.description()) } } |
SDK
...
Initialization
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame /** * 단일When using 앱으로a 사용하는single 경우app */ let config = KGTConfig(appId: "909428", appSecret: "c3c38bbfa3828b342d946e9770c974d0", appVersion: "1.0.0", market: "appStore", ageRating: "14", serverTypeappVersion: .QA"1.0.0", logLevel: .Verbose) /** * 앱 그룹을 사용하는 경우 */ let apps: [String : String] = [ "909428" market: "c3c38bbfa3828b342d946e9770c974d0appStore", "921478" : "5891c32124ca35821890a0bc1cec77a5"] let config = KGTConfig(appGroupId: "tubeAppGroup", apps: apps, appVersion: "1.0.0", market: "appStore", ageRating: "14", ageRating: "14", serverType: .QA, logLevel: .Verbose) /** * When using KGTApplication.initSDK(config) |
스타트 (Start) 하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
KGTApplication.start { error in
if error.isSuccess {
// 스타트가 성공 한 경우
// 자동로그인 여부
let isLoggedIn = KGTPlayer.isLoggedIn
if isLoggedIn {
// 플랫폼에서 발급한 현재 Player의 ID
let playerId = KGTPlayer.currentPlayer?.playerId
// 플랫폼 액세스 토큰
let accessToken = KGTPlayer.accessToken
// 현재 IDP 인증 정보를 가져옴
let idpProfile = KGTPlayer.currentPlayer?.idpProfile
// [TODO] 게임 화면으로 이동 합니다.
} else {
// [TODO] 자동로그인이 안 된 경우 로그인 화면으로 이동 합니다.
}
} else {
// 스타트가 실패 한 경우 - 초기화가 실패한 경우 이므로 스타트를 재시도 하거나 앱을 종료 하여야 합니다.
if error.code == KGTErrorCode.networkFailure ||
error.code == KGTErrorCode.serverTimeout ||
error.code == KGTErrorCode.serverConnectionFalied {
// [TODO] 네트워크 에러가 발생한 경우에는 유저에게 네트워크 이슈로 스타트에 실패했음을 알리고 재시도
} else {
// [TODO] 나머지 에러가 발생한 경우에는 에러 안내 후 스타트 재시도 요청 하여야 합니다. - 문제가 반복해서 발생하는 경우 에러코드 및 로그 확인 후 원인 파악이 필요합니다.
}
}
} |
Pause 하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
KGTApplication.pause() |
Resume 하기
...
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
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube KakaoGame KGTApplication.resumestart { error in if error.isSuccess { // [TODO]If resume이the 성공start 한is 경우 게임 화면을 재개합니다. } else {successful // [TODO]Check resume이if 실패auto-login 한is 경우enabled 인증 let 실패isLoggedIn 면= 로그인 화면으로, 그외의 경우는 에러 팝업을 띄우고 재시도 여부를 확인합니다. if error.code == KGTErrorCode.authFailure || error.code == KGTErrorCode.idpAuthFailure {KGTPlayer.isLoggedIn if isLoggedIn { // The current Player's ID issued by the platform let playerId = KGTPlayer.currentPlayer?.playerId // [TODO]Platform 인증access 실패의 경우 시작 화면으로 이동해서 다시 신규 로그인 flow를 수행합니다. } else { token let accessToken = KGTPlayer.accessToken // [TODO]Retrieve 나머지the 에러가current 발생한IDP 경우authentication 경우 에러 안내 후 resume 을 재시도 합니다. - 반복해서 문제가 발생하는 경우 앱을 종료하도록 합니다information let idpProfile = KGTPlayer.currentPlayer?.idpProfile // [TODO] Move to the game screen. } else { } }) |
로그인
...
기본 로그인 UI를 사용하지 않는 로그인하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube // 로그인 하고자 하는 IdpCode 셋팅 let idpCode = KGTIdpCode.Kakao // 특정 idp로 로그인 하기 KGTPlayer.login(with: idpCode) { error in if error.isSuccess // [TODO] If auto-login is not enabled, move to the login screen. } } else { //If IDPthe 로그인과start 플랫폼fails 로그인- 성공since initialization failed, retry the start or close the // 플랫폼에서 발급한 현재 Player의 IDapp. letif playerIderror.code == KGTPlayer.currentPlayer?.playerIdKGTErrorCode.networkFailure || // 플랫폼 액세스 토큰 let accessToken = KGTPlayer.accessToken // 현재 IDP 인증 정보를 가져옴 let idpProfile = KGTPlayer.currentPlayer?.idpProfile // [TODO] 로그인이 성공하였으므로 게임 화면으로 이동합니다. 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 { // IDP 로그인 혹은 플랫폼 로그인 실패 // [TODO] 로그인If 실패other 시errors 사용자occur, 안내provide 후an 재error 시도notification 하도록and 하여야request 합니다.a retry of the start process. - If the issue if error.code == KGTErrorCode.networkFailure || error.code == KGTErrorCode.serverTimeout || error.code == KGTErrorCode.serverConnectionFalied { // [TODO] 네트워크 에러가 발생한 경우에는 로그인 재시도 요청 하여야 합니다. } else if error.code == KGTErrorCode.blockedByPolicy { persists, check the error code and logs to determine the cause. } } } |
Pause
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
KGTApplication.pause() |
Resume
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame KGTApplication.resume { error in if error.isSuccess { // [TODO] 차단당한If 국가resume 코드is 또는successful, IPresume 대역에서the 로그인을game 시도하였습니다screen. 이에 } 대한else 처리가 필요합니다. } else if error.code == KGTErrorCode.userCanceled { // [TODO] 사용자가 로그인 진행 중 취소한 상황이므로 로그인 화면을 유지 하여야 합니다. } 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.
}
}
}) |
Login
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
...
Logging In Without Using the Default Login UI
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame // Set the IdpCode for login let idpCode = KGTIdpCode.Kakao // 로그아웃 요청Login with a specific IDP KGTPlayer.logoutlogin(showUIwith: falseidpCode) { error in if error.isSuccess { // 로그아웃IDP 성공login and // [TODO] 시작 화면으로 돌아가기 } else {platform login successful // The current Player's ID issued by the platform let playerId = KGTPlayer.currentPlayer?.playerId // 로그아웃Platform access 실패token } }) |
탈퇴
...
기본 탈퇴 UI를 사용하지 않는 탈퇴하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube // 탈퇴 요청 KGTPlayer.unregister(showUI: false) { error in if error.isSuccess { let accessToken = KGTPlayer.accessToken // Retrieve the current IDP authentication information let idpProfile = KGTPlayer.currentPlayer?.idpProfile // 탈퇴 성공 // [TODO] 시작 화면으로 돌아가기[TODO] Since login was successful, proceed to the game screen. } else { // 탈퇴 실패 } }) |
계정 연결
...
기본 계정 연결 UI를 사용하지 않는 계정 연결하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube // 로그인 하고자 하는 IdpCode 셋팅 let idpCode = KGTIdpCode.Kakao // 특정 idp로 계정 연결 하기 KGTPlayer.connect(idpCode: idpCode) { error in if error.isSuccess { // IDP 연결 성공 // Player ID 는 변경되지 않습니다. } else { // IDP 연결 실패 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. } } }) |
Logout
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
Logging Out Without Using the Default Logout UI
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
// Logout request
KGTPlayer.logout(showUI: false) { error in
if error.isSuccess {
// Logout successful
// [TODO] Return to the start screen
} else {
// Logout failed
}
}) |
Unregistration
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
Unregistering Without Using the Default Unregistration UI
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
// Unregister request
KGTPlayer.unregister(showUI: false) { error in
if error.isSuccess {
// Unregistration successful
// [TODO] Return to the start screen
} else {
// Unregistration failed
}
}) |
Account Linking
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
Linking Accounts Without Using the Default Account Linking UI
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
// 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
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let localPlayer = KGTPlayer.currentPlayer |
Retrieve My IDP Information
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let idpProfile = KGTPlayer.currentPlayer?.idpProfile |
System Information
...
Retrieve Language Code
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let languageCode = KGTSystem.languageCode |
Retrieve Country Code
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let countryCode = KGTSystem.countryCode |
Retrieve IP-based Country Code
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let countryCode = KGTSystem.geoCountryCode |
Retrieve Device ID
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let deviceId = KGTSystem.deviceId |
Retrieve Device Model
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let deviceModel = KGTSystem.deviceModel |
Retrieve OS Name
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let osName = KGTSystem.osName |
Retrieve Network Connection Status
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let isNetworkConnected = KGTSystem.isNetworkConnected |
Retrieve Connected Network Type
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
let networkType = KGTSystem.networkType |
Kakao Integration Feature
...
Setting Up KakaoTalk Game Message Reception
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
import KakaoGameKakao
// 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
}
}) |
Retrieve KakaoTalk Profile
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
import KakaoGameKakao
// Retrieve KakaoTalk profile
KGTKakaoTalk.talkProfile { error, profile in
if error.isSuccess {
// Successfully retrieved KakaoTalk profile
let talkProfile = profile // The KakaoTalk profile information of the logged-in user
} 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 profile
}
}) |
Retrieve KakaoTalk Game Friend List
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
import KakaoGameKakao
// 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
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame import KakaoGameKakao // 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.invalidParameterexceedDailyUsage { // 잘못된 인자가 전달 된 경우 } else if error.code == KGTErrorCode.notAuthorized { // 현재 로그인이 안되어 있는 경우 // Occurs when the daily quota for sending messages to a specific app (regardless of the recipient) is exceeded. } else if error.code == KGTErrorCode.invalidStateexceedMonthlyUsage { // 현재 인증 된 IDP 가 계정 연결 가능한 idp가 아닌 경우 } else if error.code == KGTErrorCode.alreadyUsedIdpAccount { // 이미 연결되어 있는 계정이 있는 경우 } else { // 기타 에러 발생 } } }) |
프로필
내 정보 조회하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let localPlayer = KGTPlayer.currentPlayer |
내 IDP 정보 조회하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let idpProfile = KGTPlayer.currentPlayer?.idpProfile |
시스템 정보
언어 코드 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let languageCode = KGTSystem.languageCode |
국가 코드 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let countryCode = KGTSystem.countryCode |
IP 기반 국가 코드 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let countryCode = KGTSystem.geoCountryCode |
기기 아이디 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let deviceId = KGTSystem.deviceId |
기기 모델 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let deviceModel = KGTSystem.deviceModel |
OS 이름 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let osName = KGTSystem.osName |
네트워크 연결 여부 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let isNetworkConnected = KGTSystem.isNetworkConnected |
연결된 네트워크 타입 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
let networkType = KGTSystem.networkType |
카카오 연동 기능
카카오톡 게임 메시지 수신 여부 설정하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube import KakaoGameTubeKakao // 카카오톡 게임 메시지 수신 여부 설정 뷰 띄우기 KGTKakaoTalk.showSetting { error, isAllowedMe in if error.isSuccess { // 카카오톡 게임 메시지 수신 여부 설정 성공 let isAllowedMe = isAllowedMe // 설정된 메시지 수신 허용 여부 // 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 } } }) |
Sending KakaoTalk Friend Invitation Messages
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame import KakaoGameKakao // [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.notKakaoTalkUserexceedDailyUsage { // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우. } else { // 카카오톡 게임 메시지 수신 여부 설정 실패 } }) |
카카오톡 프로필 조회하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube import KakaoGameTubeKakao // 카카오톡 프로필 조회하기 KGTKakaoTalk.talkProfile { error, profile in if error.isSuccess { // 카카오톡 프로필 조회 성공 let talkProfile = profile // 로그인한 유저의 카카오톡 프로필 정보// 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 { if error.code == KGTErrorCode.notKakaoTalkUser { // 로그인 한 유저가 '카카오톡' 유저가// 아닙니다.Failed 카카오to 스토리만send 가입한KakaoTalk 유저의invite 계정과message 같이 카카오톡 유저가 아닌 경우. } else { //} 카카오톡 프로필 조회 실패 } }) |
...
Adding a KakaoTalk Channel
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTubeKakaoGame import KakaoGameTubeKakaoKakaoGameKakao // 게임 친구 목록 조회하기 KGTKakaoTalk.friends[TODO] Set the channel ID let channelId = 0 KGTKakaoTalk.addChannel(channelId: channelId) { error, in players in if error.isSuccess { // 카카오톡 게임 친구 목록 조회 성공. for player in players { if let kakaoFriendProfile = player.idpProfile as? KGTKakaoFriendProfile { } } } else if error.code == KGTErrorCode.notKakaoTalkUser { // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우. } else { // 카카오톡 게임 친구 목록 조회 실패 } }) |
카카오톡 게임 메시지 보내기
...
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
}
}) |
Retrieve the list of friends to whom I sent an invite message
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
import KakaoGameTubeKakao
// friends API를 통해 가져온 친구 객체
let kakaoProfile: KGTKakaoFriendProfile = // 카카오 프로필 (KGTKakaoFriendProfile 객체)
// [TODO] 템플릿 Id 설정
let templateId = ""
// [TODO] 메시지 템플릿에 설정한 인자 설정
var argumentDic: [String : Any]? = [:]
argumentDic["rog_link"] = "test=100&hello20111"
argumentDic["bruce2"] = "test=100&hello=20111"
// 카카오톡 게임 메시지 보내기
KGTKakaoTalk.sendGameMessage(kakaoProfile: kakaoProfile, templateId: templateId, argumentDic: argumentDic) { error in
if error.isSuccess {
// 카카오톡 채팅 메시지 보내기 성공
} else {
if error.code == KGTErrorCode.messageSettingDisabled {
// 받은이가 메시지 수신 거부를 설정한 경우
} else if error.code == KGTErrorCode.exceedDailyUsage {
// 한명이 특정 앱에 대해 보낼 수 있는 하루 쿼터(받는 사람 관계없이) 초과시 발생
} else if error.code == KGTErrorCode.exceedMonthlyUsage {
// 한명이 특정 앱에 대해 특정인에게 보낼 수 있는 한달 쿼터 초과시 발생
} else {
// 카카오톡 채팅 메시지 보내기 실패
}
}
}) |
카카오톡 친구 초대 메시지 전송하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGameTube
import KakaoGameTubeKakao
// [TODO] 팝업창으로 띄울지 여부 설정
let isSingle = true
// [TODO] 팝업창으로 띄울지 여부 설정
let isPopup = true
// [TODO] 템플릿 Id 설정
let templateId = ""
// [TODO] 메시지 템플릿에 설정한 인자 설정
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 {
// 카카오톡 초대 메시지 보내기 성공
for user in users {
// 유저가 초대 메시지를 전송한 유저 목록 확인
}
} else {
// 전부 실패한 경우(공통된 원인 리턴해주기 필요)
if error.code == KGTErrorCode.messageSettingDisabled {
// 받은이가 메시지 수신 거부를 설정한 경우
} else if error.code == KGTErrorCode.exceedDailyUsage {
// 한명이 특정 앱에 대해 보낼 수 있는 하루 쿼터(받는 사람 관계없이) 초과시 발생
} else if error.code == KGTErrorCode.exceedMonthlyUsage {
// 한명이 특정 앱에 대해 특정인에게 보낼 수 있는 한달 쿼터 초과시 발생
} else {
// 카카오톡 초대 메시지 보내기 실패
}
}
}) |
카카오톡 채널 추가하기
...
코드 블럭 | ||
---|---|---|
| ||
import KakaoGame
import 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.
}
} |