메타 데이터의 끝으로 건너뛰기
메타 데이터의 시작으로 이동

이 페이지의 이전 버전을 보고 있습니다. 현재 버전 보기.

현재와 비교 페이지 이력 보기

« 이전 버전 2 다음 »

24.1. KakaoTalk Group Chatting SDK Example


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

Android

// [TODO] Set start value of query
int offset; // Group chatting room list query start value
 
// [TODO] Set query list size
int limit; // Group chatting room list size
 
// Querying KakaoTalk Group Chatting Room List
KGKakaoTalkGroupChat.loadGroupChats(offset, limit, new KGResultCallback<KGKakaoTalkGroupChatsResponse>() {
    @Override
    public void onResult(KGResult<KGKakaoTalkGroupChatsResponse> result) {
        if (result.isSuccess()) {
            // Query of KakaoTalk group chatting room list successful
 
            KGKakaoTalkGroupChatsResponse response = result.getContent();
 
            // Total number of group chatting rooms
            int totalCount = response.getTotalCount();
 
            // Group chatting room list
            List<KGKakaoTalkGroupChat> groupChats = response.getGroupChats();
        } else {
            // Query of KakaoTalk group chatting room list failed
        }
    }
});

iOS

#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

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


  • 레이블 없음