22.1. Reward Invitation(beta) Example
Do not mix with new 3.9.0 or higher APIs.
22.1.1. Querying ongoing reward invitation event list
This section shows an example of a query of the ongoing 'reward invitation event list.
Unity Example
using KakaoGame.SDK; using KakaoGame.SDK.Kakao; KGKakaoInvitationEvent.LoadInvitationEvents( (result, events) => { if (result.isSuccess) { // Successful invitation event list lookup foreach (var ev in events) { int eventId = ev.eventId; bool isEventCardEnabled = ev.isEventCardEnabled; // Whether to show event cards long startTime = ev.startTime; // Event start time long endTime = ev.finishTime; // Event end time int maxHostRewardCount = ev.maxHostRewardCount; // Maximum number of rewards the invitees can receive string hostRewardCode = ev.hostRewardCode; // The code of the reward item that the invitee receives string joinerRewardCode = ev.joinRewardCode; // The code of the reward item that the participant receives string invitationUrl = ev.invitationUrl; // Invitation URL. You must enter this when sending an invitation message. int totalJoinerCount = ev.totalJoinerCount; // The number of people who have participated in my invite so far } } else { // Fail invitation event list lookup } }); |
Android Example
// query of the ongoing 'reward invitation event list. KGKakaoInvitationEvent.loadInvitationEvents(new KGResultCallback<List<KGKakaoInvitationEvent>>() { @Override public void onResult(KGResult<List<KGKakaoInvitationEvent>> result) { if (result.isSuccess()) { // Successful invitation event list lookup List<KGKakaoInvitationEvent> invitationEventList = result.getContent(); // ongoing 'reward invitation event list for (KGKakaoInvitationEvent invitationEvent : invitationEventList) { int eventId = invitationEvent.getEventId(); boolean isEventCardEnabled = invitationEvent.isEventCardEnabled(); long startTime = invitationEvent.getStartTime(); long finishTime = invitationEvent.getFinishTime(); int maxHostRewardCount = invitationEvent.getMaxHostRewardCount(); String hostRewardCode = invitationEvent.getHostRewardCode(); String joinRewrdCode = invitationEvent.getJoinRewardCode(); String invitationUrl = invitationEvent.getInvitationUrl(); int totalJoinerCount = invitationEvent.getTotalJoinerCount(); } } else { // Fail invitation event list lookup } } |
iOS Example
#import <KakaoGame/KakaoGame.h> [KGKakaoInvitationEvent loadInvitationEventsWithCompletionHandler:^(NSError *error, NSArray *invitationEvents) { if (IS_SUCCESS(error) == YES) { // Successful invitation event list lookup // ongoing 'reward invitation event list for (KGKakaoInvitationEvent *invitationEvent in invitationEvents) { int eventId = invitationEvent.eventId; // Event ID bool isEventCardEnabled = invitationEvent.isEventCardEnabled; // Whether to show event cards long long startTime = invitationEvent.startTime; // Event start time long long finishTime = invitationEvent.finishTime; // Event end time int maxHostRewardCount = invitationEvent.maxHostRewardCount; // Maximum number of rewards the invitees can receive NSString *hostRewardCode = invitationEvent.hostRewardCode; // The code of the reward item that the invitee receives NSString *joinRewardCode = invitationEvent.joinRewardCode; // The code of the reward item that the participant receives NSString *invitationUrl = invitationEvent.invitationUrl; // Invitation URL. You must enter this when sending an invitation message. int totalJoinerCount = invitationEvent.totalJoinerCount; // The number of people who have participated in my invite so far } } else { // Fail invitation event list lookup } }]; |
22.1.2. Querying user who invited you
This section shows an example of a query of the user who invited you.
Unity Example
using KakaoGame.SDK; using KakaoGame.SDK.Kakao; KGKakaoInvitationHost.LoadInvitationHosts( EVENT_ID, (result, hosts) => { if (result.isSuccess) { // Query of user who invite me successful foreach (var host in hosts) { if (host != null) { // you have someone who invited you KGPlayer player = host.player; // player information int totalJoinerCount = host.totalJoinerCount; } else { // No player invited me } } } else { // Query of user who invite me failed } }); |
Android Example
KGKakaoInvitationHost.loadInvitationHosts(eventId, new KGResultCallback<List<KGKakaoInvitationHost>>() { @Override public void onResult(KGResult<List<KGKakaoInvitationHost>> result) { writeLog("KGKakaoInvitationHost.loadInvitationHost: " + result); if (result.isSuccess()) { // Query of user who invite me successful List<KGKakaoInvitationHost> invitationHosts = result.getContent(); // hosts information if (invitationHosts != null && invitationHosts.size() > 0) { // you have someone who invited you for (KGKakaoInvitationHost invitationHost : invitationHosts) { KGPlayer player = invitationHost.getPlayer(); int totalJoinerCount = invitationHost.getTotalJoinerCount(); } } else { // No player invited me } } else { // Query of user who invite me failed } } }); |
iOS Example
#import <KakaoGame/KakaoGame.h> [KGKakaoInvitationHost loadInvitationHostsWithEventId:eventId completionHandler:^(NSError *error, NSArray *invitationHosts) { if (IS_SUCCESS(error) == YES) { // Query of user who invite me successful for (KGKakaoInvitationHost* invitationHost in invitationHosts) { if (invitationHost != nil) { // you have someone who invited you KGPlayer *player = invitationHost.player; // player information int totalJoinerCount = invitationHost.totalJoinerCount; } else { // No player invited me } } } else { // Query of user who invite me failed } }]; |
22.1.3. View a list of players who have participated in my invitation
This section shows an example of a query of View a list of players who have participated in my invitation.
Unity Example
using KakaoGame.SDK; using KakaoGame.SDK.Kakao; KGKakaoInvitationJoiner.LoadInvitationJoiners( EVENT_ID, (result, joiners) => { if (result.isSuccess) { // Successful viewed participate player list with my invitation foreach (var joiner in joiners) { KGPlayer player = joiner.player; string hostRewardCode = joiner.hostRewardCode; KGKakaoInvitationRewardState hostRewardState = joiner.hostRewardState; string joinerRewardCode = joiner.joinRewardCode; KGKakaoInvitationRewardState joinerRewardState = joiner.joinRewardState; long joinTime = joiner.joinTime; // Join time } } else { // Fail viewed participate player list with my invitation } }); |
Android Example
KGKakaoInvitationJoiner.loadInvitationJoiners(eventId, new KGResultCallback<List<KGKakaoInvitationJoiner>>() { @Override public void onResult(KGResult<List<KGKakaoInvitationJoiner>> result) { if (result.isSuccess()) { // Successful viewed participate player list with my invitation List<KGKakaoInvitationJoiner> invitationJoinerList = result.getContent(); // list of players who have participated in my invitation for (KGKakaoInvitationJoiner invitationJoiner : invitationJoinerList) { KGPlayer player = invitationJoiner.getPlayer(); int hostRewardCode = invitationJoiner.getHostRewardCode(); KGKakaoInvitationRewardState hostRewardState = invitationJoiner.getHostRewardState(); int joinRewardCode = invitationJoiner.getJoinRewardCode(); KGKakaoInvitationRewardState joinRewardState = invitationJoiner.getJoinRewardState(); long joinTime = invitationJoiner.getJoinTime(); } } else { // Fail viewed participate player list with my invitation } } }); |
iOS Example
#import <KakaoGame/KakaoGame.h> [KGKakaoInvitationJoiner loadInvitationJoinersWithEventId:eventId completionHandler:^(NSError *error, NSArray *invitationJoiners) { if (IS_SUCCESS(error) == YES) { // Successful viewed participate player list with my invitation // list of players who have participated in my invitation for (KGKakaoInvitationJoiner *invitationJoiner in invitationJoiners) { KGPlayer *player = invitationJoiner.player; int hostRewardCode = invitationJoiner.hostRewardCode; KGKakaoInvitationRewardState hostRewardState = invitationJoiner.hostRewardState; NSString *joinRewardCode = invitationJoiner.joinRewardCode; KGKakaoInvitationRewardState joinRewardState = invitationJoiner.joinRewardState; long long joinTime = invitationJoiner.joinTime; // Join time } } else { // Fail viewed participate player list with my invitation } }]; |
22.1.4. Send invitation message with Kakao Talk
This is an example of sending an invitation message to KakaoTalk.
By default, this is the same as sending a regular invitation, but you must use the templateId for compensating invites and add an invitation_event_id.
(Guide : 20. Kakaotalk Message Template V2)
Unity
using Kakaogame.SDK; // [TODO] Get Kakao profile information from invitable friends list. KGKakaoProfile kakaoProfile; // [TODO] Set invitation message template ID. string templateId = "1679"; // [TODO] Add the required arguments to the invitation message Dictionary<string, object> argumentDic = new Dictionary<string, object>() { {"name", "Nickname"}, {"iphoneMarketParam" : "test"}, {"iphoneExecParam", "test"}, {"sender_name", "iOSTester"}, {"invitation_event_id", 29} // Add only for compensated invitations }; // Send an invitation message to KakaoTalk. KGKakaoTalkMessage.SendNewInviteMessage( kakaoProfile, templateId, argumentDic, (result) => { if (result.isSuccess) { // Send invitation message to KakaoTalk succeeded. } else if (result.code == KGResultCode.MessageSettingDisabled) { // The recipient set to unsubscribe. } else if (result.code == KGResultCode.ExceedDailyUsage) { // Occurs when one day exceeds a day's quota (regardless of recipient) that can be sent for a specific 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 invitation message to KakaoTalk. } }); |
Android
// [TODO] Get Kakao profile information from invitable friends list. KGKakaoProfile kakaoProfile; // [TODO] Set invitation message template ID. String templateId; // [TODO] Add the required arguments to 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}", ""); // Add only for compensated invitations // Send an invitation message to KakaoTalk. KGKakaoTalkMessage.sendNewInviteMessage(kakaoProfile, templateId, args, new KGResultCallback<Boolean>() { @Override public void onResult(KGResult<Boolean> result) { if (result.isSuccess()) { // Send invitation message to KakaoTalk succeeded. } else { // Fail if (result.getCode() == KGResult.KGResultCode.MESSAGE_SETTING_DISABLE) { // The recipient set to unsubscribe. } else if (result.getCode() == KGResult.KGResultCode.EXCEED_DAILY_USAGE) { // Occurs when one day exceeds a day's quota (regardless of recipient) that can be sent for a specific 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 { // Other errors... } } } }); |
iOS
#import <KakaoGame/KakaoGame.h> // [TODO] Get Kakao profile information from invitable friends list. KGKakaoProfile *kakaoProfile; // Kakao profile (KGKakaoProfile Object) // [TODO] Set invitation message template ID. NSString *templateId = @"1679"; // [TODO] Add the required arguments to the invitation message. NSDictionary* argumentDic = @{@"name" : @"Nickname", @"iphoneMarketParam" : @"test", @"iphoneExecParam" : @"test", @"sender_name" : @"iOSTester", @"invitation_event_id" : @(29)}; // Send an invitation message to KakaoTalk. //invitation_event_id: Add only for compensated invitations [KGKakaoTalkMessage sendNewInviteMessageWithKakaoProfile:kakaoProfile templateId:templateId argumentDic:argumentDic completionHandler:^(NSError *error) { if (IS_SUCCESS(error) == YES) { // Send invitation message to KakaoTalk succeeded. } else { // Failed to send invitation message to KakaoTalk. if (error.code == KGErrorMessageSettingDisabled) { // The recipient set to unsubscribe. } else if (error.code == KGErrorExceedDailyUsage) { // Occurs when one day exceeds a day's quota (regardless of recipient) that can be sent for a specific 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 if (error.code == KGErrorNotKakaoTalkUser) { // The user is not a KakaoTalk user. } else { // Other errors... } } }]; |