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 } } }]; |
Windows Sync
#include "KakaoGameLib.h" std::wstring worldId = TEXT("worldId"); // worldId std::wstring guildId = TEXT("guildId"); // guildId KakaoGame::Data::KGResult result; KakaoGame::API::KGKakaoGuildChat kgKakaoGuildChat; // Open a chat room in KakaoTalk kgKakaoGuildChat.openKakaoTalkGuildChat(worldId, guildId, result); if (result.isSuccess()) { // Successfully moved to the chat tab of the Kakao Talk app } else { // Failed to move to the chat tab of the Kakao Talk app } |
Windows Async
#include "KakaoGameLib.h" std::wstring worldId = TEXT("worldId"); // worldId std::wstring guildId = TEXT("guildId"); // guildId KakaoGame::API::KGKakaoGuildChat kgKakaoGuildChat; // Open a chat room in KakaoTalk kgKakaoGuildChat.openKakaoTalkGuildChat(worldId, guildId, [this](KakaoGame::Data::KGResult result) { if (result.isSuccess()) { // Successfully moved to the chat tab of the Kakao Talk app } else { // Failed to move to the chat tab of the Kakao Talk app } }); |
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. } }]; |
Windows Sync
#include "KakaoGameLib.h" // [TODO] Set World ID std::wstring worldId; // [TODO] Set Guild ID std::wstring guildId; // [TODO] Set Template ID std::wstring templateId; // [TODO] Optional : Setting the value defined in the template message std::map<std::wstring, std::wstring> arguments; KakaoGame::Data::KGResult result; KakaoGame::API::KGKakaoGuildChat kgKakaoGuildChat; // Send guild chat message kgKakaoGuildChat.sendGuildChatMessage(worldId, guildId, templateId, arguments, result); if (result.isSuccess()) { // Successfully sending guild chat message } else { // Failed to send guild chat message if (KakaoGame::Data::KGResultCode::ExceedDailyUsage == result.code) { // Occurs when the daily quota (regardless of recipient) that one person can send for a specific app is exceeded } else { // Other errors } } |
Windows Async
#include "KakaoGameLib.h" // [TODO] Set World ID std::wstring worldId; // [TODO] Set Guild ID std::wstring guildId; // [TODO] Set Template ID std::wstring templateId; // [TODO] Optional : Setting the value defined in the template message std::map<std::wstring, std::wstring> arguments; KakaoGame::API::KGKakaoGuildChat kgKakaoGuildChat; // Send guild chat message kgKakaoGuildChat.sendGuildChatMessage(worldId, guildId, templateId, arguments, [this](KakaoGame::Data::KGResult result) { if (result.isSuccess()) { // Successfully sending guild chat message } else { // Failed to send guild chat message if (KakaoGame::Data::KGResultCode::ExceedDailyUsage == result.code) { // Occurs when the daily quota (regardless of recipient) that one person can send for a specific app is exceeded } else { // Other errors } } }); |
Message Template V2
If you use Message Template V2, please refer to the following guide. (LINK)