목차 | ||
---|---|---|
|
...
Initialization and Status Change Event Processing
...
SDK
...
Initialization
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTApplication; import com.kakaogame.KGTConfig; /** * 단일When using 앱으로a 사용하는single 경우app */ KGTConfig config = new KGTConfig(); config.setAppInfo( "909428", // appID "c3c38bbfa3828b342d946e9770c974d0", // appSecret "1.0.0", // appVersion "googlePlay", // market "14", // ageRating KGTServerType.QA, // server type KGTLogLevel.Error // log level ); /** * 앱When using 그룹을an 사용하는app 경우group */ Map<String, String> appsForAppGroup = new HashMap<>(); appsForAppGroup.put("909428", "c3c38bbfa3828b342d946e9770c974d0"); appsForAppGroup.put("921478", "5891c32124ca35821890a0bc1cec77a5"); KGTConfig config = new KGTConfig(); config.setAppGroupInfos( "tubeAppGroup", // appGroupId appsForAppGroup, // app info map "1.0.0", // appVersion "googlePlay", // market "14", // ageRating KGTServerType.QA, // server type KGTLogLevel.Error // log level ); KGTApplication.initSDK(this, config); |
...
Start
...
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTApplication; import com.kakaogame.KGTIdpProfile; import com.kakaogame.KGTPlayer; import com.kakaogame.KGTResult; KGTApplication.start(activity, null, result -> { if (result.isSuccess()) { // If 스타트가the 성공start 한is 경우successful // 자동로그인 여부 Check if auto-login is enabled boolean isLoggedIn = KGTPlayer.isLoggedIn(); if (isLoggedIn) { // 플랫폼에서 발급한 현재 Player의 ID The current Player's ID issued by the platform String playerId = KGTPlayer.getCurrentPlayer().getPlayerId(); // Platform 플랫폼access 액세스token 토큰(ZAT) String accessToken = KGTPlayer.getCurrentPlayer().getAccessToken(); // Retrieve 현재the current IDP 인증authentication 정보를information 가져옴 KGTIdpProfile idpProfile = KGTPlayer.getCurrentPlayer().getIdpProfile(); // [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. int resultCode = result.getCode(); if (resultCode == KGTResult.KGTResultCode.NETWORK_FAILURE || resultCode == KGTResult.KGTResultCode.SERVER_TIMEOUT || resultCode == KGTResult.KGTResultCode.SERVER_CONNECTION_FAILED) { // [TODO] 네트워크If 에러가a 발생한network 경우에는error 유저에게occurs, 네트워크inform 이슈로 스타트에 실패했음을 알리고 재시도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. } } }); |
Pause
...
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTApplication; import com.kakaogame.KGTResult; KGTApplication.pause(activity, result -> { // }); |
Resume
...
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTApplication; import com.kakaogame.KGTResult; KGTApplication.resume(activity, result -> { if (result.isSuccess()) { // [TODO] resume이If 성공 한 경우 게임 화면을 재개합니다resume is successful, resume the game screen. } else { // [TODO] resume이 실패 한 경우 인증 실패 면 로그인 화면으로, 그외의 경우는 에러 팝업을 띄우고 재시도 여부를 확인합니다 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.getCode() == KGTResult.KGTResultCode.AUTH_FAILURE || result.getCode() == KGTResult.KGTResultCode.IDP_AUTH_FAILURE) { // [TODO] 인증In 실패의case 경우of 시작authentication 화면으로failure, 이동해서move 다시 신규 로그인 flow를 수행합니다to the start screen and perform the new login flow again. } else { // [TODO] 나머지 에러가 발생한 경우 경우 에러 안내 후 resume 을 재시도 합니다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.
}
}
}); |
Adding a New Intent Receive Setting
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); // 현재 액티비티에 새로운 intent 업데이트 Update the current activity with the new intent this.setIntent(intent); } |
...
Login
...
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
...
Logging In Without Using the Default Login UI
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTApplication; import com.kakaogame.KGTIdpProfile; import com.kakaogame.KGTPlayer; import com.kakaogame.KGTResult; // Set 로그인the 하고자IdpCode 하는for IdpCodethe 셋팅login KGTIdpProfile.KGTIdpCode code = KGTIdpCode.Kakao; // Log in 특정with idp로a 로그인specific 하기IDP KGTPlayer.login(activity, code, result -> { if (result.isSuccess()) { // IDP login 로그인과and 플랫폼platform 로그인login 성공succeeded // 플랫폼에서 발급한 현재 Player의 IDThe current Player's ID issued by the platform String playerId = KGTPlayer.getCurrentPlayer().getPlayerId(); // 플랫폼Platform 액세스access 토큰token String accessToken = KGTPlayer.getAccessToken(); // Retrieve the 현재current IDP 인증authentication 정보를information 가져옴 KGTIdpProfile idpProfile = KGTPlayer.getCurrentPlayer().getIdpProfile(); // [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 (result.getCode() == KGTResult.KGTResultCode.NETWORK_FAILURE || result.getCode() == KGTResult.KGTResultCode.SERVER_TIMEOUT || result.getCode() == KGTResult.KGTResultCode.SERVER_CONNECTION_FAILED) { // [TODO] 네트워크 에러가 발생한 경우에는 로그인 재시도 요청 하여야 합니다If a network error occurs, prompt the user to retry logging in. } else if (result.getCode() == KGTResult.KGTResultCode.USER_CANCELED) { // [TODO] 사용자가 로그인 진행 중 취소한 상황이므로 로그인 화면을 유지 하여야 합니다 Since the user canceled during the login process, the login screen should be maintained. } else if (result.getCode() == KGTResult.KGTResultCode.BLOCKED_BY_POLICY) { // [TODO] 차단당한The 국가login 코드was 또는attempted IPfrom 대역에서a 로그인을blocked 시도하였습니다.country 이에code 대한 처리가 필요합니다or IP range. Handle accordingly. } 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 com.kakaogame.KGTPlayer; import com.kakaogame.KGTResult; // 로그아웃Logout 요청request KGTPlayer.logout(activity, false, result -> { if (result.isSuccess()) { // 로그아웃Logout 성공successful // [TODO] Return to 시작the 화면으로start 돌아가기screen } else { // 로그아웃Logout 실패failed } }); |
탈퇴
...
Unregistration
...
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
...
Unregistering Without Using the Default Unregistration UI
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTPlayer; import com.kakaogame.KGTIdpProfile; import com.kakaogame.KGTResult; // 로그인Unregister 하고자 하는 IdpCode 셋팅 KGTIdpProfile.KGTIdpCode code = KGTIdpCode.Kakao; // 특정 idp로 계정 연결 하기 KGTPlayer.connect(activity, code, result -> { if (result.isSuccess()) { // IDP 연결 성공request KGTPlayer.unregister(activity, false, result -> { if (result.isSuccess()) { // Unregistration successful // [TODO] PlayerReturn IDto 는the 변경되지start 않습니다.screen } else { // IDPUnregistration 연결 실패failed if (result.getCode() == KGTResult.KGTResultCode.INVALID_PARAMETER) { // 잘못된 인자가 전달 된 경우 // 예) activity 가 null } else if (result.getCode() == KGTResult.KGTResultCode.NOT_AUTHORIZED) { // 현재 인증이 안되어 있는 경우 } else if (result.getCode() == KGTResult.KGTResultCode.INVALID_STATE) { // 현재 인증 된 IDP 가 기기 인증이 아닌 경우 } else if (result.getCode() == KGTResult.KGTResultCode.ALREADY_USED_IDP_ACCOUNT) { // 이미 인증되어 있는 계정인 경우 } else { // 기타 에러 발생 } } }); |
프로필
내 정보 조회하기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTPlayer;
KGTPlayer localPlayer = KGTPlayer.getCurrentPlayer(); |
내 IDP 정보 조회하기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTPlayer;
import com.kakaogame.KGTIdpProfile;
KGTIdpProfile idpProfile = KGTPlayer.getCurrentPlayer().getIdpProfile(); |
시스템 정보
언어 코드 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String languageCode = KGTSystem.getLanguageCode(); |
언어 태그 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String languageCode = KGTSystem.getLanguageTag(); |
국가 코드 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String countryCode = KGTSystem.getCountryCode(); |
IP 기반 국가 코드 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String countryCode = KGTSystem.getGeoCountryCode(); |
기기 아이디 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String deviceId = KGTSystem.getDeviceId(); |
기기 모델 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String deviceModel = KGTSystem.getDeviceModel(); |
OS 이름 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String osName = KGTSystem.getOSName(); |
네트워크 연결 여부 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
boolean networkConnected = KGTSystem.isNetworkConnected(); |
연결된 네트워크 타입 가져오기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String networkType = KGTSystem.getNetworkType(); |
카카오 연동 기능
카카오톡 게임 메시지 수신 여부 설정하기
...
}
}); |
Account Linking
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
Linking Accounts Without Using the Default Account Linking UI
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTPlayer;
import com.kakaogame.KGTIdpProfile;
import com.kakaogame.KGTResult;
// Set the IdpCode to log in with
KGTIdpProfile.KGTIdpCode code = KGTIdpCode.Kakao;
// Connect account with a specific idp
KGTPlayer.connect(activity, code, result -> {
if (result.isSuccess()) {
// IDP connection successful
// Player ID will not change.
} else {
// IDP connection failed
if (result.getCode() == KGTResult.KGTResultCode.INVALID_PARAMETER) {
// Invalid parameter passed
// e.g., activity is null
} else if (result.getCode() == KGTResult.KGTResultCode.NOT_AUTHORIZED) {
// The current state is not authorized
} else if (result.getCode() == KGTResult.KGTResultCode.INVALID_STATE) {
// The currently authenticated IDP is not device authentication
} else if (result.getCode() == KGTResult.KGTResultCode.ALREADY_USED_IDP_ACCOUNT) {
// The account is already authenticated
} else {
// Other errors occurred
}
}
}); |
Profile
...
Retrieve My Information
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTPlayer;
KGTPlayer localPlayer = KGTPlayer.getCurrentPlayer(); |
Retrieve My IDP Information
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTPlayer;
import com.kakaogame.KGTIdpProfile;
KGTIdpProfile idpProfile = KGTPlayer.getCurrentPlayer().getIdpProfile(); |
System Information
...
Retrieve Language Code
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String languageCode = KGTSystem.getLanguageCode(); |
Retrieve Language Tag
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String languageCode = KGTSystem.getLanguageTag(); |
Retrieve Country Code
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String countryCode = KGTSystem.getCountryCode(); |
Retrieve IP-based Country Code
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String countryCode = KGTSystem.getGeoCountryCode(); |
Retrieve Device ID
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String deviceId = KGTSystem.getDeviceId(); |
Retrieve Device Model
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String deviceModel = KGTSystem.getDeviceModel(); |
Retrieve OS Name
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String osName = KGTSystem.getOSName(); |
Retrieve Network Connection Status
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
boolean networkConnected = KGTSystem.isNetworkConnected(); |
Retrieve Connected Network Type
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTSystem;
String networkType = KGTSystem.getNetworkType(); |
Kakao Integration Feature
...
Setting Up KakaoTalk Game Message Reception
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTKakaoTalk;
// Display the view to set KakaoTalk game message reception preferences
KGTKakaoTalk.showSetting(activity, result -> {
if (result.isSuccess()) {
// Successfully set the KakaoTalk game message reception settings
boolean allowMessage = result.getContent(); // Whether message reception is allowed as per the settings
} else if (result.getCode() == KGTResult.KGTResultCode.NOT_KAKAOTALK_USER) {
// 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 com.kakaogame.KGTKakaoTalk;
import com.kakaogame.KGTKakaoTalkProfile;
// Retrieve KakaoTalk profile
KGTKakaoTalk.talkProfile(result -> {
if (result.isSuccess()) {
// Successfully retrieved KakaoTalk profile
talkProfile = result.getContent(); // The KakaoTalk profile information of the logged-in user
} else if (result.getCode() == KGTResult.KGTResultCode.NOT_KAKAOTALK_USER) {
// 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 com.kakaogame.KGTKakaoTalk;
import com.kakaogame.KGTKakaoFriendProfile;
// Retrieve the list of game friends
KGTKakaoTalk.friends(result -> {
if (result.isSuccess()) {
// Successfully retrieved KakaoTalk game friends list.
List<KGTPlayer> friendList = result.getContent(); // Game friends list
for (KGTPlayer player : friendList) {
KGTKakaoFriendProfile kakaoProfile = (KGTKakaoFriendProfile)player.getIdpProfile();
}
} else if (result.getCode() == KGTResult.KGTResultCode.NOT_KAKAOTALK_USER) {
// 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 com.kakaogame.KGTKakaoFriendProfile;
import com.kakaogame.KGTKakaoTalk;
import com.kakaogame.KGTKakaoTalkProfile;
// Friend object retrieved 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
Map<String, String> args = new LinkedHashMap<>();
if (talkProfile != null) {
args.put("${nickname}", talkProfile.getNickname());
}
args.put("rog_link", "test=100&hello=20111");
args.put("bruce2", "test=100&hello=20111");
// Send a KakaoTalk game message
KGTKakaoTalk.sendGameMessage(kakaoProfile, templateId, args, result -> {
if (result.isSuccess()) {
// Successfully sent a KakaoTalk chat message
} else {
if (result.getCode() == KGTResult.KGTResultCode.MESSAGE_SETTING_DISABLE) {
// The recipient has set message reception to disabled
} else if (result.getCode() == KGTResult.KGTResultCode.EXCEED_DAILY_USAGE) {
// Occurs when the daily quota for sending messages to a specific app (regardless of the recipient) is exceeded.
} else if (result.getCode() == KGTResult.KGTResultCode.EXCEED_MONTHLY_USAGE) {
// 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 com.kakaogame.KGTKakaoTalk;
// 카카오톡 게임 메시지 수신 여부 설정 뷰 띄우기
KGTKakaoTalk.showSetting(activity, result -> {
if (result.isSuccess()) {
// 카카오톡 게임 메시지 수신 여부 설정 성공
boolean allowMessage = result.getContent(); // 설정된 메시지 수신 허용 여부
} else if (result.getCode() == KGTResult.KGTResultCode.NOT_KAKAOTALK_USER) {
// 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우.
} else {
// 카카오톡 게임 메시지 수신 여부 설정 실패
}
}); |
카카오톡 프로필 조회하기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTKakaoTalk; import com.kakaogame.KGTKakaoTalkProfile; // 카카오톡 프로필 조회하기 KGTKakaoTalk.talkProfile(.kakaogame.KGTKakaoTalk; import com.kakaogame.KGTKakaoTalkProfile; import com.kakaogame.KGTKakaoUser; // [TODO] Set whether to display as a popup window boolean isSingle = true; // [TODO] Set whether to display as a popup window boolean isPopup = true; // [TODO] Set the template Id String templateId = ""; // [TODO] Set the parameters for the message template Map<String, String> args = new LinkedHashMap<>(); if (talkProfile != null) { args.put("${nickname}", talkProfile.getNickname()); } KGTKakaoTalk.sendInviteMessage(activity, isSingle, isPopUp, templateId, args, result -> { if (result.isSuccess()) { // Successfully 카카오톡sent 프로필KakaoTalk 조회invite 성공message talkProfile =for (KGTKakaoUser kakaoUser : result.getContent(); ) { // 로그인한 유저의 카카오톡 프로필 정보 } else if (result.getCode() == KGTResult.KGTResultCode.NOT_KAKAOTALK_USER)Check the list of users who received the invite message } } else { // 로그인Failed 한to 유저가send '카카오톡'to 유저가all 아닙니다.users 카카오(need 스토리만to 가입한return 유저의a 계정과 같이 카카오톡 유저가 아닌 경우. } else { common cause) if (result.getCode() == KGTResult.KGTResultCode.MESSAGE_SETTING_DISABLE) { // 카카오톡The recipient 프로필has 조회set 실패message } }); |
카카오톡 게임 친구 목록 조회하기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTKakaoTalk; import com.kakaogame.KGTKakaoFriendProfile; // 게임 친구 목록 조회하기 KGTKakaoTalk.friends(result -> { if (result.isSuccess()) { // 카카오톡 게임 친구 목록 조회 성공. List<KGTPlayer> friendList = result.getContent(); // 게임 친구 목록 for (KGTPlayer player : friendList) { KGTKakaoFriendProfile kakaoProfile = (KGTKakaoFriendProfile)player.getIdpProfile(); } reception to disabled } else if (result.getCode() == KGTResult.KGTResultCode.EXCEED_DAILY_USAGE) { // Occurs when the daily quota for sending messages to a specific app (regardless of the recipient) is exceeded. } else if (result.getCode() == KGTResult.KGTResultCode.EXCEED_MONTHLY_USAGE) { // 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 } } }); |
Adding a KakaoTalk Channel
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTKakaoTalk; // [TODO] Set the channel Id int channelId = 0; KGTKakaoTalk.addChannel(plusFriendId, result -> { if (result.isSuccess()) { // Successfully added the channel } else if (result.getCode() == KGTResult.KGTResultCode.NOT_KAKAOTALK_USER) { // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우 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 친구add 목록the 조회 실패channel } }); |
...
Retrieve the list of friends to whom I sent an invite message
발췌문 삽입 | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTKakaoFriendProfileKGTKakaoInvitation; import com.kakaogame.KGTKakaoTalkKGTPlayer; import com.kakaogame.KGTKakaoTalkProfile; // friends API를 통해 가져온 친구 객체 KGTKakaoFriendProfile kakaoProfile; // 카카오 프로필(KGTKakaoFriendProfile 객체) // [TODO] 템플릿 Id 설정 String templateId = ""; // [TODO] 메시지 템플릿에 설정한 인자 설정 Map<String, String> args = new LinkedHashMap<>(); if (talkProfile != null) { args.put("${nickname}", talkProfile.getNickname()); } args.put("rog_link", "test=100&hello=20111"); args.put("bruce2", "test=100&hello=20111"); // 카카오톡 게임 메시지 보내기 KGTKakaoTalk.sendGameMessage(kakaoProfile, templateId, argsEvent Id. int eventId = 0; // Retrieve the list of friends to whom I sent an invite message. KGTKakaoInvitation.joiners(eventId, result -> { if (result.isSuccess()) { // 카카오톡 채팅 메시지 보내기 성공 } else { if (result.getCode() == KGTResult.KGTResultCode.MESSAGE_SETTING_DISABLE) { // 받은이가 메시지 수신 거부를 설정한 경우 } else if (result.getCode() == KGTResult.KGTResultCode.EXCEED_DAILY_USAGE) { // 한명이 특정 앱에 대해 보낼 수 있는 하루 쿼터(받는 사람 관계없이) 초과시 발생 } else if (result.getCode() == KGTResult.KGTResultCode.EXCEED_MONTHLY_USAGE) { // 한명이 특정 앱에 대해 특정인에게 보낼 수 있는 한달 쿼터 초과시 발생 } else { // 카카오톡 채팅 메시지 보내기 실패 } } }); |
카카오톡 친구 초대 메시지 전송하기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTKakaoTalk;
import com.kakaogame.KGTKakaoTalkProfile;
import com.kakaogame.KGTKakaoUser;
// [TODO] 팝업창으로 띄울지 여부 설정
boolean isSingle = true;
// [TODO] 팝업창으로 띄울지 여부 설정
boolean isPopup = true;
// [TODO] 템플릿 Id 설정
String templateId = "";
// [TODO] 메시지 템플릿에 설정한 인자 설정
Map<String, String> args = new LinkedHashMap<>();
if (talkProfile != null) {
args.put("${nickname}", talkProfile.getNickname());
}
KGTKakaoTalk.sendInviteMessage(activity, isSingle, isPopUp, templateId, args, result -> {
if (result.isSuccess()) {
// 카카오톡 초대 메시지 보내기 성공
for (KGTKakaoUser kakaoUser : result.getContent()) {
// 유저가 초대 메시지를 전송한 유저 목록 확인
}
} else {
// 전부 실패한 경우(공통된 원인 리턴해주기 필요)
if (result.getCode() == KGTResult.KGTResultCode.MESSAGE_SETTING_DISABLE) {
// 받은이가 메시지 수신 거부를 설정한 경우
} else if (result.getCode() == KGTResult.KGTResultCode.EXCEED_DAILY_USAGE) {
// 한명이 특정 앱에 대해 보낼 수 있는 하루 쿼터(받는 사람 관계없이) 초과시 발생
} else if (result.getCode() == KGTResult.KGTResultCode.EXCEED_MONTHLY_USAGE) {
// 한명이 특정 앱에 대해 특정인에게 보낼 수 있는 한달 쿼터 초과시 발생
} else {
// 카카오톡 초대 메시지 보내기 실패
}
}
}); |
카카오톡 채널 추가하기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTKakaoTalk; // [TODO] 채널 Id 설정 int channelId = 0; KGTKakaoTalk.addChannel(plusFriendId, result -> { if (result.isSuccess()) { // 채널 추가 성공 // Successfully retrieve the list of friends. // Retrieve the list of players I have invited. KGTKakaoInvitation.KGTInvitationJoinersResponse joinersResponse = result.getContent(); // List of players who have joined the app, including those who have left. List<KGTPlayer> joiners = joinersResponse.getPlayers(); if (joiners.isEmpty()) { // No users have joined the app. } else { // There are users who have joined the app. for (KGTPlayer player : joiners) { // Recipient’s player ID String playerId = player.getPlayerId(); KGTKakaoFriendProfile kakaoProfile = (KGTKakaoFriendProfile) player.getIdpProfile(); // Recipient’s nickname String nickname = kakaoProfile.getNickname(); // Recipient’s profile thumbnail image String thumbnailImageUrl = kakaoProfile.getThumbnailImageUrl(); // Recipient’s withdrawal history inquiry. Use the corresponding flag when displaying the withdrawal status information in the UI. boolean isUnregistered = kakaoProfile.isUnregistered(); } } } else if (result.getCode() == KGTResult.KGTResultCode.NOT_KAKAOTALK_USER) { // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. 카카오 스토리만 가입한 유저의 계정과 같이 카카오톡 유저가 아닌 경우. } else { // 채널 추가 실패 } }); |
구글 게임
업적 달성 화면 보여주기
...
) {
// 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 com.kakaogame.KGTGoogleGamesAchievements;KGTKakaoInvitation; // [TODO] Event Id. int eventId = 0; KGTKakaoInvitation.receiversCount(eventId, result -> { if (result.isSuccess()) { // 구글 게임 업적 정보 화면 보여주기 KGTGoogleGamesAchievements.showAchievement(activity); |
업적 달성
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTGoogleGamesAchievements;
// [TODO] 업적 아이디 설정
String id = "";
// 업적 달성
KGTGoogleGamesAchievements.unlock(id); |
업적 노출하기
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTGoogleGamesAchievements;
// [TODO] 업적 아이디 설정
String id = "";
KGTGoogleGamesAchievements.reveal(id); |
업적 단계 증가
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTGoogleGamesAchievements;
// [TODO] 업적 아이디 설정
String id = "";
int numSteps = 0;
KGTGoogleGamesAchievements.setSteps(id, numSteps); |
업적 단계 설정
...
코드 블럭 | ||
---|---|---|
| ||
import com.kakaogame.KGTGoogleGamesAchievements; // [TODO] 업적 아이디 설정 String id = ""; int numSteps = 0; KGTGoogleGamesAchievements.increment(id, numStepsSuccessfully retrieve the count of friends to whom I sent an invite message. // Retrieve the number of friends I have invited. KGTInvitationReceviersCountResponse response = result.getContent(); int total = response.getTotalReceiversCount(); int joinersCount = response.getJoinersCount(); } else if (result.getCode() == KGTResult.KGTResultCode.NOT_KAKAOTALK_USER) { // 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. } }); |