...
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Displaying the setting view for KakaoTalk game message receipt
kgKakaoTalkMessage.showAllowMessageSettingView([this](KakaoGame::Data::KGResult result, bool isAllowedMessage) {
if (result.isSuccess()) {
// KakaoTalk game message receipt setup successful
bool allowMessage = isAllowedMessage; // Configured message receipt option
}
else {
// KakaoTalk game message receipt setup failed
}
}, reinterpret_cast<HWND>(GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetOSWindowHandle()); |
|
23.1.2. Querying KakaoTalk Game Friend List
This section shows an example of a query of the KakaoTalk game friend list.
UnityUnreal
using Kakaogame.SDK;
KGPlayer.LoadFriendPlayers(
(result, players) => {
if (result.isSuccess) {
// Query of#include "KakaoGame.h"
// Displaying the setting view for KakaoTalk game |
|
friendlist successful.
foreach(var player in players) {
var kakaoProfile = (KGKakaoProfile)player.idpProfilereceipt
FKGKakaoTalkMessage::ShowAllowMessageSettingView(FKGResultWithMessageAllowedValueDelegate::CreateLambda([=](FKGResult result, bool isAllowedMessage) {
if (result.IsSuccess())
{
// KakaoTalk game message receipt setup successful
bool allowMessage = isAllowedMessage; // |
|
Usedforsendinga game message
} else Query offriendlist. Android
...
23.1.2. Querying KakaoTalk Game Friend List
This section shows an example of a query of the KakaoTalk game friend list.
Unity
코드 블럭 |
---|
using Kakaogame.SDK;
KGPlayer.LoadFriendPlayers(
(result, players) => {
if (result.isSuccess |
|
()Requestsuccessful //Friend
List<KGPlayer> friendList successful.
foreach(var player in players) {
var kakaoProfile = |
|
result.getContent);
for (KGPlayer player : friendList) {
KGKakaoProfile profile = (KGKakaoProfile) player.getIdpProfile()KGKakaoProfile)player.idpProfile; // Used for sending a game message
}
} |
|
else RequestQuery of KakaoTalk game friend list failed.
}
|
|
}
iOSAndroid
#import <KakaoGameKakaoGame.h>
// Querying KakaoTalk Game Friend List
|
|
[KGPlayer loadFriendPlayersWithCompletionHandler:^(NSError *error, NSArray *playersKGPlayer.loadFriendPlayers(new KGResultCallback<List<KGPlayer>>() {
@Override
public void onResult(KGResult<List<KGPlayer>> result) {
|
|
if (IS_SUCCESS(error) == YES)
{
if (result.isSuccess()) {
// |
|
QueryofKakaoTalkgamefriend successful
for
List<KGPlayer> friendList = result.getContent();
for (KGPlayer |
|
*inplayers KGKakaoProfile*kakaoProfileprofile = (KGKakaoProfile) |
|
*)idpProfilegetIdpProfile(); // Used for sending a game message |
|
. }
else
Queryof KakaoTalk game friend list failed
] Windows SynciOS
#include "KakaoGameLib.h"
KakaoGame::Data::KGResult result;
std::vector<KakaoGame::Data::KGPlayer> players;
KakaoGame::API::KGPlayer kgPlayer;#import <KakaoGame/KakaoGame.h>
// Querying KakaoTalk Game Friend List |
|
kgPlayer.loadFriendPlayers(result, players);
if (result.isSuccess()) {
[KGPlayer loadFriendPlayersWithCompletionHandler:^(NSError *error, NSArray *players) {
if (IS_SUCCESS(error) == YES)
{
// Query of KakaoTalk game friend list successful
|
|
for (KakaoGame::Data::: KakaoGame::Data::KGKakaoProfile KGKakaoProfile *kakaoProfile = (KGKakaoProfile *)player. |
|
kakaoProfile게임메시지전송시사용}else // Query of KakaoTalk game friend list failed
}
}]; |
|
Windows AsyncSync
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::Data::KGResult result;
std::vector<KakaoGame::Data::KGPlayer> players;
KakaoGame::API::KGPlayer kgPlayer;
// Querying KakaoTalk Game Friend List
kgPlayer.loadFriendPlayers |
|
([this]KakaoGame::Data::KGResult std::vector<KakaoGame::Data::KGPlayer> players) {
if players);
if (result.isSuccess()) {
|
|
// Query of KakaoTalk game friend list successful
|
|
for for (KakaoGame::Data::KGPlayer player : players) {
|
|
KakaoGame KakaoGame::Data::KGKakaoProfile kakaoProfile = player.kakaoProfile; // 게임 메시지 전송시 사용.
|
|
else // Query of KakaoTalk game friend list failed
|
|
});23.1.3. Sending a KakaoTalk Game Message
This section shows an example of KakaoTalk game message sending. (Guide : 20. Kakaotalk Message Template V2 )
If you want to receive certain parameters when entering the game by touching the received message, you can set and use the exec parm in the message template.
When you receive the message with KakaoTalk and touch the link to the app, the app is executed and the exec param is passed.
You can use this value to start a specific stage or pay a predefined item. The exec parm can only use game messages.
Unity Example
코드 블럭 |
using Kakaogame.SDK;
KGKakaoProfile Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::API::KGPlayer kgPlayer;
// Querying KakaoTalk Game Friend List
kgPlayer.loadFriendPlayers([this](KakaoGame::Data::KGResult result, std::vector<KakaoGame::Data::KGPlayer> players) {
if (result.isSuccess()) {
// Query of KakaoTalk game friend list successful
for (KakaoGame::Data::KGPlayer player : players) {
KakaoGame::Data::KGKakaoProfile kakaoProfile = player.kakaoProfile; // 게임 메시지 전송시 사용.
}
}
else {
// Query of KakaoTalk game friend list failed
}
}); |
|
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
// Querying KakaoTalk Game Friend List
FKGPlayer::LoadFriendPlayers(FKGResultWithPlayersCallback::CreateLambda([=](FKGResult result, TArray<FKGPlayer> players) {
if (result.IsSuccess())
{
// Query of KakaoTalk game friend list successful
for (FKGPlayer player : players)
{
FKGIdpProfile idpProfile = player.GetIdpProfile();
FKGKakaoProfile *kakaoProfile = (FKGKakaoProfile*)&idpProfile;
}
}
else
{
// Query of KakaoTalk game friend list failed
}
})); |
|
23.1.3. Sending a KakaoTalk Game Message
This section shows an example of KakaoTalk game message sending. (Guide : 20. Kakaotalk Message Template V2 )
If you want to receive certain parameters when entering the game by touching the received message, you can set and use the exec parm in the message template.
When you receive the message with KakaoTalk and touch the link to the app, the app is executed and the exec param is passed.
You can use this value to start a specific stage or pay a predefined item. The exec parm can only use game messages.
Unity Example
코드 블럭 |
---|
using Kakaogame.SDK;
KGKakaoProfile kakaoProfile; // Kakaotalk profile(KGKakaoProfile Object)
// Check if the user allows to receive a game message
if (kakaoProfile.isAllowedMessage == false)
{
// The user doesn't allow to receive a game message. Don't send the message.
return;
}
string templateId = "4101";
Dictionary<string, object> argumentDic = new Dictionary<string, object>() {
{"nickname", "kakao_nickname"}
};
KGKakaoTalkMessage.SendNewGameMessage(
kakaoProfile,
templateId,
argumentDic,
(result) => {
if (result.isSuccess) {
// kakaoTalk game message sent successfully.
}
else if (result.code == KGResultCode.MessageSettingDisabled) {
// If the recipient has opted-out of the message.
}
else if (result.code == KGResultCode.ExceedDailyUsage) {
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
}
else if (result.code == KGResultCode.ExceedMonthlyUsage) {
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
}
else {
// KakaoTalk game message sent fail.
}
}); |
|
Android Example
코드 블럭 |
---|
// [TODO] Get my Kakao profile information from my Friends list
KGKakaoProfile kakaoProfile;
// Check if the user allows to receive a game message
if (kakaoProfile.isAllowedMessage() == false) {
// The user doesn't allow to receive a game message. Don't send the message.
return;
}
// [TODO] Set game message template ID
String templateId;
// [TODO] Add required arguments
Map<String, String> args = new LinkedHashMap<String, String>();
String nickname = ((KGKakaoProfile)KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
args.put("${sender_name}", nickname);
// Send a Kakaotalk game message
KGKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, args, new KGResultCallback<Boolean>() {
@Override
public void onResult(KGResult<Boolean> result) {
if (result.isSuccess()) {
// kakaoTalk game message sent successfully.
} else {
// KakaoTalk game message sent fail
if (result.getCode() == KGResult.KGResultCode.MESSAGE_SETTING_DISABLE) {
// If the recipient has opted-out of the message.
} else if (result.getCode() == KGResult.KGResultCode.EXCEED_DAILY_USAGE) {
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
} else if (result.getCode() == KGResult.KGResultCode.EXCEED_MONTHLY_USAGE) {
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
} else {
// etc
}
}
}
}); |
|
iOS Example
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// [TODO] Get my Kakao profile information from my Friends list
KGKakaoProfile *kakaoProfile; // Kakaotalk profile |
|
(KGKakaoProfile Object)
(KGKakaoProfile Object)
if (kakaoProfile.isAllowedMessage == NO)
{
// |
|
Checkiftheuserallows to receive Send a game message |
|
if (kakaoProfile.isAllowedMessage == false)
{
// The user doesn't allow to receive. Don't send the message.
return;
}
// [TODO] Set game message template ID
NSString *templateId = @"4101";
// [TODO] Add required arguments
NSDictionary* argumentDic = @{@"msg":@"This is a game message. |
|
Don't send the message.
return;
}
string templateId = "4101";
Dictionary<string, object> argumentDic = new Dictionary<string, object>() {
{"nickname", "kakao_nickname"}
};
KGKakaoTalkMessage.SendNewGameMessage(
kakaoProfile,
templateId,
argumentDic,
(result) => {
if (result.isSuccess) {
", @"iphoneMarketParam":@"test", @"iphoneExecParam":@"test", @"sender_name" : @"iOSTester"};
// Send a Kakaotalk game message
[KGKakaoTalkMessage sendNewGameMessageWithKakaoProfile:kakaoProfile
templateId:templateId
argumentDic:argumentDic
completionHandler:^(NSError *error) {
if (IS_SUCCESS(error) == YES)
{
// kakaoTalk game message sent successfully.
|
|
}
else if (result }
else
{
// KakaoTalk game message sent fail
if (error.code == |
|
KGResultCode.MessageSettingDisabledKGErrorMessageSettingDisabled)
{
// If the recipient has opted-out of the message.
}
else if ( |
|
resultKGResultCode.ExceedDailyUsageKGErrorExceedDailyUsage)
{
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
}
else if ( |
|
resultKGResultCode.ExceedMonthlyUsageKGErrorExceedMonthlyUsage)
{
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
}
|
|
else KakaoTalk game message sent fail.)Android ExampleWindows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] |
|
GetmyKakaoinformation from my Friends list
KGKakaoProfile kakaoProfile;
// Check if the user allows to receive a game message
if (kakaoProfile.isAllowedMessage() == falseobject
KakaoGame::Data::KGLocalPlayer localPlayer;
// [TODO] Get my Kakao profile information from my Friends list
KakaoGame::Data::KGKakaoProfile kakaoProfile;
if (false == kakaoProfile.allowedMessage) {
// The user doesn't allow to receive Send a game message. Don't send the message.
return;
}
// [TODO] Set game message template ID
|
|
Stringstd::wtring templateId;
// [TODO] Add required arguments
|
|
Map<StringString> args = new LinkedHashMap<String, String>();
String nickname = ((KGKakaoProfile)KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
args.putstd::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${sender_name}"), localPlayer.kakaoProfile.nickname));
KakaoGame::Data::KGResult result; |
|
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Send a Kakaotalk game message
|
|
KGKakaoTalkMessagekgKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, |
|
args, new KGResultCallback<Boolean>() {
@Override
public void onResult(KGResult<Boolean>{
if if (result.isSuccess()) {
|
|
// kakaoTalk game message sent successfully.
|
|
else // KakaoTalk game message sent fail
|
|
if getCode()KGResult.KGResultCode.MESSAGE_SETTING_DISABLEKakaoGame::Data::KGResultCode::MessageSettingDisabled) {
|
|
// If the recipient has opted-out of the message.
|
|
getCode()KGResult.KGResultCode.EXCEED_DAILY_USAGEKakaoGame::Data::KGResultCode::ExceedDailyUsage) {
|
|
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
|
|
getCode()KGResult.KGResultCode.EXCEED_MONTHLY_USAGEKakaoGame::Data::KGResultCode::ExceedMonthlyUsage) {
|
|
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
|
|
}
}
});iOS Example
코드 블럭 |
#import <KakaoGame/KakaoGame.h>Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Bring your own profile object
KakaoGame::Data::KGLocalPlayer localPlayer;
// [TODO] Get my Kakao profile information from my Friends list
KakaoGame::Data::KGKakaoProfile |
|
* //Kakaotalk profile(KGKakaoProfile Object)
kakaoProfile.isAllowedMessage NOkakaoProfile.allowedMessage) {
// The user doesn't allow to receive Send a game message. Don't send the message.
return;
}
// [TODO] Set game message template ID
|
|
NSString* = @"4101";
// [TODO] Add required arguments
|
|
NSDictionary* argumentDic = @{@"msg":@"This is a game message.", @"iphoneMarketParam":@"test", @"iphoneExecParam":@"test", @"sender_name" : @"iOSTester"};
std::map<std::wstring, std::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${sender_name}"), localPlayer.kakaoProfile.nickname));
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Send a Kakaotalk game message
|
|
[KGKakaoTalkMessage sendNewGameMessageWithKakaoProfile:kakaoProfile
templateId:templateId
argumentDic:argumentDic
completionHandler:^(NSError *errorkgKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, arguments, [this](KakaoGame::Data::KGResult result) {
if ( |
|
IS_SUCCESS(error) == YES {
// kakaoTalk game message sent successfully.
}
|
|
else
else {
// KakaoTalk game message sent fail
if ( |
|
errorKGErrorMessageSettingDisabledKakaoGame::Data::KGResultCode::MessageSettingDisabled) |
|
{
// If the recipient has opted-out of the message.
} |
|
else if errorKGErrorExceedDailyUsageKakaoGame::Data::KGResultCode::ExceedDailyUsage) |
|
{
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
} |
|
else if errorKGErrorExceedMonthlyUsageKakaoGame::Data::KGResultCode::ExceedMonthlyUsage) |
|
{
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app. |
|
}
else]Windows SyncUnreal
KakaoGameLib
// [TODO] Bring your own profile object
KakaoGame::Data::KGLocalPlayer localPlayer;
// [TODO] Get my Kakao profile information from my Friends list
KakaoGame::Data::KGKakaoProfile kakaoProfile;
if (false == kakaoProfile.allowedMessage) {
// The user doesn't allow to receive Send a game message. Don't send the message.
return;
}
// [TODO] Set game message template ID
std::wtring templateId;
// [TODO] Add required arguments
std::map<std::wstring, std::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${sender_name}"), localPlayer.kakaoProfile.nickname));
KakaoGame::Data::KGResult result;
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Send a Kakaotalk game message
kgKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, arguments, result);
if (result.isSuccess()) {
// kakaoTalk game message sent successfully.
}
else
// [TODO] Get my Kakao profile information from my Friends list
FKGKakaoProfile kakaoProfile; // Kakao Profile(FKGKakaoProfile Object)
// Check if the user allows to receive a game message
if (kakaoProfile.IsAllowedMessage() == false)
{
// The user doesn't allow to receive a game message. Don't send the message.
return;
}
FString templateId = TEXT("4101");
TMap<FString, FString> argumentMap;
argumentMap.Add(TEXT("nickname"), TEXT("kakao_nickname"));
FKGKakaoTalkMessage::SendNewGameMessage(kakaoProfile, templateId, argumentMap, FKGResultDelegate::CreateLambda([=](FKGResult result) {
if (result.IsSuccess())
{
// kakaoTalk game message sent successfully.
}
else if (result.GetCode() == FKGResultCode::MessageSettingDisabled)
{
// If the recipient has opted-out of the message.
}
else if (result.GetCode() == FKGResultCode::ExceedDailyUsage)
{
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
}
else if (result.GetCode() == FKGResultCode::ExceedMonthlyUsage)
{
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
}
else
{
// KakaoTalk game message sent fail |
|
if (result.code == KakaoGame::Data::KGResultCode::MessageSettingDisabled) {
// If the recipient has opted-out of the message.
} else if (result.code == KakaoGame::Data::KGResultCode::ExceedDailyUsage) {
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
} else if (result.code == KakaoGame::Data::KGResultCode::ExceedMonthlyUsage) {
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
} else {
// etc
}
}
Windows Async
코드 블럭 |
#include "KakaoGameLib.h"
// [TODO] Bring your own profile object
KakaoGame::Data::KGLocalPlayer localPlayer;
23.1.4. Sending a KakaoTalk game image message
This is an example of sending a KakaoTalk game image message. (Guide :20. Kakaotalk Message Template V2 )
정보 |
---|
[Android] Using a dangerous permission feature If you want to use this feature, you need to add the READ_EXTERNAL_STORAGE permission to Android Manifest. Android 6.0+ games may use this feature after the user's permission is obtained, using the guide on the notification of individual rights and right request. |
Unity Example
코드 블럭 |
---|
using Kakaogame.SDK;
KGKakaoProfile kakaoProfile; // Kakaotalk profile(KGKakaoProfile Object)
// Check if the user allows to receive a game message
if (kakaoProfile.isAllowedMessage == false)
{
// The user doesn't allow to receive a game message. Don't send the message.
return;
}
// [TODO] |
|
GetmyKakaoprofile information from my Friends list
KakaoGame::Data::KGKakaoProfile kakaoProfile;
if (false == kakaoProfile.allowedMessage) {
// The user doesn't allow to receive Send a game message. Don't send the message.
return;
}
// [TODO] Set game message template ID
std::wtring templateId;
// [TODO] Add required arguments
std::map<std::wstring, std::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT(Texture2D file;
// Upload an image to get the image url
KGKakaoTalk.UploadGameImage(file, (result, imageUrl) => {
if (result.isSuccess)
{
// Pass in the key specified in the message template
string templateId = "4101";
string nickname = ((KGKakaoProfile)KGLocalPlayer.currentPlayer.idpProfile).nickname;
Dictionary<string, object> argumentDic = new Dictionary<string, object>() {
{"${sender_name}" |
|
)localPlayer.kakaoProfile.nickname));
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Send a Kakaotalk game message
kgKakaoTalkMessage.sendNewGameMessagenickname}
{"${first_image}", imageUrl}
};
KGKakaoTalkMessage.SendNewGameMessage(kakaoProfile, templateId, |
|
arguments[this]KakaoGame::Data::KGResult if () // kakaoTalk game message sent successfully.
|
|
else {
// KakaoTalk game message sent fail
if KakaoGame::Data::KGResultCode::KGResultCode.MessageSettingDisabled)
{
|
|
// If the recipient has opted-out of the message.
|
|
else if KakaoGame::Data::KGResultCode::KGResultCode.ExceedDailyUsage)
{
|
|
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
|
|
else if KakaoGame::Data::KGResultCode::KGResultCode.ExceedMonthlyUsage)
{
|
|
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
|
|
} else {
}
else if (result.code == KGResultCode.NotKakaoTalkUser)
{
// |
|
etc
}
}
});23.1.4. Sending a KakaoTalk game image message
This is an example of sending a KakaoTalk game image message. (Guide :20. Kakaotalk Message Template V2 )
정보 |
---|
[Android] Using a dangerous permission feature If you want to use this feature, you need to add the READ_EXTERNAL_STORAGE permission to Android Manifest. Android 6.0+ games may use this feature after the user's permission is obtained, using the guide on the notification of individual rights and right request. |
Unity Example
코드 블럭 |
---|
using Kakaogame.SDK;
KGKakaoProfile kakaoProfile; // Kakaotalk profile(KGKakaoProfile Object)
// Check if the user allows to receive a game messageThe logged-in user is not a "Kakao Talk" user. If you are not a KakaoTalk user with the account of a user who has just registered a cacao story.
}
else
{
// etc
}
});
}
else
{
// Image upload failed
}
}); |
|
Android Example
코드 블럭 |
---|
// [TODO] Get my Kakao profile information from my Invite Friends list
KGKakaoProfile kakaoProfile;
if (kakaoProfile.isAllowedMessage == |
|
false NO)
{
// The user doesn't allow to receive Send a game message. Don't send the message.
return;
}
// [TODO] Set game message template ID
String templateId;
// [TODO] Set image file
File file;
// Upload an image |
|
file
Texture2D file;
// Upload an image to get the image url
KGKakaoTalk.UploadGameImage(file, (result, imageUrl) => {
if (result.isSuccess)
{
// Pass in the key specified in the message template
string templateId = "4101";
string nickname to get the image url
KGKakaoTalk.uploadGameImage(file, new KGResultCallback<String>() {
@Override
public void onResult(KGResult<String> result) {
if (result.isSuccess()) {
// The url of the uploaded image
imageUrl = result.getContent();
} else {
// Image upload failed
}
}
});
// [TODO] Add required arguments to invitation message
Map<String, String> args = new LinkedHashMap<String, String>();
String nickname = ((KGKakaoProfile)KGLocalPlayer. |
|
currentPlayer.idpProfilegetCurrentPlayer().getIdpProfile()). |
|
nickname Dictionary<string, object> argumentDic = new Dictionary<string, object>() {
{"${sender_name}", nickname}
{"${first_image}", imageUrl}
};
KGKakaoTalkMessage.SendNewGameMessageargs.put("${sender_name}", nickname);
args.put("${first_image}", imageUrl); // Pass in the key specified in the message template
// Send a Kakaotalk game message
KGKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, |
|
argumentDicargs, new KGResultCallback<Boolean>() {
@Override
public void onResult(KGResult<Boolean> result) |
|
=> if // kakaoTalk game message sent successfully.
|
|
}
else if (result.code == KGResultCode.MessageSettingDisabled)
{
// If the recipient has opted-out of the message.
}
else if (result.code } else {
// KakaoTalk game message sent fail
if (result.getCode() == KGResult.KGResultCode. |
|
ExceedDailyUsage Occurswhenthereis a day's quota (regardlessrecipient) that one person can send for a particular app.
}
else if (result.codethe message.
} else if (result.getCode() == KGResult.KGResultCode. |
|
ExceedMonthlyUsage one monthexceedsmonthday's quota (regardless of recipient) that |
|
a specificto
else if codegetCode() == KGResult.KGResultCode. |
|
NotKakaoTalkUser Thelogged-inuserisnot"Kakao Talk" user. If you are notKakaoTalkuserwiththe account of a user who has just registeredcacaostory }
else
});
}
else
{
// Image upload failed
Android iOS Example
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// [TODO] Get my Kakao profile information from my Invite Friends list
KGKakaoProfile *kakaoProfile; // Kakaotalk profile(KGKakaoProfile Object)
if (kakaoProfile.isAllowedMessage == NO)
{
// The user doesn't allow to receive Send |
|
a game message. Don't send the message.
return;
}
// [TODO] SettemplateIDStringtemplateId }
// [TODO] Set image file
|
|
FileUIImage* file;
// Upload an image to get the image url
[KGKakaoTalk |
|
.(file, new KGResultCallback<String>() {
@Override
public void onResult(KGResult<String> result:file completionHandler:^(NSError *error, NSString *imageUrl) {
|
|
if (result.isSuccess()) {
// The url of the uploaded image
imageUrl = result.getContent();
} else {
// Image upload failed
}
}
});
// [TODO] Add required arguments to invitation message
Map<String, String> args = new LinkedHashMap<String, String>();
String nickname = ((KGKakaoProfile)KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
args.put("${sender_name}", nickname);
args.put("${first_image}", imageUrl); // Pass in the key specified in the message template
// Send a Kakaotalk game message
KGKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, args, new KGResultCallback<Boolean>() {
@Override
public void onResult(KGResult<Boolean> result) {
if (result.isSuccess()) {
// kakaoTalk game message sent successfully.
} else {
// KakaoTalk game message sent fail
if (result.getCode() == KGResult.KGResultCode.MESSAGE_SETTING_DISABLE) {
// If the recipient has opted-out of the message.
} else if (result.getCode() == KGResult.KGResultCode.EXCEED_DAILY_USAGE) {
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
} else if (result.getCode() == KGResult.KGResultCode.EXCEED_MONTHLY_USAGE) {
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
} else {
// etc
}
}
}
});iOS Example
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h> if (IS_SUCCESS(error) == YES)
{
// Pass in the key specified in the message template
NSString* templateId = @"4101";
NString* nickname = kakaoProfile.nickname;
NSDictionary* argumentDic = @{@"${sender_name}":nickname, @"${first_image}":imageUrl};
[KGKakaoTalkMessage sendNewGameMessageWithKakaoProfile:kakaoProfile templateId:templateId argumentDic:argumentDic completionHandler:^(NSError* error) {
if (IS_SUCCESS(error) == YES)
{
// kakaoTalk game message sent successfully.
}
else
{
// 카카오톡 게임 메시지 보내기 실패
if (error.code == KGErrorMessageSettingDisabled)
{
// If the recipient has opted-out of the message.
}
else if (error.code == KGErrorExceedDailyUsage)
{
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
}
else if (error.code == KGErrorExceedMonthlyUsage)
{
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
}
else if (error.code == KGErrorNotKakaoTalkUser)
{
// The logged-in user is not a "Kakao Talk" user. If you are not a KakaoTalk user with the account of a user who has just registered a cacao story.
}
else
{
// etc
}
}
}];
}
else
{
// Image upload failed
}
}]; |
|
Windows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Bring your own profile object
KakaoGame::Data::KGLocalPlayer localPlayer;
// [TODO] Get my Kakao profile information from my |
|
Invite Friends list
KakaoGame::Data::KGKakaoProfile |
|
* // Kakaotalk profile(KGKakaoProfileObject)
kakaoProfile.isAllowedMessage NOkakaoProfile.allowedMessage) {
// The user doesn't allow to receive Send a game message. Don't send the message.
return;
}
// [TODO] Set image file
|
|
UIImage* file;
// Upload an image to get the image url
[KGKakaoTalk uploadGameImage:file completionHandler:^(NSError *error, NSString *imageUrl) {
if (IS_SUCCESS(error) == YES)
{
//std::wtring image;
KakaoGame::Data::KGResult result;
std::wstring imageUrl;
KakaoGame::API::KGKakaoTalk kgKakaoTalk;
kgKakaoTalk.uploadGameImage(image, result, imageUrl);
if (false == result.isSuccess()) {
// Image upload failed
return;
}
// [TODO] Pass in the key specified in the message template
|
|
NSString*= @"4101";
NString* nickname = kakaoProfile.nickname;
NSDictionary* argumentDic = @{@// [TODO] Add required arguments
std::map<std::wstring, std::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${sender_name}" |
|
:nickname, @), localPlayer.kakaoProfile.nickname));
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${first_image}" |
|
:imageUrl};
[KGKakaoTalkMessage sendNewGameMessageWithKakaoProfile:kakaoProfile templateId:templateId argumentDic:argumentDic completionHandler:^(NSError* error) {
if (IS_SUCCESS(error) == YES)
{
), imageUrl));
KakaoGame::Data::KGResult result;
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Send a Kakaotalk game message
kgKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, arguments, result);
if (result.isSuccess()) {
// kakaoTalk game message sent successfully.
|
|
else
if errorKGErrorMessageSettingDisabledKakaoGame::Data::KGResultCode::MessageSettingDisabled) |
|
// If the recipient has opted-out of the message.
|
|
else if errorKGErrorExceedDailyUsageKakaoGame::Data::KGResultCode::ExceedDailyUsage) |
|
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
|
|
else if errorKGErrorExceedMonthlyUsageKakaoGame::Data::KGResultCode::ExceedMonthlyUsage) |
|
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
|
|
else if errorKGErrorNotKakaoTalkUserKakaoGame::Data::KGResultCode::NotKakaoTalkUser) |
|
// The logged-in user is not a "Kakao Talk" user. If you are not a KakaoTalk user with the account of a user who has just registered a cacao story.
|
|
}
else
}
}
}];
else
{
// Imageupload failed
}];Windows SyncAsync
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Bring your own profile object
KakaoGame::Data::KGLocalPlayer localPlayer;
// [TODO] Get my Kakao profile information from my Friends list
KakaoGame::Data::KGKakaoProfile kakaoProfile;
if (false == kakaoProfile.allowedMessage) {
// The user doesn't allow to receive Send a game message. Don't send the message.
return;
}
// [TODO] Set image file
std::wtring image;
KakaoGame::Data::KGResult result;
std::wstring imageUrl;
KakaoGame::API::KGKakaoTalk kgKakaoTalk;
kgKakaoTalk.uploadGameImage(image, result, imageUrl);
if (false == result.isSuccess()) {
// Image upload failed
return;
}
// [TODO] Pass in the key specified in the message template
std::wtring templateId;
// [TODO] Add required arguments
std::map<std::wstring, std::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${sender_name}"), localPlayer.kakaoProfile.nickname));
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${first_image}"), imageUrl));
|
|
KakaoGame::Data::KGResult result;
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Send a Kakaotalk game message
kgKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, arguments, [this](KakaoGame::Data::KGResult result) |
|
;if if (result.isSuccess()) {
|
|
// kakaoTalk game message sent successfully.
}
|
|
else if if (result.code == KakaoGame::Data::KGResultCode::MessageSettingDisabled) {
|
|
// If the recipient has opted-out of the message.
|
|
} else if (result.code == KakaoGame::Data::KGResultCode::ExceedDailyUsage) {
|
|
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
|
|
} else if (result.code == KakaoGame::Data::KGResultCode::ExceedMonthlyUsage) {
|
|
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
|
|
} else if (result.code == KakaoGame::Data::KGResultCode::NotKakaoTalkUser) {
|
|
// The logged-in user is not a "Kakao Talk" |
|
user. If you are not a KakaoTalk user with the account of a who has just registered a cacao story.
} else {
// etc
}
}
Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Bring your own profile object
KakaoGame::Data::KGLocalPlayer localPlayer;
// [TODO] Get my Kakao profile information from my Friends list
KakaoGame::Data::KGKakaoProfile kakaoProfile;
if (false == kakaoProfile.allowedMessage) {
// The user doesn't allow to receive Send a game message. Don't send the message.
return;
}
If you are not a KakaoTalk user with the account of a user who has just registered a cacao story.
} else {
// etc
}
}
}); |
|
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
FKGKakaoProfile kakaoProfile;
// [TODO] Set image file
|
|
std::wtring imageKakaoGameDataUploadGameImage(imagePath, FKGResultWithImageUrlPathDelegate:: |
|
KGResultCreateLambda([=](FKGResult result |
|
;
std::wstring;
KakaoGame::API::KGKakaoTalk kgKakaoTalk;
kgKakaoTalk.uploadGameImage(image, result, imageUrl);
if (false == result.isSuccess()) {
) {
if (result.IsSuccess())
{
// Image upload |
|
failed return;} //[TODO]Passin the key specified in the message template
std::wtring templateId;
// [TODO] Add required arguments
std::map<std::wstring, std::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>= TEXT("4101");
// Send Message
TMap<FString, FString> argumentMap;
argumentMap.Add(TEXT("${sender_name}"), |
|
localPlayer.kakaoProfile.nicknamearguments.insert(std::pair<std::wstring, std::wstring> argumentMap.Add(TEXT("${first_image}"), TEXT("imageUrl")) |
|
;
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage //SendaKakaotalk game message
kgKakaoTalkMessage.sendNewGameMessage FKGKakaoTalkMessage::SendNewGameMessage(kakaoProfile, templateId, |
|
argumentsargumentMap, FKGResultDelegate::CreateLambda([ |
|
this](KakaoGame::Data::KGResult result) {
if (result.isSuccess()) {
=](FKGResult result) {
if (result.IsSuccess())
{
// kakaoTalk game message sent successfully.
|
|
else { //카카오톡게임메시지보내기실패 if codeKakaoGame::Data::KGResultCodeFKGResultCode::MessageSettingDisabled)
{ |
|
// If the recipient has opted-out of the message.
|
|
} else if codeKakaoGame::Data::KGResultCodeFKGResultCode::ExceedDailyUsage)
{ |
|
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
|
|
} else if codeKakaoGame::Data::KGResultCodeFKGResultCode::ExceedMonthlyUsage)
{ |
|
// Occurs when one month exceeds a month's quota that a specific person can send |
|
to a particular app.
} else if (result.code to a particular app.
}
else if (result.GetCode() == |
|
KakaoGameData::KGResultCode::
// The logged-in user is not a "Kakao Talk" user.
|
|
IfyouarenotaKakaoTalkuserwiththeaccountofauserwhohasjustregisteredacacaostory. } else {
}