버전 비교

  • 이 줄이 추가되었습니다.
  • 이 줄이 삭제되었습니다.
  • 서식이 변경되었습니다.

...

코드 블럭
#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 
friend
message 
list
receipt
successful.             foreach(var player in players
kgKakaoTalkMessage.showAllowMessageSettingView(result, isAllowedMessage);
if (result.isSuccess()) {
                var kakaoProfile
    // KakaoTalk game message receipt setup successful
    bool allowMessage = 
(KGKakaoProfile)player.idpProfile
isAllowedMessage; // 
Used
Configured 
for
message 
sending a game message             }         }         else {             // Query of
receipt option
}
else {
    // KakaoTalk game 
friend
message 
list
receipt setup failed
.

        
}
    });

...

Windows Async

코드 블럭
#include "KakaoGameLib.h"
  
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
 
//
Querying
 Displaying the setting view for KakaoTalk 
Game
game 
Friend
message 
List
receipt
KGPlayer
kgKakaoTalkMessage.
loadFriendPlayers
showAllowMessageSettingView(
new KGResultCallback<List<KGPlayer>>() {     @Override     public void onResult(KGResult<List<KGPlayer>> result
[this](KakaoGame::Data::KGResult result, bool isAllowedMessage) {
        if 
    if (result.isSuccess()) {
            
        // 
Request
KakaoTalk 
successful
game 
 
message 
            //
receipt 
Friend
setup 
list
successful
            List<KGPlayer> friendList
        bool allowMessage = 
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
    }
}];

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) {             
isAllowedMessage; // Configured message receipt option
    }
    else {
        // KakaoTalk game message receipt setup failed
    }
}, reinterpret_cast<HWND>(GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetOSWindowHandle());

Unreal

코드 블럭
#include "KakaoGame.h"
  
// Displaying the setting view for KakaoTalk game message receipt
FKGKakaoTalkMessage::ShowAllowMessageSettingView(FKGResultWithMessageAllowedValueDelegate::CreateLambda([=](FKGResult 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
  }
}));

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.
            foreach(var player in players) {
                var kakaoProfile = (KGKakaoProfile)player.idpProfile; // Used for sending a game message
            }
        }
        else {
            // Query of KakaoTalk game friend list failed.
        }
    });

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
    }
});

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)
  
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 {
        // 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
        }
    }
});

Unreal

코드 블럭
#include "KakaoGame.h"
  
// [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.
  }
}));

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 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.currentPlayer.idpProfile).nickname;
        Dictionary<string, object> argumentDic = new Dictionary<string, object>() {
            {"${sender_name}", nickname}
            {"${first_image}", imageUrl}
        };
    
        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 if (result.code == 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
            {
                // etc
            }
        });
    }
    else
    {
        // Image upload failed
    }
});

Android Example

코드 블럭
// [TODO] Get my Kakao profile information from my Invite Friends list
KGKakaoProfile kakaoProfile;
  
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 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
        }
    }
});
  
// [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 if 
 else {
   // KakaoTalk game message sent fail
   if (result.
code
getCode() == KGResult.KGResultCode.
MessageSettingDisabled
MESSAGE_SETTING_DISABLE) {
            
    // If the recipient has opted-out of the message.
        
   }
        else if 
 else if (result.
code
getCode() == KGResult.KGResultCode.
ExceedDailyUsage
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 
 else if (result.
code
getCode() == KGResult.KGResultCode.
ExceedMonthlyUsage
EXCEED_MONTHLY_USAGE) {
            
    // Occurs when one month exceeds a month's quota that a specific person can send to a particular app.
        
   }
        else 
 else {
            
    // 
KakaoTalk
etc
game
   }
message sent fail.         
  }
}
    
});

Android iOS Example

코드 블럭
#import <KakaoGame/KakaoGame.h>
// [TODO] Get my Kakao profile information from my Invite Friends list
KGKakaoProfile *kakaoProfile;
  
 // 
Check
Kakaotalk 
if the user allows to receive a game message
profile(KGKakaoProfile Object)
  
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] Add required arguments Map<String, String> args = new LinkedHashMap<String, String>(); String nickname = ((KGKakaoProfile)KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname(); args.put(
 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)
    {
        // Pass in the key specified in the message template
        NSString* templateId = @"4101";
        NString* nickname = kakaoProfile.nickname;
        NSDictionary* argumentDic = @{@"${sender_name}":nickname, 
nickname)
@"${first_image}":imageUrl};
   // Send a Kakaotalk game message KGKakaoTalkMessage.sendNewGameMessage(kakaoProfile, templateId, args, new KGResultCallback<Boolean>() { @Override public void onResult(KGResult<Boolean> result
   
        [KGKakaoTalkMessage sendNewGameMessageWithKakaoProfile:kakaoProfile templateId:templateId argumentDic:argumentDic completionHandler:^(NSError* error) {
  if (result.isSuccess()) {    
            if (IS_SUCCESS(error) == YES)
            {
                // kakaoTalk game message sent successfully.
  } else 
            }
            else
            {
   
                // 
KakaoTalk
카카오톡 
game
게임 
message
메시지 
sent
보내기 
fail
실패
   if 
                if (
result
error.
getCode()
code == 
KGResult.KGResultCode.MESSAGE_SETTING_DISABLE
KGErrorMessageSettingDisabled)
                {
    
                    // If the recipient has opted-out of the message.
   
                }
 else if 

                else if (
result
error.
getCode()
code == 
KGResult.KGResultCode.EXCEED_DAILY_USAGE
KGErrorExceedDailyUsage)
                {
    
                    // Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app.
   
                }
 else if 

                else if (
result
error.
getCode()
code == 
KGResult.KGResultCode.EXCEED_MONTHLY_USAGE
KGErrorExceedMonthlyUsage)
                {
    
                    // 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";

                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] 
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         }     } }];

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 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.currentPlayer.idpProfile).nickname;
        Dictionary<string, object> argumentDic = new Dictionary<string, object>() {
            {"${sender_name}", nickname}
            {"${first_image}", imageUrl}
        };
    
        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 if (result.code == 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
            {
                // etc
            }
        });
    }
    else
    {
        // Image upload failed
    }
});

Android Example

...

코드 블럭
// [TODO] Get my Kakao profile information from my Invite Friends list
KGKakaoProfile kakaoProfile;
  
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 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
        }
    }
});
  
// [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> // [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] 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)     {         // 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)                 {                     
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, result);
if (result.isSuccess()) {
    // kakaoTalk game message sent successfully.
}
else {
    // 카카오톡 게임 메시지 보내기 실패
    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 user 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;
}
  
// [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::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 (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 user who has just registered a cacao story.
        } else {
            // etc
        }
    }
});

Unreal

코드 블럭
#include "KakaoGame.h"

FKGKakaoProfile kakaoProfile;

// [TODO] Set image file
FString imagePath;
FKGKakaoTalk::UploadGameImage(imagePath, FKGResultWithImageUrlPathDelegate::CreateLambda([=](FKGResult result, FString imageUrl) {
  if (result.IsSuccess())
  {
    // Image upload success
    FString templateId = TEXT("4101");

    // Send Message
    TMap<FString, FString> argumentMap;
    argumentMap.Add(TEXT("${sender_name}"), TEXT("nickname"));
    argumentMap.Add(TEXT("${first_image}"), TEXT("imageUrl"));

    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 if (result.GetCode() == FKGResultCode::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
      {
        // etc
                }             }         }];     }     else     {         // Image upload failed     } }]
      }
    }));
  }
}));