21.1. KakaoTalk Invitation SDK Example

21.1. KakaoTalk Invitation SDK Example

 


Do not mix with new 3.9.0 or higher APIs.

21.1.1. Example of KakaoTalk Invitation Message Sending

 

21.1.2. Querying KakaoTalk Invitation Target List

 

LoadInvitableFriendProfiles(has 3 arguments) API and LoadRecommendedInvitableFriendProfiles API are deprecated. You can continue to use it, but we recommend replacing it with a new LoadInvitableFriendProfiles(has 4 arguments) API.



This section shows an example of a query of the KakaoTalk invitation target list.

KakaoGame Platform will recommend friend who will join the game with high possibility. The number of recommendable friends may less then limit of recommend friend set by you.

If you have more than 2,000 friends that you can get at once, you can only get list for  2,000 people.

'recomended' is a recommendation friend who is more likely to join a game, and you can use that value to design a differential reward. Through the callback, the list of recommended friends delivered is first arranged recommended friends with a high probability of joining, and then to be sorted by name.

Unity

using Kakaogame.SDK;   // [TODO] Set limit of recommend friend int recommendLimit = 5;     // [TODO] Set start value for querying friend list int offset = 0; // Start value for querying friend list   // [TODO] Set size of querying friend list int limit = 300; // Friend list size   KGKakaoProfile.LoadInvitableFriendProfiles(     recommendLimit,     offset,     limit,     (result, totalCount, idpProfiles) => {         if (result.isSuccess) {             // Finding the list of inevitable friend profiles in KakaoTalk was successful.               // Total number of invitable KakaoTalk friends             int _totalCount = totalCount;               // List of invitable KakaoTalk friend profiles             foreach(var kakaoProfile in idpProfiles) {                 // is recommended                 bool isRecommended = kakaoProfile.isRecommended;                    // Since the friend does not have a playerId before running the game, it can be managed by using KGKakaoProfile.uuid.                 string uuid = kakaoProfile.uuid;             }         }         else {             // Finding the list of inevitable friend profiles in KakaoTalk was not successful.         }     });

Android

// [TODO] Set limit of recommend friend int recommendLimit = 5;    // [TODO] Set start value of friend list query int offset; // Friend list query start value   // [TODO] Set friend list query size int limit; // Friend list size   // Querying the invitation target friend profile list KGKakaoProfile.loadInvitableFriendProfiles(recommendLimit, offset, limit, new KGResultCallback<KGKakaoFriendsResponse>() {     @Override     public void onResult(KGResult<KGKakaoFriendsResponse> result) {         if (result.isSuccess()) {             // Query of invitation target friend profile list successful               KGKakaoFriendsResponse response = result.getContent();               // Number of KakaoTalk invitation target friends             int totalCount = response.getTotalCount();               // List of invitation target friend profiles             List<KGKakaoProfile> friendList = response.getFriendList();                for (KGKakaoProfile profile : friendList) {                 // is recommended                 boolean isRecommended = profile.isRecommended();                    // Since the friend does not have a playerId before running the game, it can be managed by using KGKakaoProfile.getUUID().                 String UUID = profile.getUUID();             }         } else {             // Query of invitation target friend profile list failed         }     } });

iOS

#import <KakaoGame/KakaoGame.h>   // [TODO] Set limit of recommend friend int recommendLimit = 5; // [TODO] Set start value of friend list query int offset = 0; // Friend list query start value   // [TODO] Set friend list query size int limit = 300; // Friend list size   // Querying the invitation target friend profile list [KGKakaoProfile loadInvitableFriendProfilesWithRecommendLimit:recommendLimit offset:offset limit:limit completionHandler:^(NSError *error, int totalCount, NSArray *idpProfiles) {     if (IS_SUCCESS(error) == YES)     {         // Query of invitation target friend profile list successful           // Number of KakaoTalk invitation target friends         int _totalCount = totalCount;           // List of invitation target friend profiles         for(KGKakaoProfile *kakaoProfile in idpProfiles)         {             // is recommended             BOOL isRecommended = kakaoProfile.isRecommended;                // Since the friend does not have a playerId before running the game, it can be managed by using KGKakaoProfile.uuid.             NSString* uuid = kakaoProfile.uuid;         }     }     else     {         // Query of invitation target friend profile list failed     } }];

21.1.3. Sending a KakaoTalk Invitation Message

This section shows an example of KakaoTalk invitation message sending.(Guide : 20. Kakaotalk Message Template V2 )

Unity

using Kakaogame.SDK;   // [TODO] Retrieve the Kakao profile data from the invitation target friend list KGKakaoProfile kakaoProfile;   // [TODO] Set the invitation message template ID string templateId = "1679";   // [TODO] Add the parameters needed in the invitation message Dictionary<string, object> argumentDic = new Dictionary<string, object>() {     {"name", "MyName"},     {"iphoneMarketParam" : "test"},     {"iphoneExecParam", "test"},     {"sender_name", "iOSTester"},     {"invitation_event_id", 29} };   // Sending a KakaoTalk Invitation Message KGKakaoTalkMessage.SendNewInviteMessage(     kakaoProfile,     templateId,     argumentDic,     (result) => {         if (result.isSuccess) {             // KakaoTalk invitation message successfully sent.         }         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 {             // Sending of KakaoTalk invitation message failed.         }     });

Android

// [TODO] Retrieve the Kakao profile data from the invitation target friend list KGKakaoProfile kakaoProfile;   // [TODO] Set the invitation message template ID String templateId;   // [TODO] Add the parameters needed in the 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}", "");   // Sending a KakaoTalk Invitation Message KGKakaoTalkMessage.sendNewInviteMessage(kakaoProfile, templateId, args, new KGResultCallback<Boolean>() {  @Override  public void onResult(KGResult<Boolean> result) {   writeLog("KGKakaoTalkMessage.sendInviteMessage() : " + result);     if (result.isSuccess()) {    // Request successful     } else {    // Request 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 the Kakao profile data from the invitation target friend list KGKakaoProfile *kakaoProfile; // Kakao profile (KGKakaoProfile object)   // [TODO] Set the invitation message template ID NSString *templateId = @"1679";   // [TODO] Add the parameters needed in the invitation message NSDictionary* argumentDic = @{@"name" : @"MyName", @"iphoneMarketParam" : @"test", @"iphoneExecParam" : @"test", @"sender_name" : @"iOSTester", @"invitation_event_id" : @(29)};   // Sending a KakaoTalk Invitation Message [KGKakaoTalkMessage sendNewInviteMessageWithKakaoProfile:kakaoProfile                                              templateId:templateId                                           argumentDic:argumentDic                                     completionHandler:^(NSError *error) {     if (IS_SUCCESS(error) == YES)     {         // KakaoTalk invitation message successfully sent     }        else     {         // Sending of KakaoTalk invitation 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         }     } }];