버전 비교

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

24.1. KakaoTalk Group Chatting SDK Example

목차
minLevel1
maxLevel7

...

24.1.1. Querying KakaoTalk Group Chatting Room List

This section shows an example of the retrieval of a user’s group chatting room list. It is sorted in order of recent chats.

API permission is required to view the list of group chat rooms. Please contact Kakao Games Business PM.

Unity

코드 블럭
using Kakaogame.SDK;
 
KGKakaoTalkGroupChat.LoadGroupChats(
    0, /* offset */
    10, /* limit */
    (result, totalCount, groupChats) => {
        if (result.isSuccess) {
            // Query of KakaoTalk group chatting room list successful.
            foreach(var groupChat in groupChats) {
                long chatId = groupChat.chatId;
                string title = groupChat.title;
                string thumbnailImageUrl = groupChats.thumbnailImageUrl;
                int memberCount = groupChat.memberCount;
                var memberThumbnailImageUrls = groupChat.memberThumbnailImageUrls;
                var chatType = groupChat.chatType;
            }
        }
        else {
            // [TODO] Query of KakaoTalk group chatting room list failed.
        }
    });

...

코드 블럭
#import <KakaoGame/KakaoGame.h>
 
// [TODO] Set start value of query
int offset = 0; // Group chatting room list query start value
 
// [TODO] Set query list size
int limit = 10; // Group chatting room list size
 
// Querying KakaoTalk Group Chatting Room List
[KGKakaoTalkGroupChat loadGroupChatsWithOffset:offset limit:limit completionHandler:^(NSError *error, int totalCount, NSArray *groupChats) {
    if (IS_SUCCESS(error) == YES)
    {
        // Query of KakaoTalk group chatting room list successful
 
        int _totalCount = totalCount; // Total number of group chatting rooms
 
        for(KGKakaoTalkGroupChat *groupChat in groupChats)
        {
            long long chatId = groupChat.chatId; // Group chatting room ID
            NSString *title = groupChat.title; // Group chatting room title
            NSString *thumbnailImageUrl = groupChat.thumbnailImageUrl; // Group chatting room thumbnail image URL
            int memberCount = groupChat.memberCount; // Number of members in the group chatting room
            NSArray *memberThumbnailImageUrls = groupChat.memberThumbnailImageUrls; // Thumbnail image URL list of group chatting room members. Up to 5
            KGKakaoTalkGroupChatType chatType = groupChat.chatType; // Group chatting room type (general/open)
        }
    }
    else
    {
        // Query of KakaoTalk group chatting room list failed
    }
}];

24.1.2. Sending KakaoTalk Group Chatting Messages

This section shows an example of sending a message to a group chatting room. (Guide : 20. Kakaotalk Message Template V2)

Unity

...

Windows Sync

코드 블럭
#include "KakaoGameLib.h"
  
