...
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// Connect Account
[KGSession connectWithCompletionHandler:^(NSError *error) {
if (IS_SUCCESS(error) == YES)
{
// Account connection successful
// The player ID is not changed.
}
else
{
// Account connection failed
if (error.code == KGErrorNotAuthorized)
{
// If currently not authenticated
}
else if (error.code == KGErrorInvalidState)
{
// If currently authenticated IDP is not guest, or SIWA(in Korea only)
}
else if (error.code == KGErrorAlreadyUsedIdpAccount)
{
// If trying to convert to an already used IDP account
}
else
{
// Other errors
}
}
}]; |
|
5.1.3. Connect accounts not using the basic account connection UI
The following is an example of connect account not using the basic account connection UI.
Connect to other IDP accounts is available only after the guest, SIWA(in Korea, iPhone only) has been authenticated. Otherwise, you have to deactive the account connection UI.
If connect account is successful, the player ID is maintained.
Unity
...
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
FKGSession::Connect(FKGResultDelegate::CreateLambda([=](FKGResult result) {
if (result.IsSuccess())
{
// Account connection successful
// The player ID is not changed.
}
else if (result.GetCode() == FKGResultCode::NotAuthorized)
{
// If currently not authenticated
}
else if (result.GetCode() == FKGResultCode::InvalidState)
{
// If currently authenticated IDP is not guest, or SIWA(in Korea, iPhone only)
}
else if (result.GetCode() == FKGResultCode::AlreadyUsedIDPAccount)
{
// If trying to convert to an already used IDP account
|
|
else Android
...
5.1.3. Connect accounts not using the basic account connection UI
The following is an example of connect account not using the basic account connection UI.
Connect to other IDP accounts is available only after the guest, SIWA(in Korea, iPhone only) has been authenticated. Otherwise, you have to deactive the account connection UI.
If connect account is successful, the player ID is maintained.
Unity
코드 블럭 |
---|
using Kakaogame.SDK;
KGIdpCode idpCode = KGIdpCode.Kakao; // IDP to be used for account connection
// Connect accounts not using the basic account connection UI
KGSessionForCustomUI.Connect(
idpCode,
(result) => {
if (result.isSuccess) {
// Account connection successful
// The player ID is not changed.
}
else if (result.code == KGResultCode.NotAuthorized) {
// If currently not authenticated
|
|
else if getCode()KGResult.INVALID_STATE // If currently authenticated IDP is not guest |
|
.
} else if (result.getCode() == KGResult.KGResultCode.ALREADY_USED_IDP_ACCOUNT, or SIWA(in Korea, iPhone only)
}
else if (result.code == KGResultCode.AlreadyUsedIdpAccount) {
|
|
// If trying to convert to an already used IDP account
|
|
else
}
}iOSAndroid
#import <KakaoGame/KakaoGame.h>
// Connect accounts not using the basic account connection UI
KGIdpProfile.KGIdpCode idpCode |
|
= KGIdpCodeKakao; // IDP to be used for account connection
|
|
[KGSessionForCustomUI connectWithIdpCode:idpCode completionHandler:^(NSError *errorKGSessionForCustomUI.connect(activity, idpCode, new KGResultCallback<Void>() {
@Override
public void onResult(KGResult<Void> result) {
|
|
if (IS_SUCCESS(error) == YES)
{
if (result.isSuccess()) {
// Account connection successful
|
|
// The player ID is not changed.
|
|
}
else
// Account connection failed
|
|
if errorcodeKGErrorNotAuthorizedKGResult.KGResultCode.INVALID_PARAMETER) |
|
currentlynotauthenticated
else if errorcodeKGErrorInvalidStateKGResult.KGResultCode.NOT_AUTHORIZED) |
|
authenticated IDP isguest, or SIWA(in Korea only)
}
else if (error.code == KGErrorAlreadyUsedIdpAccount)
{
authenticated
} else if (result.getCode() == KGResult.KGResultCode.INVALID_STATE) {
// If currently authenticated IDP is not guest.
} else if (result.getCode() == KGResult.KGResultCode.ALREADY_USED_IDP_ACCOUNT) {
// If trying to convert to an already used IDP account
|
|
}
else
] 5.1.4. Kacao 'app-to-web' login without the default account connection UI (3.8.0+)
This is an example of implementing a Kacao 'app-to-web' login when connecting accounts that do not use the default account connection UI.
Connect to other IDP accounts is available only after the guest, SIWA(in Korea, iPhone only) has been authenticated. Otherwise, you have to deactive the account connection UI.
If connect account is successful, the player ID is maintained.
In the version below 3.8.0, only the 'app-to-app' authentication was supported when KakaoTalk app was installed by default. You can use the following APIs to allow users to select 'Kakao app' or 'web' authentication to log in, or to perform an 'app-to-web' authentication.
Unity
코드 블럭 |
using Kakaogame.SDK;
// Users select app or web authentication and sign iniOS
코드 블럭 |
---|
#import <KakaoGame/KakaoGame.h>
// Connect accounts not using the basic account connection UI
KGIdpCode idpCode = KGIdpCodeKakao; // IDP to be used for account connection
[KGSessionForCustomUI connectWithIdpCode:idpCode completionHandler:^(NSError *error) {
if (IS_SUCCESS(error) == YES)
{
// Account connection successful
// The player ID is not changed.
}
else
{
// Account connection failed
if (error.code == KGErrorNotAuthorized)
{
// If currently not authenticated
}
else if (error.code == KGErrorInvalidState)
{
// If currently authenticated IDP is not guest, or SIWA(in Korea only)
}
else if (error.code == KGErrorAlreadyUsedIdpAccount)
{
// If trying to convert to an already used IDP account
}
else
{
// Other errors
}
}
}]; |
|
Windows Sync
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::API::KGSessionForCustomUI kgSessionForCustomUI;
KakaoGame::Data::KGResult result;
// IDP to be used for account connection
KakaoGame::Data::KGIdpCode idpCode;
// Connect accounts not using the basic account connection UI
kgSessionForCustomUI.connect(idpCode, result);
if (result.isSuccess()) {
// Account connection successful
// The player ID is not changed.
}
else if (KakaoGame::Data::KGResultCode::NotAuthorized == result.code) {
// If currently not authenticated
}
else if (KakaoGame::Data::KGResultCode::NotSupported == result.code) {
// Unable to connect idp
}
else if (KakaoGame::Data::KGResultCode::AlreadyUsedIDPAccount == result.code) {
// If trying to convert to an already used IDP account
}
else {
// Other errors
}
|
|
Windows Async
코드 블럭 |
---|
#include "KakaoGameLib.h"
KakaoGame::API::KGSessionForCustomUI kgSessionForCustomUI;
KakaoGame::Data::KGResult result;
// IDP to be used for account connection
KakaoGame::Data::KGIdpCode idpCode;
// Connect accounts not using the basic account connection UI
kgSessionForCustomUI.connect(idpCode, [this](KakaoGame::Data::KGResult result) {
if (result.isSuccess()) {
// Account connection successful
// The player ID is not changed.
}
else if (KakaoGame::Data::KGResultCode::NotAuthorized == result.code) {
// If currently not authenticated
}
else if (KakaoGame::Data::KGResultCode::NotSupported == result.code) {
// Unable to connect idp
}
else if (KakaoGame::Data::KGResultCode::AlreadyUsedIDPAccount == result.code) {
// If trying to convert to an already used IDP account
}
else {
// Other errors
}
}, reinterpret_cast<HWND>(GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetOSWindowHandle());
|
|
Unreal
코드 블럭 |
---|
#include "KakaoGame.h"
// Connect accounts not using the basic account connection UI
EKGIdpCode idpCode = EKGIdpCode::Kakao; // IDP to be used for account connection
FKGSessionForCustomUI::Connect(idpCode, FKGResultDelegate::CreateLambda([=](FKGResult result) {
if (result.IsSuccess())
{
// Account connection successful
// The player ID is not changed.
}
else if (result.GetCode() == FKGResultCode::NotAuthorized)
{
// If currently not authenticated
}
else if (result.GetCode() == FKGResultCode::InvalidState)
{
// If currently authenticated IDP is not guest, or SIWA(in Korea only)
}
else if (result.GetCode() == FKGResultCode::AlreadyUsedIDPAccount)
{
// If trying to convert to an already used IDP account
}
else
{
// Other errors
}
})); |
|
5.1.4. Kacao 'app-to-web' login without the default account connection UI (3.8.0+)
This is an example of implementing a Kacao 'app-to-web' login when connecting accounts that do not use the default account connection UI.
Connect to other IDP accounts is available only after the guest, SIWA(in Korea, iPhone only) has been authenticated. Otherwise, you have to deactive the account connection UI.
If connect account is successful, the player ID is maintained.
In the version below 3.8.0, only the 'app-to-app' authentication was supported when KakaoTalk app was installed by default. You can use the following APIs to allow users to select 'Kakao app' or 'web' authentication to log in, or to perform an 'app-to-web' authentication.
Unity
코드 블럭 |
---|
using Kakaogame.SDK;
// Users select app or web authentication and sign in
KGKakaoAuthType authType = KGKakaoAuthType.KakaoAllType;
// Login KakaoWeb
// KGKakaoAuthType authType = KGKakaoAuthType.KakaoWeb;
// Connect accounts that do not use the default account connection UI
KGSessionForCustomUI.ConnectKakao(
authType,
(result) => {
if (result.isSuccess) {
// Account connection successful
// The player ID is not changed.
}
else if (result.code == KGResultCode.NotAuthorized) {
// If currently not authenticated
}
else if (result.code == KGResultCode.InvalidState) {
// If currently authenticated IDP is not guest, or SIWA(in Korea, iPhone only)
}
else if (result.code == KGResultCode.AlreadyUsedIDPAccount) {
// If trying to convert to an already used IDP account
}
else {
// Other errors
}
}); |
|
Android
코드 블럭 |
---|
// Connect accounts not using the basic account connection UI
// User selects 'app' or 'web' authentication and logs in
KGKakaoAuthType authType = KGKakaoAuthType.KakaoAllType;
// app to web login only
//// KGKakaoAuthType authType = KGKakaoAuthType. |
|
KakaoAllType
// Login KakaoWeb
// KGKakaoAuthType authType = KGKakaoAuthType.KakaoWeb;
// Connect accounts that do not use the default account connection UI
KGSessionForCustomUI.ConnectKakao(
authType,
(result) => {
if (result.isSuccess) {
// Account connection successful
// The player ID is not changed.
}
else if (result.code == KGResultCode.NotAuthorized) {
KGSessionForCustomUI.connectKakao(getActivity(), authType, new KGResultCallback<Void>() {
@Override
public void onResult(KGResult<Void> result) {
if (result.isSuccess()) {
// Account connection successful
// The player ID is not changed.
} else {
// Account connection failed
if (result.getCode() == KGResult.KGResultCode.INVALID_PARAMETER) {
// If activity is null
} else if (result.getCode() == KGResult.KGResultCode.NOT_AUTHORIZED) {
// If currently not authenticated
|
|
else if codegetCode() == KGResult.KGResultCode. |
|
InvalidState // If currently authenticated IDP is not guest |
|
, or SIWA(in Korea, iPhone only)
}
else if codegetCode() == KGResult.KGResultCode. |
|
AlreadyUsedIDPAccountALREADY_USED_IDP_ACCOUNT) {
|
|
// If trying to convert to an already used IDP account
|
|
else // Other errors
}
}
}
}); |
|
AndroidiOS
// Connect accounts not using the basic account connection UI#import <KakaoGame/KakaoGame.h>
// |
|
Userselects''''logssign in
KGKakaoAuthType authType = |
|
KGKakaoAuthType.KakaoAllTypeKGKakaoAuthTypeKakaoAllType;
// |
|
app to web login only
Login KakaoWeb
//// KGKakaoAuthType authType = |
|
KGKakaoAuthType.KakaoWeb;
KGSessionForCustomUI.connectKakao(getActivity(), authType, new KGResultCallback<Void>() {
@Override
public void onResult(KGResult<Void> result) {
if (result.isSuccess()) {
KGKakaoAuthTypeKakaoWeb;
// Connect accounts that do not use the default account connection UI
[KGSessionForCustomUI connectKakaoWithKakaoAuthType:authType completionHandler:^(NSError *error) {
if (IS_SUCCESS(error) == YES) {
// Account connection successful
|
|
not changed.
} else {
// Account connection failed
if (result.getCode() == KGResult.KGResultCode.INVALID_PARAMETER) {
// If activity is null
} else if (result.getCode() == KGResult.KGResultCode.NOT_AUTHORIZED) {
not changed.
}
else {
// Account connection failed
if (error.code == KGErrorNotAuthorized) {
// If currently not authenticated
|
|
else if resultgetCode()KGResult.KGResultCode.INVALID_STATE // If currently authenticated IDP is not guest |
|
.
} else if (result.getCode(), or SIWA(in Korea only)
}
else if (error.code == |
|
KGResult.KGResultCode.ALREADY_USED_IDP_ACCOUNTKGErrorAlreadyUsedIdpAccount) {
|
|
// If trying to convert to an already used IDP account
|
|
else
}) iOSUnreal
#import<KakaoGame/h>
h"
// Users select app or web authentication and sign in
|
|
KGKakaoAuthTypeEKGKakaoAuthType authType = |
|
KGKakaoAuthTypeKakaoAllType;EKGKakaoAuthType::KakaoAllType;
// Login KakaoWeb
// |
|
//KGKakaoAuthTypeEKGKakaoAuthType authType = |
|
KGKakaoAuthTypeKakaoWeb;
// Connect accounts that do not use the default account connection UI
[KGSessionForCustomUI connectKakaoWithKakaoAuthType:authType completionHandler:^(NSError *errorEKGKakaoAuthType.KakaoWeb;
FKGSessionForCustomUI::ConnectKakao(authType, FKGResultDelegate::CreateLambda([=](FKGResult result) {
|
|
if (IS_SUCCESS(error) == YES) {
if (result.IsSuccess())
{
// Account connection successful
|
|
// The player ID is not changed.
|
|
else {
// Account connection failed
if (error.code else if (result.GetCode() == |
|
KGErrorNotAuthorizedFKGResultCode::NotAuthorized)
{
|
|
// If currently not authenticated
|
|
else if errorcodeKGErrorInvalidStateFKGResultCode::InvalidState)
{
|
|
// If currently authenticated IDP is not guest, or SIWA(in Korea only)
|
|
else if errorcodeKGErrorAlreadyUsedIdpAccountFKGResultCode::AlreadyUsedIDPAccount)
{
|
|
// If trying to convert to an already used IDP account
|
|
else
}]