목차 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
초기화 및 상태변화 이벤트 처리
...
SDK 초기화
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" /** * Unreal Editor에 설정한 정보로 초기화 수행 */ FKGTApplication::InitSDK(); |
스타트 (Start) 하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FKGTApplication::Start(FKGTResultDelegate::CreateLambda([=](FKGTResult result) { if (result.IsSuccess()) { // 스타트가 성공 한 경우 // 자동로그인 여부 bool isLoggedIn = FKGTPlayer::IsLoggedIn(); if (isLoggedIn) { // 플랫폼에서 발급한 현재 Player의 ID FString playerId = FKGTPlayer::GetCurrentPlayer().GetPlayerId(); // 플랫폼 엑세스 토큰 FString accessToken = FKGTPlayer::GetAccessToken(); // 현재 IDP 인증 정보를 가져옴 FKGTIdpProfile idpProfile = FKGTPlayer::GetCurrentPlayer().GetIdpProfile(); // [TODO] 게임 화면으로 이동 합니다. } else { // [TODO] 자동로그인이 안 된 경우 로그인 화면으로 이동 합니다. } } else { // 스타트가 실패 한 경우 - 초기화가 실패한 경우 이므로 스타트를 재시도 하거나 앱을 종료 하여야 합니다. int32 resultCode = result.GetCode(); if (resultCode == FKGTResultCode::NetworkFailure || resultCode == FKGTResultCode::ServerTimeout || resultCode == FKGTResultCode::ServerConnectionFailed) { // [TODO] 네트워크 에러가 발생한 경우에는 유저에게 네트워크 이슈로 스타트에 실패했음을 알리고 재시도 } else { // [TODO] 나머지 에러가 발생한 경우에는 에러 안내 후 스타트 재시도 요청 하여야 합니다. - 문제가 반복해서 발생하는 경우 에러코드 및 로그 확인 후 원인 파악이 필요합니다. } } })); |
Pause 하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 게임이 백그라운드 상태 일 때 호출됩니다 (예 : 다른 앱으로 전환하거나 홈 버튼을 통해 종료) // ApplicationWillEnterBackgroundDelegate를 이용하여 SDK Pause가 호출 될 수 있도록 등록합니다. FCoreDelegates::ApplicationWillEnterBackgroundDelegate.AddUObject(this, &UApplicationWidget::Pause); FKGTApplication::Pause(FKGTResultDelegate::CreateLambda([=](FKGTResult result) { // result는 항상 성공(200) 응답을 반환합니다. })); |
Resume 하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 게임이 포그라운드로 돌아갈 때 호출됩니다 // ApplicationHasEnteredForegroundDelegate를 이용하여 SDK Resume이 호출 될 수 있도록 등록합니다. FCoreDelegates::ApplicationHasEnteredForegroundDelegate.AddUObject(this, &UApplicationWidget::Resume); FKGTApplication::Resume(FKGTResultDelegate::CreateLambda([=](FKGTResult result) { if (result.IsSuccess()) { // [TODO] resume이 성공 한 경우 게임 화면을 재개합니다. } else { // [TODO] resume이 실패 한 경우 인증 실패 면 로그인 화면으로, 그외의 경우는 에러 팝업을 띄우고 재시도 여부를 확인합니다. if (result.Code == FKGTResultCode::AuthFailure || result.Code == FKGTResultCode::IdpAuthFailure) { // [TODO] 인증 실패의 경우 시작 화면으로 이동해서 다시 신규 로그인 flow를 수행합니다. } else { // [TODO] 나머지 에러가 발생한 경우 경우 에러 안내 후 resume 을 재시도 합니다. - 반복해서 문제가 발생하는 경우 앱을 종료하도록 합니다. } } }); |
윈도우즈 환경에서 자동로그인 설정하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 자동로그인사용 유무를 세팅, 세팅하지 않으면 사용하지 않음 상태로 세팅 // 자동로그인사용설정으로 로그인이 성공하면 자동로그인정보가 생성됨 // 자동로그인정보가 존재하면 다음 KGTApplication의 start시에 자동로그인이 진행됨으로 자동로그인정보를 제거하려면 로그아웃을 진행해야함 bool useAutoLogin = true; FKGTApplication::SetUseAutoLogin(useAutoLogin); |
로그인
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
기본 로그인 UI를 사용하지 않는 로그인하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 로그인 하고자 하는 IdpCode 셋팅 EKGTIdpCode idpCode = EKGTIdpCode::Kakao; // 특정 idp로 로그인 하기 FKGTPlayer::Login(idpCode, FKGTResultDelegate::CreateLambda([=](FKGTResult result) { if (result.IsSuccess()) { // 플랫폼에서 발급한 현재 Player의 ID FString playerId = FKGTPlayer::GetCurrentPlayer().GetPlayerId(); // 플랫폼 엑세스 토큰 FString accessToken = FKGTPlayer::GetAccessToken(); // 현재 IDP 인증 정보를 가져옴 FKGTIdpProfile idpProfile = FKGTPlayer::GetCurrentPlayer().GetIdpProfile(); // [TODO] 로그인이 성공하였으므로 게임 화면으로 이동합니다. } else { // IDP 로그인 혹은 플랫폼 로그인 실패 // [TODO] 로그인 실패 시 사용자 안내 후 재 시도 하도록 하여야 합니다. int32 resultCode = result.GetCode(); if (resultCode == FKGTResultCode::NetworkFailure || resultCode == FKGTResultCode::ServerTimeout || resultCode == FKGTResultCode::ServerConnectionFailed) { // [TODO] 네트워크 에러가 발생한 경우에는 유저에게 네트워크 이슈로 스타트에 실패했음을 알리고 재시도 } else if (resultCode == FKGTResultCode::Forbidden) { // [TODO] CBT기간동안 허용된 유저외에는 인증이 불가능 할 수 있습니다. 유저에게 안내메시지 처리가 필요합니다. } else if (resultCode == FKGTResultCode::UserCanceled) { // [TODO] 사용자가 로그인 진행 중 취소한 상황이므로 로그인 화면을 유지 하여야 합니다. } else { // [TODO] 나머지 에러가 발생한 경우에는 에러 안내 후 로그인 재시도 요청 하여야 합니다. - 에러코드 및 로그 확인 후 원인 파악이 필요합니다. } } })); |
로그아웃
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
기본 로그아웃 UI를 사용하지 않는 로그아웃하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 로그아웃 요청 FKGTPlayer::Logout(FKGTResultDelegate::CreateLambda([=](FKGTResult result) { if (result.IsSuccess()) { // 로그아웃 성공 // [TODO] 시작 화면으로 돌아가기 } else { // 로그아웃 실패 } })); |
탈퇴
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
기본 탈퇴 UI를 사용하지 않는 탈퇴하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 탈퇴 요청 FKGTPlayer::Unregister(showUI, FKGTResultDelegate::CreateLambda([=](FKGTResult result) { if (result.IsSuccess()) { // 탈퇴 성공 // [TODO] 시작 화면으로 돌아가기 } else { // 탈퇴 실패 } })); |
계정 연결
...
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
기본 계정 연결 UI를 사용하지 않는 계정 연결하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 로그인 하고자 하는 IdpCode 셋팅 EKGTIdpCode idpCode = EKGTIdpCode:Kakao; // 특정 idp로 계정 연결 하기 FKGTPlayer::Connect(idpCode, FKGTResultDelegate::CreateLambda([=](FKGTResult result) { if (result.IsSuccess()) { // IDP 연결 성공 // Player ID 는 변경되지 않습니다. } else { // IDP 연결 실패 int32 resultCode = result.GetCode(); if (resultCode == FKGTResultCode::NotAuthorized) { // 현재 로그인이 안되어 있는 경우 } else if (resultCode == FKGTResultCode::InvalidState) { // 현재 인증 된 IDP 가 계정 연결 가능한 idp가 아닌 경우 } else if (resultCode == FKGTResultCode::AlreadyUsedIDPAccount) { // 이미 연결되어 있는 계정이 있는 경우 } else { // 기타 에러 발생 } } })); |
프로필
...
내 정보 조회하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FKGTPlayer player = FKGTPlayer::GetCurrentPlayer(); // 플랫폼 playerId FString playerId = player.GetPlayerId(); // 플랫폼 AccessToken FString accessToken = FKGTPlayer::GetAccessToken(); // idpProfile 정보 FKGTIdpProfile idpProfile = player.GetIdpProfile(); |
내 IDP 정보 조회하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FKGTPlayer player = FKGTPlayer::GetCurrentPlayer(); // IDP 정보 조회 FKGTIdpProfile idpProfile = player.GetIdpProfile(); EKGTIdpCode idpCode = idpProfile.GetIdpCode(); FString idpUserId = idpProfile.GetIdpUserId(); // 카카오 IDP 정보 조회 // 카카오 로그인 상태인 경우 if (idpCode == EKGTIdpCode::Kakao) { // 카카오 IDP 정보 조회 FKGTKakaoProfile *kakaoProfile = (FKGTKakaoProfile*)&idpProfile; // 카카오 UUID FString uuid = kakaoProfile->GetUUID(); // 다른 앱에서 동일한 카카오 유저인 경우 같은 그룹 유저 토큰을 반환 FString groupUserToken = kakaoProfile->GetGroupUserToken(); // 오늘 보낼 수 있는 남은 초대 수 int32 remainingInviteCount = kakaoProfile->GetRemainingInviteCount(); // 앱 가입 여부 bool isAppRegistered = kakaoProfile->IsAppRegistered(); // 메시지 수신 여부 bool isAllowedMessage = kakaoProfile->IsAllowedMessage(); } |
시스템 정보
...
언어 코드 가져오기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FString languageCode = FKGTSystem::GetLanguageCode(); |
국가 코드 가져오기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FString countryCode = FKGTSystem::GetCountryCode(); |
IP 기반 국가 코드 가져오기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FString geoCountryCode = FKGTSystem::GetGeoCountryCode(); |
기기 아이디 가져오기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FString deviceId = FKGTSystem::GetDeviceId(); |
기기 모델 가져오기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FString deviceModel = FKGTSystem::GetDeviceModel(); |
OS 이름 가져오기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FString osName = FKGTSystem::GetOSName(); |
네트워크 연결 여부 가져오기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" bool isNetworkConnected = FKGTSystem::IsNetworkConnected(); |
연결된 네트워크 타입 가져오기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" FString networkType = FKGTSystem::GetNetworkType(); |
카카오 연동 기능
...
카카오톡 게임 메시지 수신 여부 설정하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 카카오톡 게임 메시지 수신 여부 설정 뷰 띄우기 FKGTKakaoTalk::ShowSetting(FKGTResultWithIsAllowMeDelegate::CreateLambda([=](FKGTResult result, bool isAllowMe) { if (result.IsSuccess()) { // 카카오톡 게임 메시지 수신 여부 설정 성공 // isAllowMe - 설정된 메시지 수신 허용 여부 } else if (result.GetCode() == FKGTResultCode::NotKakaoTalkUser) { // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. (카카오톡 유저가 아닌 경우) } else { // 카카오톡 게임 메시지 수신 여부 설정 실패 } })); |
카카오톡 프로필 조회하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 카카오톡 프로필 조회하기 FKGTKakaoTalk::TalkProfile(FKGTResultWithKakaoTalkProfileDelegate::CreateLambda([=](FKGTResult result, FKGTKakaoTalkProfile profile) { if (result.IsSuccess()) { // 카카오톡 프로필 조회 성공 // profile - 로그인한 유저의 카카오톡 프로필 정보 } else if (result.GetCode() == FKGTResultCode::NotKakaoTalkUser) { // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. (카카오톡 유저가 아닌 경우) } else { // 카카오톡 프로필 조회 실패 } })); |
카카오톡 게임 친구 목록 조회하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // 게임 친구 목록 조회하기 FKGTKakaoTalk::Friends(FKGTResultWithPlayerListDelegate::CreateLambda([=](FKGTResult result, TArray<FKGTPlayer> playerList) { if (result.IsSuccess()) { // 카카오톡 게임 친구 목록 조회 성공. for (FKGTPlayer player : playerList) { FKGTIdpProfile idpProfile = player.GetIdpProfile(); FKGTKakaoFriendProfile *kakaoFriendProfile = (FKGTKakaoFriendProfile*)&idpProfile; } } else if (result.GetCode() == FKGTResultCode::NotKakaoTalkUser) { // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. (카카오톡 유저가 아닌 경우) } else { // 카카오톡 게임 친구 목록 조회 실패 } })); |
카카오톡 게임 메시지 보내기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // friends API를 통해 가져온 카카오 친구 프로필 FKGTKakaoFriendProfile *kakaoFriendProfile; // [TODO] 템플릿 Id 설정 FString templateId = TEXT(""); // [TODO] 메시지 템플릿에 설정한 인자 설정 TMap<FString, FString> argumentDic; argumentDic.Add(TEXT("${nickname}"), kakaoFriendProfile->GetNickname()) argumentDic.Add(TEXT("rog_link"), TEXT("test=100&hello=20111")); // 카카오톡 게임 메시지 보내기 FKGTKakaoTalk::SendGameMessage((*kakaoFriendProfile), templateId, argumentDic, FKGTResultDelegate::CreateLambda([=](FKGTResult result) { if (result.IsSuccess()) { // 카카오톡 채팅 메시지 보내기 성공 } else { if (result.GetCode() == FKGTResultCode::MessageSettingDisabled) { // 받은이가 메시지 수신 거부를 설정한 경우 } else if (result.GetCode() == FKGTResultCode::ExceedDailyUsage) { // 한명이 특정 앱에 대해 보낼 수 있는 하루 쿼터(받는 사람 관계없이) 초과시 발생 } else if (result.GetCode() == FKGTResultCode::ExceedMonthlyUsage) { // 한명이 특정 앱에 대해 특정인에게 보낼 수 있는 한달 쿼터 초과시 발생 } else { // 카카오톡 채팅 메시지 보내기 실패 } } })); |
카카오톡 친구 초대 메시지 전송하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // [TODO] 팝업창으로 띄울지 여부 설정 bool isSingle = true; // [TODO] 팝업창으로 띄울지 여부 설정 bool isPopup = true; // [TODO] 템플릿 Id 설정 FString templateId = TEXT(""); // [TODO] 메시지 템플릿에 설정한 인자 설정 TMap<FString, FString> argumentDic; argumentDic.Add(TEXT("${nickname}"), TEXT("nickname")); FKGTKakaoTalk::SendInviteMessage(isSingle, isPopup, templateId, argumentDic, FKGTResultWithKakaoUserListDelegate::CreateLambda([=](FKGTResult result, TArray<FKGTKakaoUser> users) { if (result.IsSuccess()) { // 카카오톡 초대 메시지 보내기 성공 for (FKGTKakaoUser user : users) { // 유저가 초대 메시지를 전송한 유저 목록 확인 } } else { // 전부 실패한 경우(공통된 원인 리턴해주기 필요) if (result.GetCode() == FKGTResultCode::MessageSettingDisabled) { // 받은이가 메시지 수신 거부를 설정한 경우 } else if (result.GetCode() == FKGTResultCode::ExceedDailyUsage) { // 한명이 특정 앱에 대해 보낼 수 있는 하루 쿼터(받는 사람 관계없이) 초과시 발생 } else if (result.GetCode() == FKGTResultCode::ExceedMonthlyUsage) { // 한명이 특정 앱에 대해 특정인에게 보낼 수 있는 한달 쿼터 초과시 발생 } else { // 카카오톡 채팅 메시지 보내기 실패 } } })); |
카카오톡 채널 추가하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // [TODO] 채널 Id 설정 int32 channelId = 0; FKGTKakaoTalk::AddChannel(channelId, FKGTResultDelegate::CreateLambda([=](FKGTResult result) { if (result.IsSuccess()) { // 채널 추가 성공 } else if (result.GetCode() == FKGTResultCode::NotKakaoTalkUser) { // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. (카카오톡 유저가 아닌 경우) } else { // 채널 추가 실패 } })); |
내 초대 메시지로 가입한 친구 목록 조회하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
코드 블럭 | ||
---|---|---|
| ||
#include "KakaoGameV4.h" // [TODO] 이벤트 Id 설정 int32 eventId = 0; // 내가 초대한 플레이어 목록 조회하기 FKGTKakaoInvitation::Joiners(eventId, FKGTResultWithJoinersDelegate::CreateLambda([=](FKGTResult result, TArray<FKGTPlayer> players) { if (result.IsSuccess()) { // 내가 초대한 플레이어 목록 가져오기 for (FKGTPlayer player : players) { // 수신자의 플레이어 아이디 FString playerId = player.GetPlayerId(); FKGTIdpProfile idpProfile = player.GetIdpProfile(); FKGTKakaoFriendProfile *kakaoProfile = (FKGTKakaoFriendProfile*)&idpProfile; // 수신자의 닉네임 FString nickname = kakaoProfile->GetNickname(); // 수신자의 프로필 썸네일 이미지 FString thumbnailImageUrl = kakaoProfile->GetThumbnailImageUrl(); // 수신지의 탈퇴 이력 조회. UI상에서 탈퇴 여부 정보를 표시할 경우 해당 flag를 사용. bool isUnregistered = kakaoProfile->IsUnregistered(); } } else if (result.GetCode() == FKGTResultCode::NotKakaoTalkUser) { // 로그인 한 유저가 '카카오톡' 유저가 아닙니다. (카카오톡 유저가 아닌 경우) } else { // 호출 실패 } })); |
내가 초대 메시지를 보낸 친구 숫자 조회하기
발췌문 삽입 | ||||||||
---|---|---|---|---|---|---|---|---|
|
...