// [TODO] Set start value of query
int32_t offset; // Group chatting room 
(KGKakaoTalkGroupChat
list 
object)
query 
string templateId = "1677"; Dictionary<string, object> argumentDic = new Dictionary<string, object>() {     {"msg", "New Connection, New World"},     {"iphoneMarketParam", "test"},     {"iphoneExecParam", "test"},     {"sender_name", "iOSTester"} };   KGKakaoTalkMessage.SendNewGroupChatMessage(     groupChat,     templateId,     argumentDic,     (result) => {         if (result.isSuccess) {             // Sending of KakaoTalk group chatting message successful.         }         else if (result.code == KGResultCode.MessageSettingDisabled) {             // If the receiver has set up message rejection         }         else if (result.code == KGResultCode.ExceedDailyUsage) {             // Occurs when the daily quota (regardless of receiver) of messages from a specific app that can be sent by a user has been exceeded         }         else if (result.code == KGResultCode.ExceedMonthlyUsage) {             // Occurs when the monthly quota of messages that a user can send to another specific user has been exceeded         }         else {             // Other errors         }     });

Android

코드 블럭// [TODO] Retrieve chatting room data from my chatting room list KGKakaoTalkGroupChat groupChat  
start value
// [TODO] Set query list size
int32_t limit; // Group chatting room list size
  
KakaoGame::Data::KGResult result;
int32_t totalCount;
std::vector<KakaoGame::Data::KGKakaoTalkGroupChat> groupChats;
  
KakaoGame::API::KGKakaoTalkGroupChat kgKakaoTalkGroupChat;
  
// Querying KakaoTalk Group Chatting Room List
kgKakaoTalkGroupChat.loadGroupChats(offset, limit, result, totalCount, groupChats);
if (result.isSuccess()) {
    // Query of KakaoTalk group chatting room list successful
    totalCount; // Total number of group chatting rooms
     
    for(KakaoGame::Data::KGKakaoTalkGroupChat groupChat : groupChats)
    {
        uint64_t chatId = groupChat.chatId; // Group chatting room ID
        std::wstring title = groupChat.title; // Group chatting room title
        std::wstring thumbnailImageUrl = groupChat.thumbnailImageUrl; // Group chatting room thumbnail image URL
        uint32_t memberCount = groupChat.memberCount; // Number of members in the group chatting room
        std::vector<std::wstring> memberThumbnailImageUrls = groupChat.memberThumbnailImageUrls; // Thumbnail image URL list of group chatting room members. Up to 5
        KakaoGame::Data::KGKakaoTalkGroupChatType chatType = groupChat.chatType; // Group chatting room type (general/open)
    }
} else {
    // Query of KakaoTalk group chatting room list failed
}

Windows Async

코드 블럭
#include "KakaoGameLib.h"
  
// [TODO] Set start value of query
int32_t offset; // Group chatting room list query start value
// [TODO] Set query list size
int32_t limit; // Group chatting room list size
 
KakaoGame::API::KGKakaoTalkGroupChat kgKakaoTalkGroupChat;
  
// Querying KakaoTalk Group Chatting Room List
KGKakaoTalkGroupChat.loadGroupChats(offset, limit, [this](KakaoGame::Data::KGResult result, int32_t totalCount, std::vector<KakaoGame::Data::KGKakaoTalkGroupChat> groupChats) {
    if (result.isSuccess()) {
        // Query of KakaoTalk group chatting room list successful
        totalCount; // Total number of group chatting rooms
     
        for(KakaoGame::Data::KGKakaoTalkGroupChat groupChat : groupChats)
        {
            uint64_t chatId = groupChat.chatId; // Group chatting room ID
            std::wstring title = groupChat.title; // Group chatting room title
            std::wstring thumbnailImageUrl = groupChat.thumbnailImageUrl; // Group chatting room thumbnail image URL
            uint32_t memberCount = groupChat.memberCount; // Number of members in the group chatting room
            std::vector<std::wstring> memberThumbnailImageUrls = groupChat.memberThumbnailImageUrls; // Thumbnail image URL list of group chatting room members. Up to 5
            KakaoGame::Data::KGKakaoTalkGroupChatType chatType = groupChat.chatType; // Group chatting room type (general/open)
        }
    } else {
        // Query of KakaoTalk group chatting room list failed
    }
});

Unreal

코드 블럭
#include "KakaoGame.h"
  
// [TODO] Set start value of query
int32 offset = 0; // Group chatting room list query start value
// [TODO] Set query list size
int32 limit = 10; // Group chatting room list size
 
// Querying KakaoTalk Group Chatting Room List
FKGKakaoTalkGroupChat::LoadGroupChats(offset, limit, FKGResultWithKakaoTalkGroupChatDelegate::CreateLambda([=](FKGResult result, int32 totalCount, TArray<FKGKakaoTalkGroupChat> groupChats) {
  if (result.IsSuccess())
  {
    // Query of KakaoTalk group chatting room list successful
    for (FKGKakaoTalkGroupChat groupChat : groupChats)
    {
      int64 chatId = groupChat.GetChatId(); // Group chatting room ID
      FString title = groupChat.GetTitle(); // Group chatting room title
      FString thumbnailImageUrl = groupChat.GetThumbnailImageUrl(); // Group chatting room thumbnail image URL
      int32 memberCount = groupChat.GetMemberCount(); // Number of members in the group chatting room
      TArray<FString> memberThumbnailImageUrls = groupChat.GetMemberThumbnailImageUrls(); // Thumbnail image URL list of group chatting room members. Up to 5
      EKGKakaoTalkGroupChatType chatType = groupChat.GetChatType(); // Group chatting room type (general/open)
    }
  }
  else
  {
    // Query of KakaoTalk group chatting room list failed
  }
}));

24.1.2. Sending KakaoTalk Group Chatting Messages

This section shows an example of sending a message to a group chatting room. (Guide : 20. Kakaotalk Message Template V2 )

Unity

코드 블럭
using Kakaogame.SDK;
 
KGKakaoTalkGroupChat groupChat; // Group chatting room (KGKakaoTalkGroupChat object)
string templateId = "1677";
Dictionary<string, object> argumentDic = new Dictionary<string, object>() {
    {"msg", "New Connection, New World"},
    {"iphoneMarketParam", "test"},
    {"iphoneExecParam", "test"},
    {"sender_name", "iOSTester"}
};
 
KGKakaoTalkMessage.SendNewGroupChatMessage(
    groupChat,
    templateId,
    argumentDic,
    (result) => {
        if (result.isSuccess) {
            // Sending of KakaoTalk group chatting message successful.
        }
        else if (result.code == KGResultCode.MessageSettingDisabled) {
            // If the receiver has set up message rejection
        }
        else if (result.code == KGResultCode.ExceedDailyUsage) {
            // Occurs when the daily quota (regardless of receiver) of messages from a specific app that can be sent by a user has been exceeded
        }
        else if (result.code == KGResultCode.ExceedMonthlyUsage) {
            // Occurs when the monthly quota of messages that a user can send to another specific user has been exceeded
        }
        else {
            // Other errors
        }
    });

Android

코드 블럭
// [TODO] Retrieve chatting room data from my chatting room list
KGKakaoTalkGroupChat groupChat
 
// [TODO] Set the group chatting message template ID
String templateId;
 
// [TODO] Set the parameters needed for the group chatting message
Map<String, String> args = new LinkedHashMap<String, String>();
String nickname = ((KGKakaoProfile)KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
args.put("${sender_name}", nickname);
 
// Sending KakaoTalk Group Chatting Messages
KGKakaoTalkMessage.sendNewGroupChatMessage(groupChat, templateId, args, new KGResultCallback<Boolean>() {
@Override
public void onResult(KGResult<Boolean> result) {
  writeLog("KGKakaoTalkMessage.sendGroupChatMessage() : " + result);
 
  if (result.isSuccess()) {
   // Sending of KakaoTalk group chatting message successful
 
  } else {
   // Sending of KakaoTalk group chatting message failed
 
   if (result.getCode() == KGResult.KGResultCode.MESSAGE_SETTING_DISABLE) {
    // If the receiver has set up message rejection.
   } else if (result.getCode() == KGResult.KGResultCode.EXCEED_DAILY_USAGE) {
    // Occurs when the daily quota (regardless of receiver) of messages from a specific app that can be sent by a user has been exceeded.
   } else if (result.getCode() == KGResult.KGResultCode.EXCEED_MONTHLY_USAGE) {
    // Occurs when the monthly quota of messages that a user can send to another specific user has been exceeded.
   } else {
    // Other errors
   }
  }
}
});

iOS

코드 블럭
#import <KakaoGame/KakaoGame.h>
 
// [TODO] Retrieve chatting room object from my group chatting room list
KGKakaoTalkGroupChat *groupChat; // Group chatting room (KGKakaoTalkGroupChat object)
 
// [TODO] Set the group chatting message template ID
NSString *templateId = @"1677"; // Issued group chatting message template ID
 
// [TODO] Set the parameters needed for the group chatting message
NSDictionary *argumentDic = @{@"msg" : @"New Connection, New World.", @"iphoneMarketParam" : @"test", @"iphoneExecParam" : @"test", @"sender_name" : @"iOSTester"};
 
// Sending KakaoTalk Group Chatting Messages
[KGKakaoTalkMessage sendNewGroupChatMessageWithGroupChat:groupChat
                                               templateId:templateId
                                          argumentDic:argumentDic
                                    completionHandler:^(NSError *error) {
    if (IS_SUCCESS(error) == YES)
    {
        // Sending of KakaoTalk group chatting message successful
    }
    else
    {
        // Sending of KakaoTalk group chatting message failed
 
        if (error.code == KGErrorMessageSettingDisabled)
        {
            // If the receiver has set up message rejection
        }
        else if (error.code == KGErrorExceedDailyUsage)
        {
            // Occurs when the daily quota (regardless of receiver) of messages from a specific app that can be sent by a user has been exceeded
        }
        else if (error.code == KGErrorExceedMonthlyUsage)
        {
            // Occurs when the monthly quota of messages that a user can send to another specific user has been exceeded
        }
        else
        {
            // Other errors
        }
    }
}];

Windows Sync

코드 블럭
#include "KakaoGameLib.h"
  
// [TODO] Bring your own profile object
KakaoGame::Data::KGLocalPlayer localPlayer;
// [TODO] Get my chat room information from my chat room list
KakaoGame::Data::KGKakaoTalkGroupChat groupChat;
// [TODO] Set group message template ID
std::wstring templateId;
// [TODO] Add required arguments to group message
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 group message
kgKakaoTalkMessage.sendNewGroupChatMessage(groupChat, templateId, args, result);
if (result.isSuccess()) {
    // kakaoTalk group chat 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 {
        // etc
    }
}

Windows Async

코드 블럭
#include "KakaoGameLib.h"
 
// [TODO] Bring your own profile object
KakaoGame::Data::KGLocalPlayer localPlayer;
// [TODO] Get my chat room information from my chat room list
KakaoGame::Data::KGKakaoTalkGroupChat groupChat;
// [TODO] Set
the
 group
chatting
 message template ID
String
std::wstring templateId;
 

// [TODO] 
Set
Add 
the
required 
parameters
arguments 
needed
to 
for the
group
chatting
 message
Map<String, String> args = new LinkedHashMap<String, String>(); String nickname = ((KGKakaoProfile)KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname(); args.put(
std::map<std::wstring, std::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${sender_name}"
, nickname);  
), localPlayer.kakaoProfile.nickname));
  
KakaoGame::API::KGKakaoTalkMessage kgKakaoTalkMessage;
// 
Sending
Send 
KakaoTalk
a 
Group
Kakaotalk 
Chatting
group 
Messages
message
KGKakaoTalkMessage
kgKakaoTalkMessage.sendNewGroupChatMessage(groupChat, templateId, args,
 new KGResultCallback<Boolean>() { @Override public void onResult(KGResult<Boolean>
 [this](KakaoGame::Data::KGResult result) {
  writeLog("KGKakaoTalkMessage.sendGroupChatMessage() : " + result);     if 
    if (result.isSuccess()) {
   
        // 
Sending of KakaoTalk
kakaoTalk group 
chatting
chat message 
successful
sent 
 
successfully.
  } else 
    }
    else
    {
   
        // 
Sending
카카오톡 
of
그룹 
KakaoTalk
채팅 
group
메시지 
chatting
보내기 
message failed      if 
실패
        if (result.
getCode()
code == 
KGResult.KGResultCode.MESSAGE_SETTING_DISABLE
KakaoGame::Data::KGResultCode::MessageSettingDisabled) {
    
            // If the 
receiver
recipient has opted-out 
set
of 
up
the message
rejection
.
   
        } else if (result.
getCode()
code == 
KGResult.KGResultCode.EXCEED_DAILY_USAGE
KakaoGame::Data::KGResultCode::ExceedDailyUsage) {
    
            // Occurs when there 
the daily
is a day's quota (regardless
of receiver) of messages from a specific app that
 of recipient) that one person can 
be
send 
sent by
for a 
user has been exceeded
particular app.
   
        } else if (result.
getCode()
code == 
KGResult.KGResultCode.EXCEED_MONTHLY_USAGE
KakaoGame::Data::KGResultCode::ExceedMonthlyUsage) {
    
            // Occurs when
the monthly quota of messages
 one month exceeds a month's quota that a specific 
user
person can send to 
another
a 
specific user has been exceeded
particular app.
   
        } else {
    
            // 
Other
etc
errors    
        }
  }
    }
});

