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

You are viewing an old version of this content. View the current version.

현재와 비교 View Version History

« 이전 버전 2 다음 »

28.1. Kakao Guild Chatting SDK Example


28.1.1. Open chat room of guild joined by KakaoTalk.

This is an example of opening a chat room in the KakaoTalk guild.

  • Run KakaoTalk to open a chat room for your current guild.

  • If you have not left the guild, but have left the chat room in Kakao Talk, join the chat room again and open the chat room.

  • If KakaoTalk is not installed, the function will fail. (If you leave the chat room in KakaoTalk, you will join the chat room again.)

  • If no guild is subscribed, the function will fail.
     

Unity Example

using KakaoGame.SDK;
using KakaoGame.SDK.Kakao;
 
// [TODO] Set World ID
int worldId = 2344;
  
// [TODO] Set Guild ID
int guildId = 2354;
  
// Open the chat room of guild registered in KakaoTalk
KGKakaoGuildChat.OpenKakaoTalkGuildChat(
    worldId,
    guildId,
    (result) => {
        if (result.isSuccess) {
            // Successfully opened chat room of guild registered in KakaoTalk
        }
        else {
            // Failed to open guild chat room registered in Kakao Talk
             
            if (result.code == KGResultCode.NotExistData)
            {
                // No guilds joined
            }
            else if (result.code == KGResultCode.KakaoTalkNotInstalled)
            {
                // KakaoTalk is not installed.
            }
            else
            {
                // Other errors
            }
        }
    });

Android Example

// Set World ID
int worldId = 2344;
  
// Set Guild ID
int guildId = 2354;
  
// Open the chat room of guild registered in KakaoTalk
KGKakaoGuildChat.openKakaoTalkGuildChat(activity, worldId, guildId, new KGResultCallback<Void>() {
    @Override
    public void onResult(KGResult<Void> result) {
        writeLog("KGKakaoGuildChat.openKakaoTalkGuildChat: " + result);
        if (result.isSuccess()) {
            // Successfully opened chat room of guild registered in KakaoTalk
        } else {
            // Failed to open guild chat room registered in Kakao Talk
            if (result.getCode() == KGResult.KGResultCode.KAKAOTALK_NOT_INSTALLED) {
                // KakaoTalk is not installed.
            } else {
                // Other errors
            }
        }
    }
}); 

iOS Example

#import <KakaoGame/KakaoGame.h>
  
// [TODO] Set World ID
int worldId = 2344;
  
// [TODO] Set Guild ID
int guildId = 2354;
 
[KGKakaoGuildChat openKakaoTalkGuildChatWithWorldId:worldId guildId:guildId completionHandler:^(NSError *error) {
    if (IS_SUCCESS(error) == YES)
    {
        // Successfully opened chat room of guild registered in KakaoTalk
    }
    else
    {
        // 카카오톡에서 가입된 길드의 채팅 방 열기 실패
        if (result.code == KGErrorNotExistData)
        {
            // No guilds joined
        }
        else if (error.code == KGErrorKakaoTalkNotInstalled)
        {
            // KakaoTalk is not installed.
        }
        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 kakao story.
        }
        else
        {
            // Other errors
        }
    }
}];
  

28.1.2. Send a message to the guild chat room

This is an example of sending a message to a guild chat room. (Guide : 20. Kakaotalk Message Template V2

Unity

using Kakaogame.SDK;
using Kakaogame.SDK.Kakao;
// [TODO] Set World ID
int worldId = 2344;
  
// [TODO] Set Guild ID
int guildId = 2354;
  
// [TODO] Set Template ID
int templateId = 1234;
 
KGKakaoGuildChat.SendNewGuildChatMessage(
    worldId,
    guildId,
    templateId,
    null,
    (result) => {
        if (result.isSuccess == true)
        {
            //A guild message has been sent successfully.
        }
        else
        {
            //A guild message could not be been sent successfully.
        }
});

Android

// [TODO] Set World ID
int worldId = 2344;
  
// [TODO] Set Guild ID
int guildId = 2354;
  
// [TODO] Set Template ID
int templateId = 1234;
  
KGKakaoGuildChat.sendNewGuildChatMessage(worldId, guildId, templateId, Settings.extra, new KGResultCallback<Void>() {
    @Override
    public void onResult(KGResult<Void> result) {
        if (result.isSuccess()) {
            //A guild message has been sent successfully.
        } else {
            //A guild message could not be been sent successfully.
        }
    }
}); 

iOS

#import <KakaoGame/KakaoGame.h>
 
 
// [TODO] Set World ID
int worldId = 2344;
  
// [TODO] Set Guild ID
int guildId = 2354;
  
// [TODO] Set Template ID
int templateId = 1234;
 
[KGKakaoGuildChat sendNewGuildChatMessageWithWorldId:worldId guildId:guildId templateId:templateId extra:nil completionHandler:^(NSError *error) {
    if (IS_SUCCESS(error) == YES)
    {
        //A guild message has been sent successfully.
    }
    else
    {
        //A guild message could not be been sent successfully.
    }
 
}];

Message Template V2

If you use Message Template V2, please refer to the following guide. (LINK)

  • 레이블 없음