...
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// Displaying the setting view for KakaoTalk game message receipt
[KGKakaoTalkMessage showAllowMessageSettingViewWithCompletionHandler:^(NSError *error, BOOL isAllowedMessage) {
if (IS_SUCCESS(error) == YES)
{
// KakaoTalk game message receipt setup successful
BOOL _isAllowedMessage = isAllowedMessage; // Configured message receipt option
}
else
{
// KakaoTalk game message receipt setup failed
}
}]; |
|
23.1.2. Querying KakaoTalk Game Friend List
This section shows an example of a query of the KakaoTalk game friend list.
Unity
...
Windows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::Data::KGResult result;
bool isAllowedMessage;
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Displaying the setting view for KakaoTalk game |
|
friendlistsuccessful.
foreach(var player in players) {
var kakaoProfile = (KGKakaoProfile)player.idpProfilekgKakaoTalkMessage.showAllowMessageSettingView(result, isAllowedMessage);
if (result.isSuccess()) {
// KakaoTalk game message receipt setup successful
bool allowMessage = isAllowedMessage; // |
|
Usedforsendingagame message
}
}
else {
// Query of}
else {
// KakaoTalk game |
|
friendlist. });...
Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// |
|
QueryingKakaoTalkGameFriendList
KGPlayer.loadFriendPlayers(new KGResultCallback<List<KGPlayer>>() {
@Override
public void onResult(KGResult<List<KGPlayer>> resultfor KakaoTalk game message receipt
kgKakaoTalkMessage.showAllowMessageSettingView([this](KakaoGame::Data::KGResult result, bool isAllowedMessage) {
|
|
if if (result.isSuccess()) {
|
|
Requestsuccessful //Friendlist List<KGPlayer> friendListresult.getContent();
for (KGPlayer player : friendList) {
KGKakaoProfile profile = (KGKakaoProfile) player.getIdpProfile(); // Used for sending a game message
}
} else {
// Request failed
}
}
});iOS
코드 블럭 |
#import <KakaoGame/KakaoGame.h>
// Querying KakaoTalk Game Friend List
[KGPlayer loadFriendPlayersWithCompletionHandler:^(NSError *error, NSArray *players) {
if (IS_SUCCESS(error) == YES)
{
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.
Unity
코드 블럭 |
---|
using Kakaogame.SDK;
KGPlayer.LoadFriendPlayers(
(result, players) => {
if (result.isSuccess) {
// Query of KakaoTalk game friend list successful.
|
|
forKGPlayer *player in players KGKakaoProfile*kakaoProfile = (KGKakaoProfile |
|
*)player.idpProfile; // Used for sending a game message |
|
. 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) {
Android
코드 블럭 |
---|
// Querying KakaoTalk Game Friend List
KGPlayer.loadFriendPlayers(new KGResultCallback<List<KGPlayer>>() {
@Override
public void onResult(KGResult<List<KGPlayer>> result) {
if (result.isSuccess()) {
// Request successful
// Friend list
List<KGPlayer> friendList = result.getContent();
for (KGPlayer player : friendList) {
KGKakaoProfile profile = (KGKakaoProfile) player.getIdpProfile(); // Used for sending a game message
}
} else {
// Request failed
}
}
}); |
|
iOS
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// Querying KakaoTalk Game Friend List
[KGPlayer loadFriendPlayersWithCompletionHandler:^(NSError *error, NSArray *players) {
if (IS_SUCCESS(error) == YES)
{
// Query of KakaoTalk game friend list successful
for(KGPlayer *player in players)
{
KGKakaoProfile *kakaoProfile = (KGKakaoProfile *)player.idpProfile; // Used for sending a game message.
}
}
else
{
// Query of KakaoTalk game friend list failed
}
}]; |
|
Windows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::Data::KGResult result;
std::vector<KakaoGame::Data::KGPlayer> players;
KakaoGame::API::KGPlayer kgPlayer;
// Querying KakaoTalk Game Friend List
kgPlayer.loadFriendPlayers(result, 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
}
|
|
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
}
}); |
|
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)
if (kakaoProfile.isAllowedMessage == NO)
{
// The user doesn't allow to receive Send a game message. 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.", @"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
{
// KakaoTalk game message sent fail
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
{
// etc
}
}
}]; |
|
Windows Sync
코드 블럭 |
---|
#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 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
{
// 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;
// [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::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Send a Kakaotalk game message
kgKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, arguments, [this](KakaoGame::Data::KGResult result) {
if (result.isSuccess()) {
// kakaoTalk game message sent successfully. |
|
}
else if
}
else {
// KakaoTalk game message sent fail
if (result.code == |
|
KGResultCode.KakaoGame::Data::KGResultCode::MessageSettingDisabled) {
// If the recipient has opted-out of the message.
} |
|
else if KGResultCode.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 KGResultCode.KakaoGame::Data::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;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] Set |
|
game message template ID
String templateId;
// [TODO] Add required arguments
Map<String, String> args = new LinkedHashMap<String, String>();
String nickname 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 = ((KGKakaoProfile)KGLocalPlayer. |
|
getCurrentPlayer().getIdpProfile()).getNickname();
args.put(currentPlayer.idpProfile).nickname;
Dictionary<string, object> argumentDic = new Dictionary<string, object>() {
{"${sender_name}", nickname |
|
);
// Send a Kakaotalk game message
KGKakaoTalkMessage.sendNewGameMessage}
{"${first_image}", imageUrl}
};
KGKakaoTalkMessage.SendNewGameMessage(kakaoProfile, templateId, |
|
args new KGResultCallback<Boolean>(){
@Override
public void onResultKGResult<Boolean> if () // kakaoTalk game message sent successfully.
|
|
} else {
// KakaoTalk game message sent fail
if (result.getCode() }
else if (result.code == KGResultCode.MessageSettingDisabled)
{
// If the recipient has opted-out of the message.
}
else if (result.code == |
|
KGResult.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.code == KGResultCode.ExceedMonthlyUsage)
{
// Occurs when one |
|
thereisday(regardlessofrecipient) that one for else if getCode()KGResult.EXCEED_MONTHLY_USAGE
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
} else {
// 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
}
}); |
|
iOS Android Example
#import <KakaoGame/KakaoGame.h>
// [TODO] Get my Kakao profile information from my Invite Friends list
KGKakaoProfile |
|
* // Kakaotalkprofile(KGKakaoProfile Object)
if (kakaoProfile.isAllowedMessage == 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 game message template ID
NSString *templateId = @"4101";
// [TODO] Add required arguments
NSDictionary* argumentDic = @{@"msg":@"This is a game message.", @"iphoneMarketParam":@"test", @"iphoneExecParam":@"test", @"sender_name" : @"iOSTester"}
// [TODO] Set image file
File file;
// Upload an image 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
}
}
});
// |
|
Send a Kakaotalk game[TODO] Add required arguments to invitation message
|
|
[KGKakaoTalkMessage sendNewGameMessageWithKakaoProfile:kakaoProfile
templateId:templateId
argumentDic:argumentDic
completionHandler:^(NSError *error) {
if (IS_SUCCESS(error) == YES)
{
// kakaoTalk game message sent successfully.
}
else
{
// KakaoTalk game message sent fail
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)
{
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 |
|
onemonth exceedsmonththataspecificpersoncansend to a particular app.
}
else
{
// 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 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 Invite Friends list
KGKakaoProfile *kakaoProfile; // Kakaotalk profile(KGKakaoProfile Object)
|
|
// Check if theuser allows to receive a game message
if (kakaoProfile.isAllowedMessage == |
|
false NO)
{
// The user doesn't allow to receive Send a game message. Don't send the message.
return;
}
// [TODO] Set image file
|
|
Texture2DUIImage* file;
// Upload an image to get the image url
|
|
KGKakaoTalk.UploadGameImage(file, (result, imageUrl) => {
if (result.isSuccess[KGKakaoTalk uploadGameImage:file completionHandler:^(NSError *error, NSString *imageUrl) {
if (IS_SUCCESS(error) == YES)
{
// Pass in the key specified in the message template
|
|
string templateId string nickname((KGKakaoProfile)KGLocalPlayer.currentPlayer.idpProfile). Dictionary<string, object> NSDictionary* argumentDic = |
|
new Dictionary<string, object>()
{@"${sender_name}":nickname, |
|
nickname}
{, };
KGKakaoTalkMessage.SendNewGameMessage(kakaoProfile, templateId, argumentDic, (result) => {
if (result.isSuccess[KGKakaoTalkMessage sendNewGameMessageWithKakaoProfile:kakaoProfile templateId:templateId argumentDic:argumentDic completionHandler:^(NSError* error) {
if (IS_SUCCESS(error) == YES)
{
// kakaoTalk game message sent successfully.
} |
|
else if (result
else
{
// 카카오톡 게임 메시지 보내기 실패
if (error.code == |
|
KGResultCode.MessageSettingDisabledKGErrorMessageSettingDisabled)
|
|
// If the recipient has opted-out of the message.
|
|
else if resultKGResultCode.ExceedDailyUsage // 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 if resultKGResultCode.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
{
// Image upload failed |
|
}
});Android Example
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 kakaoProfile;
if ( |
|
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
StringtemplateId;
File file;
// Upload an image to get the image url
KGKakaoTalk.uploadGameImage(file, new KGResultCallback<String>() {
@Override
public void onResult(KGResult<String> result) {
if (std::wtring image;
KakaoGame::Data::KGResult result;
std::wstring imageUrl;
KakaoGame::API::KGKakaoTalk kgKakaoTalk;
kgKakaoTalk.uploadGameImage(image, result, imageUrl);
if (false == result.isSuccess()) {
|
|
// The url of the uploaded image
imageUrl = result.getContent();
} else {
}
});Addrequiredargumentstoinvitation
Map<String, String> args = new LinkedHashMap<String, String>();
String nickname = ((KGKakaoProfile)KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
args.put 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));
|
|
args.putarguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${first_image}"), imageUrl));
|
|
// Pass in the key specified in the message template
KakaoGame::Data::KGResult result;
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Send a Kakaotalk game message
|
|
KGKakaoTalkMessagekgKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, |
|
args, new KGResultCallback<Boolean>arguments, result);
if (result.isSuccess()) { |
|
@Override
public void onResult(KGResult<Boolean> result) {
if (result.isSuccess()
// kakaoTalk game message sent successfully.
}
else {
// 카카오톡 게임 메시지 보내기 실패
if (result.code == KakaoGame::Data::KGResultCode::MessageSettingDisabled) {
|
|
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) {
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 |
|
thereisday quota (regardless of recipient)onefor getCode()KGResult.KGResultCode.EXCEED_MONTHLY_USAGEKakaoGame::Data::KGResultCode::NotKakaoTalkUser) {
|
|
Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
} else {
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
|
|
}
});...
Windows Async
#import <KakaoGame/KakaoGame.h>#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* templateId = @"4101";
NString* nickname = kakaoProfile.nickname;
NSDictionary* argumentDic = @{@"${sender_name}":nickname, @ 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}
[KGKakaoTalkMessage sendNewGameMessageWithKakaoProfile:kakaoProfile templateId:templateId argumentDic:argumentDic completionHandler:^(NSError* error) {
if (IS_SUCCESS(error) == YES)
{
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// Send a Kakaotalk game message
kgKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, arguments, [this](KakaoGame::Data::KGResult 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
{
// Image upload failed
}
}]