iOSUnreal

코드 블럭
#import
#include 
<KakaoGame/
"KakaoGame.
h>
h"
 
  
// [TODO] Get 
Retrieve
my 
chatting
chat room 
object
information from my 
group chatting
chat room list
KGKakaoTalkGroupChat
FKGKakaoTalkGroupChat 
*
groupChat; // // Group 
chatting
chat room
(
KGKakaoTalkGroupChat
FKGKakaoTalkGroupChat object)
 
// [TODO] Set
the
 group
chatting
 message template ID
NSString
FString 
*
templateId = 
@
TEXT("
1677
4108");
 //

Issued group chatting message template ID
 
// [TODO]
Set the parameters needed for the group chatting message NSDictionary *argumentDic = @{@"msg" : @"New Connection, New World.", @"iphoneMarketParam" : @"test", @"iphoneExecParam" : @"test", @"sender_name" : @"iOSTester"};   // Sending KakaoTalk Group Chatting Messages [KGKakaoTalkMessage sendNewGroupChatMessageWithGroupChat:groupChat                                                templateId:templateId                                           argumentDic:argumentDic                                     completionHandler:^(NSError *error) {     if (IS_SUCCESS(error) == YES)     {         // Sending of KakaoTalk group chatting message successful     }     else     {         // Sending of KakaoTalk group chatting message failed           if (error.code == KGErrorMessageSettingDisabled)         {             
 Add required arguments to group message
FKGIdpProfile idpProfile = FKGLocalPlayer::GetCurrentPlayer().GetIdpProfile();
FKGKakaoProfile *localKakaoProfile = (FKGKakaoProfile*)&idpProfile;
FString nickname = localKakaoProfile->GetNickname();
 
TSharedPtr<FJsonObject> argumentMap = MakeShareable(new FJsonObject);
argumentMap->SetStringField(TEXT("${sender_name}"), nickname);
 
FKGKakaoTalkMessage::SendNewGroupChatMessage(groupChat, templateId, argumentMap, FKGResultDelegate::CreateLambda([=](FKGResult result) {
  if (result.IsSuccess())
  {
    // kakaoTalk group chat message sent successfully.
  }
  else if (result.GetCode() == FKGResultCode::MessageSettingDisabled)
  {
    // If the 
receiver
recipient has opted-out 
set
of 
up
the message.
rejection         
  }
        else if 
  else if (
error
result.
code
GetCode() == 
KGErrorExceedDailyUsage
FKGResultCode::ExceedDailyUsage)
        
  {
            
    // Occurs when there is 
the
a 
daily
day's quota (regardless of 
receiver
recipient) 
of
that 
messages
one 
from a specific app that
person can 
be
send 
sent by
for a 
user
particular 
has been exceeded         
app.
  }
        else if 
  else if (
error
result.
code
GetCode() == 
KGErrorExceedMonthlyUsage
FKGResultCode::ExceedMonthlyUsage)
        
  {
            
    // Occurs when one 
the
month 
monthly
exceeds 
quota
a 
of
month's 
messages
quota that a 
user
specific person can send to 
another
a 
specific
particular 
user has been exceeded         
app.
  }
        else
  else
        
  {
            
    // 
Other
etc
errors         
  }
    
}
}]
));