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

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

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

버전 1 현재 »

20.1. Kakaotalk Message Template V2 Example


20.1.1. Send an invitation message V2 to a friend

This section shows an example of a send an invitation message V2 to a friend.

Unity Example

using Kakaogame.SDK;
// [TODO] Get my Kakao profile information from my Invite Friends list
KGKakaoProfile kakaoProfile;
// [TODO] Set invitation message template ID
string templateId = "4108";
// [TODO] Add required arguments to invitation message
Dictionary<string, object> argumentDic = new Dictionary<string, object>();
// Send a Kakaotalk invitation message
KGKakaoTalkMessage.SendNewInviteMessage(
    kakaoProfile,
    templateId,
    argumentDic,
    (result) => {
        if (result.isSuccess) {
            // Sending invitation message to KakaoTalk succeeded
        }
        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 {
            // Failed to send Kakao Talk invitation message
        }
    });

Android Example

// [TODO] Get my Kakao profile information from my Invite Friends list
KGKakaoProfile kakaoProfile;
// [TODO] Set invitation message template ID
String templateId;
// [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("${invitation_event_id}", "");
// Send a Kakaotalk invitation message
KGKakaoTalkMessage.sendNewInviteMessage(kakaoProfile, templateId, args, new KGResultCallback<Boolean>() {
 @Override
 public void onResult(KGResult<Boolean> result) {
  if (result.isSuccess()) {
   // Sending invitation message to KakaoTalk succeeded
  } else {
   // Failed to send Kakao Talk invitation message
    
    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)
// [TODO] Set invitation message template ID
NSString *templateId = @"4108";
// [TODO] Add required arguments to invitation message
NSDictionary* argumentDic = @{@"name" : @"nickname", @"iphoneMarketParam" : @"test", @"iphoneExecParam" : @"test", @"sender_name" : @"iOSTester", @"invitation_event_id" : @(29)};
// Send a Kakaotalk invitation message
[KGKakaoTalkMessage sendNewInviteMessageWithKakaoProfile:kakaoProfile
                                              templateId:templateId
                                             argumentDic:argumentDic
                                       completionHandler:^(NSError *error) {
    if (IS_SUCCESS(error) == YES)
    {If the recipient has opted-out of the message
        // Sending invitation message to KakaoTalk succeeded
    }
    else
    {
        // Failed to send Kakao Talk invitation message
     
        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
        }
    }
}];

20.1.2. Send an game message V2 to a friend

This section shows an example of a send an game message V2 to a friend.

Unity Example

using Kakaogame.SDK;
KGKakaoProfile kakaoProfile; // Kakaotalk profile(KGKakaoProfile Object)
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;
// [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)
// [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
        }
    }
}];

20.1.3. Send an group chat room message V2 to a friend

This section shows an example of a send an group chat room message V2 to a friend.

Unity Example

sing Kakaogame.SDK;
KGKakaoTalkGroupChat groupChat; // Group chat room(KGKakaoTalkGroupChat object)
string templateId = "4108";
Dictionary<string, object> argumentDic = new Dictionary<string, object>();
KGKakaoTalkMessage.SendNewGroupChatMessage(
    groupChat,
    templateId,
    argumentDic,
    (result) => {
        if (result.isSuccess) {
            // kakaoTalk group chat 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 {
            // etc
        }
    });

Android Example

// [TODO] Get my chat room information from my chat room list
KGKakaoTalkGroupChat groupChat
// [TODO] Set group message template ID
String templateId;
// [TODO] Add required arguments to group message
Map<String, String> args = new LinkedHashMap<String, String>();
String nickname = ((KGKakaoProfile)KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
args.put("${sender_name}", nickname);
// Send a Kakaotalk group message
KGKakaoTalkMessage.sendNewGroupChatMessage(groupChat, templateId, args, new KGResultCallback<Boolean>() {
@Override
public void onResult(KGResult<Boolean> result) {
  if (result.isSuccess()) {
   // kakaoTalk group chat message sent successfully.
  } else {
   // kakaoTalk group chat 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 chat room information from my chat room list
KGKakaoTalkGroupChat *groupChat; // Group chat room(KGKakaoTalkGroupChat object)
// [TODO] Set group message template ID
NSString *templateId = @"4108";
// [TODO] Add required arguments to group message
NSDictionary *argumentDic = @{@"msg" : @"This is a group message.", @"iphoneMarketParam" : @"test", @"iphoneExecParam" : @"test", @"sender_name" : @"iOSTester"};
// Send a Kakaotalk group message
[KGKakaoTalkMessage sendNewGroupChatMessageWithGroupChat:groupChat
                                              templateId:templateId
                                             argumentDic:argumentDic
                                       completionHandler:^(NSError *error) {
    if (IS_SUCCESS(error) == YES)
    {
        // kakaoTalk group chat message sent successfully.
    }
    else
    {
        // kakaoTalk group chat 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
        }
    }
}];

20.1.4. Send Message V2 to Guild Chat Room

This section shows an example of a send an message V2 to the guild chat room.

 

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

 

  • 레이블 없음