21.1. KakaoTalk Invitation SDK Example
...
경고 |
---|
Caution Do not mix with existing APIs under 3.9.0. In games newly released after 2022, you cannot use the Get Friends List and Send Message APIs guided below. Please use the message sending function using the friend picker API. |
21.1.1. Querying ongoing invitation event list
...
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// query of the ongoing invitation event list.
[KGKakaoInvitation loadEventsWithCompletionHandler:^(NSError *error, NSArray *invitationEvents) {
if (IS_SUCCESS(error) == YES)
{
// Successful invitation event list lookup
if (invitationEvents != nil)
{
for (KGKakaoEvent *invitationEvent in invitationEvents)
{
// Event ID: Required when sending an invitation message, to retrieve a list of invitees or senders.
int eventId = invitationEvent.eventId;
// Event start time
long long startTime = invitationEvent.startTime;
// Event end time
long long finishTime = invitationEvent.finishTime;
// Event Description
NSString *eventDescription = invitationEvent.eventDescription;
}
}
}
else if (error.code == KGErrorNotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail invitation event list lookup
}
}]; |
|
21.1.2. Querying KakaoTalk Invitation Target List
This section shows an example of a query of the KakaoTalk invitation target list.
KakaoGame Platform will recommended friends who will join the game with high possibility. The number of recommended friends may less than the number of recommend limt you have set.
When sending an invitation message to KakaoTalk, you must pass the 'KakaoProfile' object received using this API as an argument.
The friend list is first listed according to the ranking given by the server on the recommend limit, and then sorted in alphabetical order.
If you want to show recommended friends in the UI, you can use the 'isRecommended' argument.
Unity 예제
코드 블럭 |
using Kakaogame.SDK;
using Kakaogame.SDK.Kakao;
Windows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::Data::KGResult result;
std::vector<KakaoGame::Data::KGKakaoEvent> invitationEvents;
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// query of the ongoing invitation event list.
kgKakaoInvitation.loadEvents(result, invitationEvents)'
if (result.isSuccess()) {
// Successful invitation event list lookup
for (KakaoGame::Data::KGKakaoEvent invitationEvent : invitationEvents)
{
// Event ID: Required when sending an invitation message, to retrieve a list of invitees or senders.
int32_t eventId = invitationEvent.eventId;
// Event start time
int64_t startTime = invitationEvent.startTime;
// Event end time
int64_t finishTime = invitationEvent.finishTime;
// Event Description
std::wstring eventDescription = invitationEvent.eventDescription;
}
}
else if (result.code == KakaoGame::Data::KGResultCode::NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail invitation event list lookup
}
|
|
Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// query of the ongoing invitation event list.
kgKakaoInvitation.loadEvents([this](KakaoGame::Data::KGResult result, std::vector<KakaoGame::Data::KGKakaoEvent> invitationEvents) {
if (result.isSuccess()) {
// Successful invitation event list lookup
for (KakaoGame::Data::KGKakaoEvent invitationEvent : invitationEvents) {
// Event ID: Required when sending an invitation message, to retrieve a list of invitees or senders.
int32_t eventId = invitationEvent.eventId;
// Event start time
int64_t startTime = invitationEvent.startTime;
// Event end time
int64_t finishTime = invitationEvent.finishTime;
// Event Description
std::wstring eventDescription = invitationEvent.eventDescription;
}
}
else if (result.code == KakaoGame::Data::KGResultCode::NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail invitation event list lookup
}
});
|
|
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
// query of the ongoing invitation event list.
FKGKakaoInvitation::LoadEvents(FKGResultWithEventsDelegate::CreateLambda([=](FKGResult result, TArray<FKGKakaoEvent> events) {
if (result.IsSuccess())
{
// Successful invitation event list lookup
for (FKGKakaoEvent invitationEvent : events)
{
// Event ID: Required when sending an invitation message, to retrieve a list of invitees or senders.
int32 eventId = invitationEvent.GetEventId();
// Event start time
int64 startTime = invitationEvent.GetStartTime();
// Event end time
int64 finishTime = invitationEvent.GetFinishTime();
// Event Description
FString eventDescription = invitationEvent.GetEventDescription();
}
}
else if (result.GetCode() == FKGResultCode::NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail invitation event list lookup
}
})); |
|
21.1.2. Querying KakaoTalk Invitation Target List
This section shows an example of a query of the KakaoTalk invitation target list.
KakaoGame Platform will recommended friends who will join the game with high possibility. The number of recommended friends may less than the number of recommend limt you have set.
When sending an invitation message to KakaoTalk, you must pass the 'KakaoProfile' object received using this API as an argument.
The friend list is first listed according to the ranking given by the server on the recommend limit, and then sorted in alphabetical order.
If you want to show recommended friends in the UI, you can use the 'isRecommended' argument.
Unity 예제
코드 블럭 |
---|
using Kakaogame.SDK;
using Kakaogame.SDK.Kakao;
// [TODO] Set limit of recommended friends
int recommendLimit = 5; // The number of recommended friends
// int recommendLimit = 0; // Set to 0 if you want to fetch the list without recommended friends
// int recommendLimit = -1; // Set it to -1 if you want to include all of your recommended friends (the number of recommended friends is variably)
// [TODO] Set start value for querying friend list
int offset; // Start value for querying friend list
// [TODO] Set size of querying friend list
int limit; // Friend list size
// Querying KakaoTalk Invitation Target List
KGKakaoInvitation.LoadInvitableFriendProfiles(recommendLimit, offset, limit, (result, totalCount, kakaoProfiles) => {
if (result.isSuccess)
{
// Success
// Query of invitation target friend profile list successful
foreach (KGKakaoProfile kakaoProfile in kakaoProfiles)
{
// KakaoTalk nickname
string nickname = kakaoProfile.nickname;
// KakaoTalk profile thumbnail image url
string thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If this user is a recommended friend or not
BOOL isRecommended = kakaoProfile.isRecommended;
// KakaoTalk installation os
string talkOs = kakaoProfile.kakaoTalkOS.ToString();
// Whether your friends are allowed to get messages or not. You must not send message if it is 'false'.
bool isAllowMessage = kakaoProfile.isAllowedMessage;
}
}
else if (result.code == KGResultCode.NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail...
}
}); |
|
Android 예제
코드 블럭 |
---|
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGKakaoProfile.KGKakaoFriendsResponse;
import com.kakaogame.KGResult;
// [TODO] Set limit of recommended friends
int recommendLimit = 5; // The number of recommended friends
// int recommendLimit = 0; // Set to 0 if you want to fetch the list without recommended friends
// int recommendLimit = -1; // Set it to -1 if you want to include all of your recommended friends (the number of recommended friends is variably)
// [TODO] Set start value for querying friend list
int offset; // Start value for querying friend list
// [TODO] Set size of querying friend list
int limit; // Friend list size
// Querying KakaoTalk Invitation Target List
KGKakaoInvitation.loadInvitableFriendProfiles(recommendLimit, offset, limit, new KGResultCallback<KGKakaoFriendsResponse>() {
@Override
public void onResult(KGResult<KGKakaoFriendsResponse> result) {
if (result.isSuccess()) {
// Success
// Query of invitation target friend profile list successful
KGKakaoFriendsResponse response = result.getContent();
// Total count of friends you can invite
int totalCount = response.getTotalCount();
// Invite Friend List - list of friend profile objects to use when sending invitation messages
List<KGKakaoProfile> friendList = response.getFriendList();
for (KGKakaoProfile kakaoProfile : friendList) {
// KakaoTalk nickname
String nickname = kakaoProfile.getNickname();
// KakaoTalk profile thumbnail image url
String thumbnailImageUrl = kakaoProfile.getThumbnailImageUrl();
// If this user is a recommended friend or not
boolean isRecommended = kakaoProfile.isRecommended();
// KakaoTalk installation os
String talkOs = kakaoProfile.getTalkOs();
// Whether your friends are allowed to get messages or not. You must not send message if it is 'false'.
boolean isAllowMessage = kakaoProfile.isAllowedMessage();
}
} else if (result.getCode() == KGResult.KGResultCode.NOT_KAKAOTALK_USER) {
// The user is not a KakaoTalk user.
} else {
// Fail...
}
}
}); |
|
iOS 예제
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// [TODO] Set limit of recommended friends
int recommendLimit = 5; // The number of recommended friends
// int recommendLimit = 0; // Set to 0 if you want to fetch the list without recommended friends
// int recommendLimit = -1; // Set it to -1 if you want to include all of your recommended friends (the number of recommended friends is variably)
// [TODO] Set start value for querying friend list
int offset; // Start value for querying friend list
// [TODO] Set size of querying friend list
int limit; // Friend list size
// Querying KakaoTalk Invitation Target List
[KGKakaoInvitation loadInvitableFriendProfilesWithRecommendLimit:recommendLimit offset:offset limit:limit completionHandler:^(NSError *error, int totalCount, NSArray *idpProfiles) {
if (IS_SUCCESS(error) == YES)
{
// Success
// Query of invitation target friend profile list successful
for (KGKakaoProfile *kakaoProfile in idpProfiles)
{
// KakaoTalk nickname
NSString *nickname = kakaoProfile.nickname;
// KakaoTalk profile thumbnail image url
NSString *thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If this user is a recommended friend or not
BOOL isRecommended = kakaoProfile.isRecommended;
// KakaoTalk installation os
NSString *talkOs = kakaoProfile.kakaoTalkOS.description;
// Whether your friends are allowed to get messages or not. You must not send message if it is 'false'.
BOOL isAllowMessage = kakaoProfile.isAllowedMessage;
}
}
else if (error.code == KGErrorNotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail...
}
}]; |
|
Windows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Set limit of recommended friends
int32_t recommendLimit = 5; // The number of recommended friends
// int32_t recommendLimit = 0; // Set to 0 if you want to fetch the list without recommended friends
// int32_t recommendLimit = -1; // Set it to -1 if you want to include all of your recommended friends (the number of recommended friends is variably)
// [TODO] Set start value for querying friend list
int32_t offset; // Start value for querying friend list
// [TODO] Set size of querying friend list
int32_t limit; // Friend list size
KakaoGame::Data::KGResult result;
int32_t totalCount;
std::vector<KakaoGame::Data::KGKakaoProfile> players;
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// Querying KakaoTalk Invitation Target List
kgKakaoInvitation.loadInvitableFriendProfiles(recommendLimit , offset, limit, result, players);
if (result.isSuccess()) {
// Success
for (KakaoGame::Data::KGKakaoProfile kakaoProfile : players) {
// KakaoTalk nickname
std::wtring nickname = kakaoProfile.nickname;
// KakaoTalk profile thumbnail image url
std::wtring thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// KakaoTalk installation os
KakaoGame::Data::KGOSType kakaoTalkOS = kakaoProfile.kakaoTalkOS;
// Whether your friends are allowed to get messages or not. You must not send message if it is 'false'.
bool allowedMessage = kakaoProfile.allowedMessage;
}
}
else if (result.code == KakaoGame::Data::KGResultCode::NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail...
}
|
|
Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Set limit of recommended friends
int32_t recommendLimit = 5; // The number of recommended friends
// int32_t recommendLimit = 0; // Set to 0 if you want to fetch the list without recommended friends
// int32_t recommendLimit = -1; // Set it to -1 if you want to include all of your recommended friends (the number of recommended friends is variably)
// [TODO] Set start value for querying friend list
int32_t offset; // Start value for querying friend list
// [TODO] Set size of querying friend list
int32_t limit; // Friend list size
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// Querying KakaoTalk Invitation Target List
kgKakaoInvitation.loadInvitableFriendProfiles(recommendLimit, offset, limit, [this](KakaoGame::Data::KGResult result, std::vector<KakaoGame::Data::KGKakaoProfile> players) {
if (result.isSuccess()) {
// Success
for (KakaoGame::Data::KGKakaoProfile kakaoProfile : players)
{
// KakaoTalk nickname
std::wtring nickname = kakaoProfile.nickname;
// KakaoTalk profile thumbnail image url
std::wtring thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// KakaoTalk installation os
KakaoGame::Data::KGOSType kakaoTalkOS = kakaoProfile.kakaoTalkOS;
// Whether your friends are allowed to get messages or not. You must not send message if it is 'false'.
bool allowedMessage = kakaoProfile.allowedMessage;
}
}
else if (result.code == KakaoGame::Data::KGResultCode::NotKakaoTalkUser) {
// The user is not a KakaoTalk user.
}
else {
// Fail...
}
});
|
|
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
// [TODO] Set start value for querying friend list
int32 offset = 0; // Start value for querying friend list
// [TODO] Set size of querying friend list
int32 limit = 500; // Friend list size
// Querying KakaoTalk Invitation Target List
FKGKakaoInvitation::LoadInvitableFriendProfiles(0, offset, limit, FKGResultWithKakaoProfilesDelegate::CreateLambda([=](FKGResult result, int32 totalCount, TArray<FKGKakaoProfile> kakaoProfiles) {
if (result.IsSuccess())
{
// Success
for (FKGKakaoProfile kakaoProfile : kakaoProfiles)
{
// KakaoTalk nickname
FString nickname = kakaoProfile.GetNickname();
// KakaoTalk profile thumbnail image url
FString thumbnailImageUrl = kakaoProfile.GetThumbnailImageUrl();
// KakaoTalk installation os
EKGOSType talkOs = kakaoProfile.GetKakaoTalkOS();
// Whether your friends are allowed to get messages or not. You must not send message if it is 'false'.
bool isAllowMessage = kakaoProfile.IsAllowedMessage();
}
}
else if (result.GetCode() == FKGResultCode::NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail
}
})); |
|
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;
using Kakaogame.SDK.Kakao;
// [TODO] Set event Id
int eventId = 511; // Send the invitation message for this event
// [TODO] Set invitation message template ID
int templateId = 4100; // The Id value of the template created by the Message Template Admin
// [TODO] Add required arguments to invitation message
String nickname = ((KGKakaoProfile) KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
Map<String, String> args = new LinkedHashMap<String, String>();
args.put("${sender_name}", nickname);
// [TODO] Set up recipient profiles
KGKakaoProfile kakaoProfile; // The profile object looked up by 'loadInvitableFriendProfiles'
// Send a Kakaotalk invitation message
KGKakaoInvitation.SendInviteMessage(eventId, kakaoProfile, templateId, args, (result) => {
if (result.isSuccess)
{
// Success
}
else
{
// Failed to send Kakao Talk invitation message
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 if (result.code == KGResultCode.NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Other errors...
}
}
}); |
|
Android 예제
코드 블럭 |
---|
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGLocalPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;
// [TODO] Set event Id
int eventId = 511; // Send the invitation message for this event
// [TODO] Set invitation message template ID
int templateId = 4100; // The Id value of the template created by the Message Template Admin
// [TODO] Add required arguments to invitation message
string nickname = ((KGKakaoProfile) KGLocalPlayer.currentPlayer.idpProfile).nickname;
Dictionary<String, String> args = new Dictionary<String, String>();
args.add("${sender_name}", nickname);
// [TODO] Set up recipient profiles
KGKakaoProfile kakaoProfile; // The profile object looked up by 'loadInvitableFriendProfiles'
// Send a Kakaotalk invitation message
KGKakaoInvitation.sendInviteMessage(eventId, kakaoProfile, templateId, args, new KGResultCallback<Void>() {
@Override
public void onResult(KGResult<Void> result) {
if (result.isSuccess()) {
// Success
} 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 if (result.getCode() == KGResult.KGResultCode.NOT_KAKAOTALK_USER) {
// The user is not a KakaoTalk user.
} else {
// Other errors...
}
}
}
}); |
|
iOS 예제
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// [TODO] Set event Id
int eventId = 511; // Send the invitation message for this event
// [TODO] Set invitation message template ID
int templateId = 4100; // The Id value of the template created by the Message Template Admin
// [TODO] Add required arguments to invitation message
String nickname = ((KGKakaoProfile) KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
Map<String, String> args = new LinkedHashMap<String, String>();
args.put("${sender_name}", nickname);
// [TODO] Set up recipient profiles
KGKakaoProfile kakaoProfile; // The profile object looked up by 'loadInvitableFriendProfiles'
// Send a Kakaotalk invitation message
[KGKakaoInvitation sendInviteMessageWithEventId:eventId kakaoProfile:kakaoProfile templateId:templateId argumentDic:args (result) => {
if (IS_SUCCESS(error) == YES)
{
// Success
}
else 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 == KGErrorExceedMothlyUsage)
{
// 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
{
// Failed to send Kakao Talk invitation message
}
}]; |
|
Windows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::Data::KGLocalPlayer localPlayer;
KakaoGame::API::KGLocalPlayer kgLocalPlayer;
// [TODO] Bring your own profile object
getCurrentPlayer(localPlayer);
// [TODO] Set event Id
int32_t eventId = 511; // Send the invitation message for this event
// [TODO] Set invitation message template ID
int32_t templateId = 4100; // The Id value of the template created by the Message Template Admin
// [TODO] Add required arguments to invitation message
std::map<std::wstring, std::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${sender_name}"), localPlayer.kakaoProfile.nickname));
// [TODO] Set up recipient profiles
KakaoGame::Data::KGKakaoProfile kakaoProfile; // The profile object looked up by 'loadInvitableFriendProfiles'
KakaoGame::Data::KGResult result;
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// Send a Kakaotalk invitation message
kgKakaoInvitation.sendInviteMessage(eventId, kakaoProfile, templateId, arguments, result);
if (result.isSuccess()) {
// Success
}
else {
// Failed to send Kakao Talk invitation message
if (result.code == KakaoGame::Data::KGResultCode::MessageSettingDisabled) {
// If the recipient has opted-out of the message
} else if (result.code == KakaoGame::Data::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 == KakaoGame::Data::KGResultCode::ExceedMonthlyUsage) {
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app
} else if (result.code == KakaoGame::Data::KGResultCode::NotKakaoTalkUser) {
// The user is not a KakaoTalk user.
} else {
// Other errors...
}
}
|
|
Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::Data::KGLocalPlayer localPlayer;
KakaoGame::API::KGLocalPlayer kgLocalPlayer;
// [TODO] Bring your own profile object
getCurrentPlayer(localPlayer);
// [TODO] Set event Id
int32_t eventId = 511; // Send the invitation message for this event
// [TODO] Set invitation message template ID
int32_t templateId = 4100; // The Id value of the template created by the Message Template Admin
// [TODO] Add required arguments to invitation message
std::map<std::wstring, std::wstring> arguments;
arguments.insert(std::pair<std::wstring, std::wstring>(TEXT("${sender_name}"), localPlayer.kakaoProfile.nickname));
// [TODO] Set up recipient profiles
KakaoGame::Data::KGKakaoProfile kakaoProfile; // The profile object looked up by 'loadInvitableFriendProfiles'
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// Send a Kakaotalk invitation message
kgKakaoInvitation.sendInviteMessage(eventId, kakaoProfile, templateId, arguments, [this](KakaoGame::Data::KGResult result) {
if (result.isSuccess()) {
// Success
}
else {
// Failed to send Kakao Talk invitation message
if (result.code == KakaoGame::Data::KGResultCode::MessageSettingDisabled) {
// If the recipient has opted-out of the message
} else if (result.code == KakaoGame::Data::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 == KakaoGame::Data::KGResultCode::ExceedMonthlyUsage) {
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app
} else if (result.code == KakaoGame::Data::KGResultCode::NotKakaoTalkUser) {
// The user is not a KakaoTalk user.
} else {
// Other errors...
}
}
});
|
|
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
// [TODO] Set event Id
int32 eventId = 511; // Send the invitation message for this event
// [TODO] Set invitation message template ID
FString templateId = TEXT("4100"); // The Id value of the template created by the Message Template Admin
// [TODO] Add required arguments to invitation message
FKGIdpProfile idpProfile = FKGLocalPlayer::GetCurrentPlayer().GetIdpProfile();
FKGKakaoProfile *localKakaoProfile = (FKGKakaoProfile*)&idpProfile;
FString nickname = localKakaoProfile->GetNickname();
TSharedPtr<FJsonObject> argumentMap = MakeShareable(new FJsonObject);
argumentMap->SetStringField(TEXT("${sender_name}"), nickname);
// [TODO] Set up recipient profiles
FKGKakaoProfile kakaoProfile; // The profile object looked up by 'loadInvitableFriendProfiles'
// Send a Kakaotalk invitation message
FKGKakaoInvitation::SendInviteMessage(eventId, kakaoProfile, templateId, argumentMap, FKGResultDelegate::CreateLambda([=](FKGResult result) {
if (result.IsSuccess())
{
// Success
}
else
{
// Failed to send Kakao Talk invitation message
if (result.GetCode() == FKGResultCode::MessageSettingDisabled)
{
// If the recipient has opted-out of the message
}
else if (result.GetCode() == FKGResultCode::ExceedDailyUsage)
{
// Occurs when there is a day's quota (regardless of recipient) that one person can send for a particular app
}
else if (result.GetCode() == FKGResultCode::ExceedMonthlyUsage)
{
// Occurs when one month exceeds a month's quota that a specific person can send to a particular app
}
else if (result.GetCode() == FKGResultCode::NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Other errors
}
}
})); |
|
21.1.4. Querying the number of friends I sent an invitation to
This section shows an example of a query of the count of friends who have received my invitation.
Unity 예제
코드 블럭 |
---|
using KakaoGame.SDK;
using KakaoGame.SDK.Kakao;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
KGKakaoInvitation.LoadReceiversCount(eventId, (result, totalReceiversCount, joinersCount) => {
if (result.isSuccess)
{
// Success
// Total receivers count
int totalCount = totalReceiversCount;
// Number of friends who joined the game
int registeredCount = joinersCount;
}
else
{
// Fail...
}
}); |
|
Android 예제
코드 블럭 |
---|
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGKakaoInvitation.KGInvitationReceviersResponse;
import com.kakaogame.KGPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;
// [TODO] Set |
|
limitof recommended friends
int recommendLimit 5ThenumberofrecommendedfriendsintrecommendLimit=0; // Set to 0 if you want to fetch the list without recommended friends
// int recommendLimit = -1; // Set it to -1 if you want to include all of your recommended friends (the number of recommended friends is variably)
// [TODO] Set start value for querying friend list
int offset; // Start value for querying friend list
of friends I sent an invitation to
KGKakaoInvitation.loadReceiversCount(eventId, new KGResultCallback<KGInvitationReceviersCountResponse>() {
@Override
public void onResult(KGResult<KGInvitationReceviersCountResponse> result) {
if (result.isSuccess()) {
// Success
KGInvitationReceviersCountResponse response = result.getContent();
// Total receivers count
int total = response.getTotalReceiversCount();
// Number of friends who joined the game
int joinersCount = response.getJoinersCount();
} else {
// Fail...
}
}
}); |
|
iOS 예제
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// [TODO] Set |
|
sizeofqueryingfriendlist
int limit; // Friend list size
KakaoTalkInvitationTargetList.LoadInvitableFriendProfiles(recommendLimit, offset, limit, (result, totalCount, kakaoProfiles) => loadReceiversCountWithEventId:eventId completionHandler:^(NSError *error, int totalReceiversCount, int joinersCount) {
if |
|
(result.isSuccess(IS_SUCCESS(error) == YES)
|
|
{ Success Total receivers count
int totalCount = totalReceiversCount;
// |
|
Queryinvitationtargetfriendprofilelistsuccessful
foreach (KGKakaoProfile kakaoProfile in kakaoProfiles)
{
// KakaoTalk nickname
string nickname = kakaoProfile.nickname;
// KakaoTalk profile thumbnail image url
string thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If this user is a recommended friend or not
BOOL isRecommended = kakaoProfile.isRecommended;
// KakaoTalk installation os
string talkOs = kakaoProfile.kakaoTalkOS.ToString();
// Whether your friends are allowed to get messages or not. You must not send message if it is 'false'.
bool isAllowMessage = kakaoProfile.isAllowedMessage;
}
}
else if (result.code == KGResultCode.NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
joinersCount;
}
else
{
// Fail...
}
}]; |
|
Windows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Set event Id
int32_t eventId = 511; // Querying this invitation event
KakaoGame::Data::KGResult result;
int32_t totalReceiversCount;
int32_t joinersCount;
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// Querying the number of friends I sent an invitation to
kgKakaoInvitation.loadReceiversCount(eventId, result, totalReceiversCount, joinersCount);
if (result.isSuccess()) {
// Success
// Total receivers count
int totalCount = totalReceiversCount;
// Number of friends who joined the game
int registeredCount = joinersCount;
}
else {
// Fail...
|
|
});...
Windows Async
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGKakaoProfile.KGKakaoFriendsResponse;
import com.kakaogame.KGResult;#include "KakaoGameLib.h"
// [TODO] Set |
|
limit of recommended friends
int recommendLimit = 5; // The number of recommended friends
// int recommendLimit = 0; // Set to 0 if you want to fetch the list without recommended friends
// int recommendLimit = -1; // Set it to -1 if you want to include all of your recommended friends (the number of recommended friends is variably)
// [TODO] Set start value for querying friend list
int offset; // Start value for querying friend list
// [TODO] Set size of querying friend list
int limit; // Friend list size
// Querying KakaoTalk Invitation Target List
KGKakaoInvitation.loadInvitableFriendProfiles(recommendLimit, offset, limit, new KGResultCallback<KGKakaoFriendsResponse>() {
@Override
public void onResult(KGResult<KGKakaoFriendsResponse> result) {
if (result.isSuccess()) {
// Success
// Query of invitation target friend profile list successful
KGKakaoFriendsResponse response = result.getContent();
// Total count of friends you can invite
int totalCount = response.getTotalCount();
// Invite Friend List - list of friend profile objects to use when sending invitation messages
List<KGKakaoProfile> friendList = response.getFriendList();
for (KGKakaoProfile kakaoProfile : friendList) {
// KakaoTalk nickname
String nickname = kakaoProfile.getNickname();
// KakaoTalk profile thumbnail image url
String thumbnailImageUrl = kakaoProfile.getThumbnailImageUrl();
// If this user is a recommended friend or not
boolean isRecommended = kakaoProfile.isRecommended();
// KakaoTalk installation os
String talkOs = kakaoProfile.getTalkOs();
// Whether your friends are allowed to get messages or not. You must not send message if it is 'false'.
boolean isAllowMessage = kakaoProfile.isAllowedMessage();
}
} else if (result.getCode() == KGResult.KGResultCode.NOT_KAKAOTALK_USER) {
// The user is not a KakaoTalk user.
} else {
// Fail...
}
}
}); iOS 예제
코드 블럭 |
#import <KakaoGame/KakaoGame.h>
// [TODO] Set limit of recommended friends
int recommendLimit = 5; // The number of recommended friends
// int recommendLimit = 0; // Set to 0 if you want to fetch the list without recommended friends
// int recommendLimit = -1; // Set it to -1 if you want to include all of your recommended friends (the number of recommended friends is variably)
// [TODO] Set start value for querying friend list
int offset; // Start value for querying friend list
// [TODO] Set size of querying friend list
int limit; // Friend list size
// Querying KakaoTalk Invitation Target List
[KGKakaoInvitation loadInvitableFriendProfilesWithRecommendLimit:recommendLimit offset:offset limit:limit completionHandler:^(NSError *error, int totalCount, NSArray *idpProfiles) {
if (IS_SUCCESS(error) == YES)
{
// Success
// Query of invitation target friend profile list successful
for (KGKakaoProfile *kakaoProfile in idpProfiles)
{
// KakaoTalk nickname
NSString *nickname = kakaoProfile.nickname;
// KakaoTalk profile thumbnail image url
NSString *thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If this user is a recommended friend or not
BOOL isRecommended = kakaoProfile.isRecommended;
// KakaoTalk installation os
NSString *talkOs = kakaoProfile.kakaoTalkOS.description;
// Whether your friends are allowed to get messages or not. You must not send message if it is 'false'.
BOOL isAllowMessage = kakaoProfile.isAllowedMessage;
}
}
else if (error.code == KGErrorNotKakaoTalkUser)
{
event Id
int32_t eventId = 511; // Querying this invitation event
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// Querying the number of friends I sent an invitation to
kgKakaoInvitation.loadReceiversCount(eventId, [this](KakaoGame::Data::KGResult result, int32_t totalReceiversCount, int32_t joinersCount) {
if (result.isSuccess()) {
// Success
// Total receivers count
int totalCount = totalReceiversCount;
// Number of friends who joined the game
int registeredCount = joinersCount;
}
else {
// Fail...
}
});
|
|
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
// [TODO] Set event Id
int32 eventId = 511; // Querying this invitation event
FKGKakaoInvitation::LoadReceiversCount(eventId, FKGResultWithReceiversCountDelegate::CreateLambda([=](FKGResult result, int32 totalReceiversCount, int32 joinersCount) {
if (result.IsSuccess())
{
// Success
// Total receivers count
int32 totalCount = totalReceiversCount;
// Number of friends who joined the game
int32 registeredCount = joinersCount;
}
else
{
// Fail
}
})); |
|
21.1.5. Querying the list of friends I sent an invitation to
This section shows an example of a query of the list of friends who have received my invitation.
Unity 예제
코드 블럭 |
---|
using KakaoGame.SDK;
using KakaoGame.SDK.Kakao;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
// Querying the list of friends I sent an invitation to
KGKakaoInvitation.LoadReceivers(eventId, (result, joiners, invitees) => {
if (result.isSuccess)
{
// Success
// List of players joined to the app, including unlink users
foreach (KGPlayer joiner in joiners)
{
// Receiver's playerId
string playerId = joiner.playerId;
KGKakaoProfile kakaoProfile = (KGKakaoProfile)joiner.idpProfile;
// Receiver's nickname
string nickname = kakaoProfile.nickname;
// Receiver's KakaoTalk thumbnail profile image url
string thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If the player has unlinked this app or not
// If you want to display information on whether or not to leave the UI, use this flag
BOOL isUnregistered = kakaoProfile.isUnregistered;
}
// List of recipients who have not yet joined the app
// Player ID is not provided because the user has not signed up for the app
foreach (KGKakaoPrfoile invitee in invitees)
{
// Receiver's nickname
string nickname = invitee.nickname;
// Receiver's KakaoTalk thumbnail profile image url
string thumbnailImageUrl = invitee.thumbnailImageUrl;
}
}
else if (result.code == KGResultCode.NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail...
}
}); |
|
Android 예제
코드 블럭 |
---|
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGKakaoInvitation.KGInvitationReceviersResponse;
import com.kakaogame.KGPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
// Querying the list of friends I sent an invitation to
KGKakaoInvitation.loadReceivers(eventId, new KGResultCallback<KGKakaoInvitation.KGInvitationReceviersResponse>() {
@Override
public void onResult(KGResult<KGKakaoInvitation.KGInvitationReceviersResponse> result) {
if (result.isSuccess()) {
// Success
KGKakaoInvitation.KGInvitationReceviersResponse receivers = result.getContent();
// List of players joined to the app, including unlink users
List<KGPlayer> joiners = receivers.getJoiners();
for (KGPlayer player : joiners) {
// Receiver's playerId
String playerId = player.getPlayerId();
KGKakaoProfile kakaoProfile = (KGKakaoProfile) player.getIdpProfile();
// Receiver's nickname
String nickname = kakaoProfile.getNickname();
// Receiver's KakaoTalk thumbnail profile image url
String thumbnailImageUrl = kakaoProfile.getThumbnailImageUrl();
// If the player has unlinked this app or not
// If you want to display information on whether or not to leave the UI, use this flag
boolean isUnregistered = kakaoProfile.isUnregistered();
}
// List of recipients who have not yet joined the app
// Player ID is not provided because the user has not signed up for the app
List<KGKakaoProfile> invitees = receivers.getInvitees();
for (KGKakaoProfile kakaoProfile : invitees) {
// Receiver's nickname
String nickname = kakaoProfile.getNickname();
// Receiver's KakaoTalk thumbnail profile image url
String thumbnailImageUrl = kakaoProfile.getThumbnailImageUrl();
}
} else if (result.getCode() == KGResult.KGResultCode.NOT_KAKAOTALK_USER) {
// The user is not a KakaoTalk user.
|
|
}
else
}
}];21.1.3. Sending a KakaoTalk Invitation Message
This section shows an example of KakaoTalk invitation message sending. (Guide :20. Kakaotalk Message Template V2 )
...
iOS 예제
using Kakaogame.SDK;
using Kakaogame.SDK.Kakao;#import <KakaoGame/KakaoGame.h>
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
// |
|
SendQuerying the list of friends I sent an invitation |
|
message for this event
// [TODO] Set invitation message template ID
int templateId = 4100; // The Id value of the template created by the Message Template Admin
// [TODO] Add required arguments to invitation message
String nickname = ((KGKakaoProfile) KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
Map<String, String> args = new LinkedHashMap<String, String>();
args.put("${sender_name}", nickname);
// [TODO] Set up recipient profiles
KGKakaoProfile kakaoProfile; // The profile object looked up by 'loadInvitableFriendProfiles'
// Send a Kakaotalk invitation message
KGKakaoInvitation.SendInviteMessage(eventId, kakaoProfile, templateId, args, (result) => {
if (result.isSuccess)
{
// Success
}
else
{
// Failed to send Kakao Talk invitation message
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.ExceedMonthlyUsageto
[KGKakaoInvitation loadReceiversWithEventId:eventId completionHandler:^(NSError *error, NSArray *joiners, NSArray *invitees) {
if (IS_SUCCESS(error) == YES)
{
// Success
// List of players joined to the app, including unlink users
for (KGPlayer *joiner in joiners)
{
// Receiver's playerId
NSString *playerId = joiner.playerId;
KGKakaoProfile *kakaoProfile = (KGKakaoProfile*)joiner.idpProfile;
// Receiver's nickname
NSString *nickname = kakaoProfile.nickname;
// Receiver's KakaoTalk thumbnail profile image url
NSString *thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If the player has unlinked this app or not
// If you want to display information on whether or not to leave the UI, use this flag
BOOL isUnregistered = kakaoProfile.isUnregistered;
}
// List of recipients who have not yet joined the app
// Player ID is not provided because the user has not signed up for the app
for (KGKakaoPrfoile *invitee in invitees)
{
// |
|
Occurs when one month exceeds a month's quota that a specific person can send to a particular app
}
else if (resultReceiver's nickname
NSString *nickname = invitee.nickname;
// Receiver's KakaoTalk thumbnail profile image url
NSString *thumbnailImageUrl = invitee.thumbnailImageUrl;
}
}
else if (error.code == |
|
KGResultCode.NotKakaoTalkUser // The user is not a KakaoTalk user.
|
|
else Othererrors }
) Android 예제Windows Sync
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGLocalPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;#include "KakaoGameLib.h"
// [TODO] Set event Id
int32_t |
|
int eventId 511Sendthemessage for this event
// [TODO] Set invitation message template ID
int templateId = 4100; // The Id value of the template created by the Message Template Admin
// [TODO] Add required arguments to invitation message
string nickname = ((KGKakaoProfile) KGLocalPlayer.currentPlayer.idpProfile).nickname;
Dictionary<String, String> args = new Dictionary<String, String>();
args.add("${sender_name}", nickname);
// [TODO] Set up recipient profiles
KGKakaoProfile kakaoProfile; // The profile object looked up by 'loadInvitableFriendProfiles'
// Send a Kakaotalk invitation message
KGKakaoInvitation.sendInviteMessage(eventId, kakaoProfile, templateId, args, new KGResultCallback<Void>() {
@Override
public void onResult(KGResult<Void> result) {
if (result.isSuccess()) {
// Success
} 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 if (result.getCode() == KGResult.KGResultCode.NOT_KAKAOTALK_USER) {
// The user is not a KakaoTalk user.
} else {
// Other errors...
}
}
}
}); iOS 예제
코드 블럭 |
#import <KakaoGame/KakaoGame.h>event
KakaoGame::Data::KGResult result;
std::vector<KakaoGame::Data::KGPlayer> joiners;
std::vector<KakaoGame::Data::KGKakaoProfile> invitees;
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// Querying the list of friends I sent an invitation to
kgKakaoInvitation.loadReceivers(eventId, result, joiners, invitees);
if (result.isSuccess()) {
// Success
// List of players joined to the app, including unlink users
for (KakaoGame::Data::KGPlayer joiner : joiners) {
// Receiver's playerId
std::wstring playerId = player.playerId;
KakaoGame::Data::KGKakaoProfile kakaoProfile = player.kakaoProfile;
// Receiver's nickname
std::wstring nickname = kakaoProfile.nickname;
// Receiver's KakaoTalk thumbnail profile image url
std::wstring thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If the player has unlinked this app or not
// If you want to display information on whether or not to leave the UI, use this flag
bool unregistered = kakaoProfile.unregistered;
}
// List of recipients who have not yet joined the app
// Player ID is not provided because the user has not signed up for the app
for (KakaoGame::Data::KGKakaoProfile invitee : invitees) {
// Receiver's nickname
std::wstring nickname = invitee.nickname;
// Receiver's KakaoTalk thumbnail profile image url
std::wstring thumbnailImageUrl= invitee.thumbnailImageUrl;
}
}
else
{
// Fail...
}
|
|
Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Set event Id
int32_t |
|
int eventIdSendthemessage for this // [TODO] Set invitation message template ID
int templateId = 4100; // The Id value of the template created by the Message Template Admin
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// |
|
[TODO]AddrequiredargumentstoinvitationmessageStringnickname=((KGKakaoProfile) KGLocalPlayer.getCurrentPlayer().getIdpProfile()).getNickname();
Map<String, String> args = new LinkedHashMap<String, String>();
args.put("${sender_name}", nickname);
// [TODO] Set up recipient profiles
KGKakaoProfile kakaoProfile; // The profile object looked up by 'loadInvitableFriendProfiles'
// Send a Kakaotalk invitation message
[KGKakaoInvitation sendInviteMessageWithEventId:eventId kakaoProfile:kakaoProfile templateId:templateId argumentDic:args (result) => {
if (IS_SUCCESS(error) == YES)
{
// Success
}
else if (error.code == KGErrorMessageSettingDisabled)
{
kgKakaoInvitation.loadReceivers(eventId, [this](KakaoGame::Data::KGResult result, std::vector<KakaoGame::Data::KGPlayer> joiners, std::vector<KakaoGame::Data::KGKakaoProfile> invitees) {
if (result.isSuccess())
{
// Success
// List of players joined to the app, including unlink users
for (KakaoGame::Data::KGPlayer joiner : joiners) {
// Receiver's playerId
std::wstring playerId = player.playerId;
KakaoGame::Data::KGKakaoProfile kakaoProfile = player.kakaoProfile;
// Receiver's nickname
std::wstring nickname = kakaoProfile.nickname;
// Receiver's KakaoTalk thumbnail profile image url
std::wstring thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If the |
|
recipient 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 == KGErrorExceedMothlyUsage)
{
// 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
{
// Failed to send Kakao Talk invitation message
}
}];21.1.4. Querying the number of friends I sent an invitation to
This section shows an example of a query of the count of friends who have received my invitation.
Unity 예제
코드 블럭 |
using KakaoGame.SDK;
using KakaoGame.SDK.Kakao; unlinked this app or not
// If you want to display information on whether or not to leave the UI, use this flag
bool unregistered = kakaoProfile.unregistered;
}
// List of recipients who have not yet joined the app
// Player ID is not provided because the user has not signed up for the app
for (KakaoGame::Data::KGKakaoProfile invitee : invitees) {
// Receiver's nickname
std::wstring nickname = invitee.nickname;
// Receiver's KakaoTalk thumbnail profile image url
std::wstring thumbnailImageUrl= invitee.thumbnailImageUrl;
}
}
else
{
// Fail...
}
});
|
|
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
// [TODO] Set event Id
int32 |
|
int eventIdeventId = 511; // Querying this invitation event
|
|
KGKakaoInvitation.LoadReceiversCount
FKGKakaoInvitation::LoadReceivers(eventId, FKGResultWithReceiversDelegate::CreateLambda([=](FKGResult result, TArray<FKGPlayer> |
|
totalReceiversCountjoiners, TArray<FKGKakaoProfile> |
|
joinersCount=> if isSuccess
// Total receivers count
int totalCount = totalReceiversCount;
Numberfriendswhojoinedgame int registeredCount= joinersCount;
}
else for (FKGPlayer player : joiners)
{
|
|
Fail...
}
});Android 예제
...
코드 블럭 |
---|
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGKakaoInvitation.KGInvitationReceviersResponse;
import com.kakaogame.KGPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
// Querying the number of friends I sent an invitation to
KGKakaoInvitation.loadReceiversCount(eventId, new KGResultCallback<KGInvitationReceviersCountResponse>() {
@Override
public void onResult(KGResult<KGInvitationReceviersCountResponse> result) {
if (result.isSuccess()) {
// Success
KGInvitationReceviersCountResponse response = result.getContent();
// Total receivers count
int total = response.getTotalReceiversCount();
// Number of friends who joined the game
int joinersCount = response.getJoinersCount();
} else {
// Fail...
}
}
}); |
iOS 예제
...
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
[KGKakaoInvitation loadReceiversCountWithEventId:eventId completionHandler:^(NSError *error, int totalReceiversCount, int joinersCount) {
if (IS_SUCCESS(error) == YES)
{
// Success
// Total receivers count
int totalCount = totalReceiversCount;
// Number of friends who joined the game
int registeredCount = joinersCount;
}
else
{
// Fail...
}
}]; |
...
Receiver's playerId
FString playerId = player.GetPlayerId();
FKGIdpProfile idpProfile = player.GetIdpProfile();
FKGKakaoProfile *kakaoProfile = (FKGKakaoProfile*)&idpProfile;
// Receiver's nickname
FString nickname = kakaoProfile->GetNickname();
// Receiver's KakaoTalk thumbnail profile image url
FString thumbnailImageUrl = kakaoProfile->GetThumbnailImageUrl();
// If the player has unlinked this app or not
// If you want to display information on whether or not to leave the UI, use this flag
bool unregistered = kakaoProfile->IsUnregistered();
}
// List of recipients who have not yet joined the app
// Player ID is not provided because the user has not signed up for the app
for (FKGKakaoProfile invitee : invitees)
{
// Receiver's nickname
FString inviteeNickname = invitee.GetNickname();
// Receiver's KakaoTalk thumbnail profile image url
FString inviteeThumbnailImageUrl = invitee.GetThumbnailImageUrl();
}
}
else
{
// Fail
}
})); |
|
21.1.6. Querying the count of players who invited you
This section shows an example of a query of the list count of friends who have received my invitationplayers who invited you.
Unity 예제
코드 블럭 |
---|
using KakaoGame.SDK;
using KakaoGame.SDK.Kakao;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
|
|
//Querying the list of friends I sent an invitation to
LoadReceiversLoadSendersCount(eventId, (result, |
|
joiners, inviteescount) => {
if (result.isSuccess)
{
// |
|
Success
// List of players joined to the app, including unlink users
foreach (KGPlayer joiner in joiners)
{
// Receiver's playerId
string playerId = joiner.playerId;
KGKakaoProfile kakaoProfile = (KGKakaoProfile)joiner.idpProfile;
// Receiver's nickname
string nickname = kakaoProfile.nickname;
// Receiver's KakaoTalk thumbnail profile image url
string thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If the player has unlinked this app or not
// If you want to display information on whether or not to leave the UI, use this flag
BOOL isUnregistered = kakaoProfile.isUnregistered;
}
// List of recipients who have not yet joined the app
// Player ID is not provided because the user has not signed up for the app
foreach (KGKakaoPrfoile invitee in invitees)
{
// Receiver's nickname
string nickname = invitee.nickname;
// Receiver's KakaoTalk thumbnail profile image url
string thumbnailImageUrl = invitee.thumbnailImageUrl;
}
}
else if (result.code == KGResultCode.NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
// Fail...
}
});Android 예제
...
코드 블럭 |
---|
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGKakaoInvitation.KGInvitationReceviersResponse;
import com.kakaogame.KGPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
// Querying the list of friends I sent an invitation to
KGKakaoInvitation.loadReceivers(eventId, new KGResultCallback<KGKakaoInvitation.KGInvitationReceviersResponse>() {
@Override
public void onResult(KGResult<KGKakaoInvitation.KGInvitationReceviersResponse> result) {
if (result.isSuccess()) {
// Success
KGKakaoInvitation.KGInvitationReceviersResponse receivers = result.getContent();
// List of players joined to the app, including unlink users
List<KGPlayer> joiners = receivers.getJoiners();
for (KGPlayer player : joiners) {
// Receiver's playerId
String playerId = player.getPlayerId();
KGKakaoProfile kakaoProfile = (KGKakaoProfile) player.getIdpProfile();
// Receiver's nickname
String nickname = kakaoProfile.getNickname();
// Receiver's KakaoTalk thumbnail profile image url
String thumbnailImageUrl = kakaoProfile.getThumbnailImageUrl();
// If the player has unlinked this app or not
// If you want to display information on whether or not to leave the UI, use this flag
boolean isUnregistered = kakaoProfile.isUnregistered();
}
// List of recipients who have not yet joined the app
// Player ID is not provided because the user has not signed up for the app
List<KGKakaoProfile> invitees = receivers.getInvitees();
for (KGKakaoProfile kakaoProfile : invitees) {
// Receiver's nickname
String nickname = kakaoProfile.getNickname();
// Receiver's KakaoTalk thumbnail profile image url
String thumbnailImageUrl = kakaoProfile.getThumbnailImageUrl();
}
} else if (result.getCode() == KGResult.KGResultCode.NOT_KAKAOTALK_USER) {
// The user is not a KakaoTalk user.
} else {
// Fail...
}
}
}); |
iOS 예제
코드 블럭 |
#import <KakaoGame/KakaoGame.h>
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
// Querying the list of friends I sent an invitation to
[KGKakaoInvitation loadReceiversWithEventId:eventId completionHandler:^(NSError *error, NSArray *joiners, NSArray *invitees) {
if (IS_SUCCESS(error) == YESSuccess
// Get the number of players who invited you
int senderCount = count;
}
else
{
// Fail...
}
}); |
|
Android 예제
코드 블럭 |
---|
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGKakaoInvitation.KGInvitationReceviersResponse;
import com.kakaogame.KGPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
KGKakaoInvitation.loadSendersCount(eventId, new KGResultCallback<Integer>() {
@Override
public void onResult(KGResult<Integer> result) {
if (result.isSuccess()) {
// Success
int count = result.getContent(); // Get the number of players who invited you
} else {
// Fail...
}
}
}); |
|
iOS 예제
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
[KGKakaoInvitation loadSendersCountWithEventId:eventId completionHandler:^(NSError *error, int count) {
if (IS_SUCCESS(error) == YES)
{
// Success
// Get the number of players who invited you
int senderCount = count;
}
else
{
// Fail...
}
}]; |
|
Windows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Set event Id
int32_t eventId = 511; // Querying this invitation event
KakaoGame::Data::KGResult result;
int32_t count;
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
kgKakaoInvitation.loadSendersCount(eventId, result, count);
if (result.isSuccess()) {
// Success
// Get the number of players who invited you
int senderCount = count;
}
else {
// Fail...
}
|
|
Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
// [TODO] Set event Id
int32_t eventId = 511; // Querying this invitation event
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
kgKakaoInvitation.loadSendersCount(eventId, [this](KakaoGame::Data::KGResult result, int32_t count) {
if (result.isSuccess()) {
// Success
// Get the number of players who invited you
int senderCount = count;
}
else {
// Fail...
}
});
|
|
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
// [TODO] Set event Id
int32 eventId = 511; // Querying this invitation event
FKGKakaoInvitation::LoadSendersCount(eventId, FKGResultWithSendersCountDelegate::CreateLambda([=](FKGResult result, int32 count) {
if (result.isSuccess)
{
// Success
// Get the number of players who invited you
int32 senderCount = count;
}
else
{
// Fail...
}
})); |
|
21.1.7. Querying the list of players who invited you
This section shows an example of a query the list of players who invited you.
Unity 예제
코드 블럭 |
---|
using KakaoGame.SDK;
using KakaoGame.SDK.Kakao;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
// Querying the list of players who invited you
KGKakaoInvitation.LoadSenders(eventId, (result, invitationSenders) => {
if (result.isSuccess)
{
// Success
// Get the list of players who invited you
if (invitationSenders != null && invitationSenders.Count > 0)
{
foreach (KGPlayer player in invitationSenders)
{
// Get the playerId
string playerId = player.playerId;
KGKakaoProfile kakaoProfile = (KGKakaoProfile)player.idpProfile;
// player's nickname
string nickname = kakaoProfile.nickname;
// player's KakaoTalk thumbnail image url
string thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
}
}
else
{
// No players who invited you
}
}
else if (result.code == KGResultCode.NotKakaoTalkUser)
{
// |
|
Success //Listofplayersjoinedtotheapp, including unlink users
for (KGPlayer *joiner in joiners)
{
// Receiver's playerId
NSString *playerId = joiner.playerId;
KGKakaoProfile *kakaoProfile = (KGKakaoProfile*)joiner.idpProfile;
// Receiver's nickname
NSString *nickname = kakaoProfile.nickname;
// Receiver's KakaoTalk thumbnail profile image url
NSString *thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
// If the player has unlinked this app or not
// If you want to display information on whether or not to leave the UI, use this flag
BOOL isUnregistered = kakaoProfile.isUnregistered;
}
// List of recipients who have not yet joined the app
// Player ID is not provided because the user has not signed up for the app
for (KGKakaoPrfoile *invitee in invitees)
{
// Receiver's nickname
NSString *nickname = invitee.nickname;
// Receiver's KakaoTalk thumbnail profile image url
NSString *thumbnailImageUrl = invitee.thumbnailImageUrl;
}
}
else if (error.code == KGErrorNotKakaoTalkUser)
{
Android 예제
코드 블럭 |
---|
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
// Querying the list of players who invited you
KGKakaoInvitation.loadSenders(eventId, new KGResultCallback<List<KGPlayer>>() {
@Override
public void onResult(KGResult<List<KGPlayer>> result) {
if (result.isSuccess()) {
// Success
// Get the list of players who invited you
List<KGPlayer> invitationSenders = result.getContent();
if (invitationSenders != null && invitationSenders.size() > 0) {
for (KGPlayer player : invitationSenders) {
// Get the playerId
String playerId = player.getPlayerId();
KGKakaoProfile kakaoProfile = (KGKakaoProfile) player.getIdpProfile();
// player's nickname
String nickname = kakaoProfile.getNickname();
// player's KakaoTalk thumbnail image url
String thumbnailImageUrl = kakaoProfile.getThumbnailImageUrl();
}
} else {
// No players who invited you
}
} else if (result.getCode() == KGResult.KGResultCode.NOT_KAKAOTALK_USER) {
// The user is not a KakaoTalk user.
|
|
}
else
];21.1.6. Querying the count of players who invited you
This section shows an example of a query the count of players who invited you.
...
iOS 예제
using KakaoGame.SDK;
using KakaoGame.SDK.Kakao;#import <KakaoGame/KakaoGame.h>
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
|
|
KGKakaoInvitation.LoadSendersCount(eventId, (result, count) => {
if (result.isSuccess)
{
// Success
// Get the number
// Querying the list of players who invited you
|
|
int senderCount = count;
}
else
{
// Fail...
}
}); Android 예제
코드 블럭 |
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGKakaoInvitation.KGInvitationReceviersResponse;
import com.kakaogame.KGPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
KGKakaoInvitation.loadSendersCount(eventId, new KGResultCallback<Integer>() {
@Override
public void onResult(KGResult<Integer> result) {
if (result.isSuccess()) {
// Success
int count = result.getContent(); [KGKakaoInvitation loadSendersWithEventId:eventId completionHandler:^(NSError *error, NSArray *invitationSenders) {
if (IS_SUCCESS(error) == YES)
{
// Success
// Get the list of players who invited you
if (invitationSenders != nil && [invitationSenders count] > 0)
{
for (KGPlayer *invitationSender in invitationSenders)
{
// Get the |
|
numberofplayerswho invited you
} else {
// Fail...
}
}
});iOS 예제
코드 블럭 |
#import <KakaoGame/KakaoGame.h>
// [TODO] Set event Id
int eventId = 511; // Querying this invitation event
[KGKakaoInvitation loadSendersCountWithEventId:eventId completionHandler:^(NSError *error, int count) {
if (IS_SUCCESS(error) == YES= invitationSender.playerId;
KGKakaoProfile *kakaoProfile = (KGKakaoProfile*)invitationSender.idpProfile;
// player's nickname
NSString *nickname = kakaoProfile.nickname;
// player's KakaoTalk thumbnail image url
NSString *thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
}
}
}
else if (error.code == KGErrorNotKakaoTalkUser)
{
// |
|
Success //Getthenumber of players who invited you
int senderCount = count;KakaoTalk user.
}
else
{
// Fail...
}
}]; |
|
21.1.7. Querying the list of players who invited you
This section shows an example of a query the list of players who invited you.
Unity 예제Windows Sync
using KakaoGame.SDK;
using KakaoGame.SDK.Kakao;#include "KakaoGameLib.h"
// [TODO] Set event Id
|
|
int eventIdint32_t eventId = 511; // Querying this invitation event |
|
KakaoGame::Data::KGResult result;
std::vector<KakaoGame::Data::KGPlayer> invitationSenders;
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// Querying the list of players who invited you
|
|
KGKakaoInvitationLoadSenders(result, invitationSenders) |
|
=> {
if ;
if (result.isSuccess()) |
|
// Get the list of players who invited you
|
|
if (invitationSenders != null && invitationSenders.Count > 0)
{
foreach (KGPlayer player in invitationSenders)
{
for (KakaoGame::Data::KGPlayer invitationSender : invitationSenders) {
// Get the playerId
std::wstring |
|
string playerIdplayerId = player.playerId;
|
|
KGKakaoProfile KakaoGame::Data::KGKakaoProfile kakaoProfile = |
|
(KGKakaoProfile)player.idpProfileinvitationSender.kakaoProfile;
|
|
string nickname = kakaoProfile.nickname;
// player's KakaoTalk thumbnail image url
string thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
}
}
else
{
// No players who invited you
}
}
else if (result.code == KGResultCode.NotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
std::wstring nickname = kakaoProfile.nickname;
// player's KakaoTalk thumbnail image url
std::wstring thumbnailImageUrl = kakaoProfile.thumbnailImageUrl;
}
}
else
{
// Fail...
|
|
}); ...
Windows Async
import com.kakaogame.KGKakaoInvitation;
import com.kakaogame.KGPlayer;
import com.kakaogame.KGKakaoProfile;
import com.kakaogame.KGResult;#include "KakaoGameLib.h"
// [TODO] Set event Id
|
|
int eventId 511 511; // Querying this invitation event
KakaoGame::API::KGKakaoInvitation kgKakaoInvitation;
// Querying the list of players who invited you
|
|
KGKakaoInvitationkgKakaoInvitation.loadSenders(eventId, |
|
new KGResultCallback<List<KGPlayer>>() {
@Override
public void onResult(KGResult<List<KGPlayer>> result [this](KakaoGame::Data::KGResult result, std::vector<KakaoGame::Data::KGPlayer> invitationSenders) {
|
|
if if (result.isSuccess()) {
|
|
// Get the list of players who invited you
|
|
List<KGPlayer> invitationSenders = result.getContent();
if (invitationSenders != null && invitationSenders.size() > 0) {
for (KGPlayer player for (KakaoGame::Data::KGPlayer invitationSender : invitationSenders) {
|
|
String std::wstring playerId = player. |
|
getPlayerId() KGKakaoProfile KakaoGame::Data::KGKakaoProfile kakaoProfile = |
|
(KGKakaoProfile) player.getIdpProfile()invitationSender.kakaoProfile;
|
|
String std::wstring nickname = kakaoProfile. |
|
getNickname()
// player's KakaoTalk thumbnail image url
|
|
String thumbnailImageUrl std::wstring thumbnailImageUrl = kakaoProfile. |
|
getThumbnailImageUrl() else {
// No players who invited you
}
} else if (result.getCode() == KGResult.KGResultCode.NOT_KAKAOTALK_USER) {
// The user is not a KakaoTalk user.
} else {
}
iOS 예제Unreal
#import<KakaoGame/h>h"
// [TODO] Set event Id
int32 |
|
int eventIdeventId = 511; // Querying this invitation event
|
|
// Querying the list of players who invited you
[KGKakaoInvitation loadSendersWithEventId:eventId completionHandler:^(NSError *error, NSArray *invitationSenders
FKGKakaoInvitation::LoadSenders(eventId, FKGResultWithSendersDelegate::CreateLambda([=](FKGResult result, TArray<FKGPlayer> players) {
|
|
if (IS_SUCCESS(error) == YES)
{
if (result.IsSuccess())
{
// Success
|
|
// Get the list of players who invited you
|
|
if invitationSenders!=nil && [invitationSenders count] > 0)
{
for (KGPlayer *invitationSender in invitationSenders)
{
: players)
{
// Get the playerId
|
|
NSString*invitationSenderplayerId
KGKakaoProfile
FKGIdpProfile idpProfile = player.GetIdpProfile();
FKGKakaoProfile *kakaoProfile = ( |
|
KGKakaoProfileinvitationSender. NSString*.nickname // player's KakaoTalk thumbnail image url
|
|
NSString*thumbnailImageUrl = kakaoProfile |
|
.thumbnailImageUrl->GetThumbnailImageUrl();
|
|
}
else if (error.code == KGErrorNotKakaoTalkUser)
{
// The user is not a KakaoTalk user.
}
else
{
... ]