Log in/Log out

Login

Login in authentication is composed of the following steps.

Authv4Helper executes some part of login process, and indicates the proper page based on the response.

Refer to the following notes to implement the login function.

Automatic Login and Implicit Login

Automatic Login

Implicit Login is a method that the user does not select a means of login, but logs in the Apple Game Center account on iOS or the Google Play Games account on Android automatically. Implement the Implicit Login to be executed after failure of Automatic Login.

Offline Mode

Hive SDK v4 23.1.0 and higher offers an automatic login feature (AuthV4.signIn using ProviderType.AUTO, or AuthV4.Helper.signIn) even when the user’s device is not connected to the network. To use the offline mode, follow the instructions below:

  1. It is necessary that the app was run in online mode at least once, resulting in a successful explicit, implicit, guest, or custom login, and subsequently, playerId and playerToken were issued.

    From the perspective of the app developers, there must have been at least one successful execution of AuthV4.Helper.signIn, AuthV4.showSignIn, or AuthV4.signInWithAuthKey in an online state, with the reception of playerId and playerToken via callback. From the user’s perspective, they must have successfully logged into the app at least once while their device was connected to the network. However, if the user’s account was suspended or restricted during their last login attempt in online mode, they will not be able to log in in offline mode.

  2. Activate the offline mode in the Hive console under App Center > Manage Project > Game Details > Hive Product Settings.
Automatic Login on Windows

Windows environment supports automatic login, and it can be enabled/disabled in the Hive console App Center. Note that the Windows automatic login works differently from the automatic login for the mobile environment. The differences are:

  • In the mobile environment, a user is kept logged in by automatic login, but in Windows, it is kept only when a user enabled “keep me logged in” checkbox (displayed below the IdP list in login UI). In other circumstances, the login status does not continue.
  • In the mobile environment, when you execute AuthV4Helper.Connect and convert to another account, the newly logged in account also is kept logged in by the automatic login, but in Windows, it is not.
Implicit Login
  • Login flow of Implicit Login

AuthV4.Helper.signIn tries Automatic Login by using the authentication token key of PlayerID. If the token key generated from previous login does not exist, the game automatically sign in Apple Game Center for iOS, and Google Play Games for Android. If failed to sign in, it displays a proper login page in accordance with the response.

Followings are sample codes to execute Automatic Login.

Unity®

API Reference: hive.AuthV4.Helper.signIn

C++

API Reference: Auth4::signIn

Kotlin

API Reference: com.hive.Auth4.Helper.signIn

Java

API Reference: com.hive.Auth4.Helper.signIn

Swift

API Reference: HIVEAuth4:signIn

Obj-C
API Reference: HIVEAuth4:signIn
Implicit Login Behavior: Mobile

On mobile platforms (Hive SDK Unity Android, etc., Android/iOS), implicit login (AuthV4.Helper.signIn) causes an account conflict and prompts the user with a dialog asking whether to log in with the last logged-in account after the initial login.

Implicit Login Behavior: PC

On PC platforms (Hive SDK Unity Windows, etc., Windows), implicit login (AuthV4.Helper.signIn) automatically logs in with the last logged-in account after the initial login, without causing any account conflict.

Explicit Login

Explicit Login means a process that user chooses an IdP to proceed with authentication. If a player failed to execute both Automatic Login and Implicit Login, implement the game to make the player go to the game title screen and execute Explicit Login when tapping the title.

Explicit Login is composed of the UI provided by Hive SDK or the UI customized in games with the IdP lists returned after initializing Hive SDK used in authentication. If you customize the UI, see Advanced >; Customizing Explicit Login UI.

Hive Platform controls and provides IdP lists in accordance with the policy of each country. For example, Google Play Games, Facebook, and Guest Login are not available in China.

An example screen of Explicit Login

IdP selection UI provided by Hive SDK

When implementing the function with the UI provided by Hive SDK

To implement Explicit Login with the UI provided by Hive SDK, you can display the IdP list UI by calling showSignIn() method.

Unity®

API Reference: hive.AuthV4.showSignIn

C++

API Reference: AuthV4::showSignIn

Kotlin

API Reference: com.hive.AuthV4.showSignIn

Java

API Reference: com.hive.AuthV4.showSignIn

Swift

API Reference: HIVEAuthV4:showSignIn

Obj-C

API Reference: HIVEAuthV4:showSignIn

Customizing Explicit Login UI

You can implement a customized UI for an explicit login by using providerTypeList, which is returned as a callback handler of AuthV4.setup() method called for Hive SDK initialization, or AuthV4.Helper.getIDPList() method called after Hive SDK initialization. Customizing explicit login UI is used when you want to display the login screen according to the game UI, or to display the linking option with a specific IdP only. After designing the UI, call signIn() method with the desired ProviderType depending on the user’s action.

  • Example UI which exposes only Facebook-synced button on sign-in page

Followings are sample codes for the case that user selects Google sign-in on the customized explicit login UI.

Unity®

API Reference: hive.AuthV4.signIn

C++

API Reference: Auth4::signIn

Kotlin

API Reference: AuthV4.signIn

Java

API Reference: com.hive.Auth4.signIn

Swift

API Reference: AuthV4Interface.signIn

Objective-C

API Reference: HIVEAuth4:signIn

Checking Logged-in IdP Account on Device

Automatic Login is available to sign in with the token key of registered playerId, and so as Explicit Login with various IdPs. In the case of these two cases, the IdP account (DevicePlayer) logged-in on user device may mismatch with the IdP of PlayerID, which user logged in. Considering the use of achievement or leaderboard, notification page is provided for users to match two accounts.

  • SDK-providing UI which asks whether to use DevicePlayer or not

Followings are sample codes to confirm the IdP information.

Unity®

API Reference: AuthV4 .Helper.syncAccount

C++

API Reference: AuthV4 ::Helper::syncAccount

Kotlin

API Reference: AuthV4.Helper.syncAccount

Java

API Reference: AuthV4 .Helper.INSTANCE.syncAccount

Swift

API Reference: AuthV4Interface.helper().syncAccount

Objective-C

API Reference: [ HIVEAuthV4 helper] syncAccount

Guest Login

Hive supports Guest Login to allow users to use the game as a guest without selecting an IdP. You can implement this function for user to choose guest from the Explicit Login UI provided by Hive SDK, or from the customized UI by game. The Windows environment does not support guest sign-in.

Make sure to comply with the following policy when logging in as a guest.

Guest Login Policy
    • Build a game available for both guest users and Hive members equally.
      Most features of Hive platform are available for guest users. So, implement your games the same for both guest users and IdP-connected users. For example, guest users are also able to purchase items and pay in the game.
    • Do not allow guest users to sign out.
      If a user logs in as a guest and then logs out, the user can no longer sign in with the same PlayerID. Therefore, do not provide a logout button to prevent users from signing out when their state is the guest.
    • Guest Login Policy with Chinese IP.
      If users access the game with Chinese IP, only authorized members can charge game money or purchase items (started from May 1, 2017). Therefore, IdP lists available with Chinese IP do not include Guest Login.

Implement signIn() method with the parameter, ProviderType.GUEST to execute Guest Login.
Followings are sample codes to execute Guest Login.

Unity®

API Reference: hive.AuthV4.signIn

C++

API Reference: Auth4::signIn

Kotlin

API Reference: AuthV4.signIn

Java

API Reference: com.hive.Auth4.signIn

Swift

API Reference: AuthV4Interface.signIn

Objective-C

API Reference: HIVEAuth4:signIn

Custom Login

Custom Login is a feature of implementing login with an external IdP that Hive SDK does not support. Follow the Auth V4 Custom Authentication guide to create an authKey that uses for calling the Custom Login API.
You can confirm the user’s information who signed in with custom login by accessing customProviderInfoData with the PlayerInfo object which is passed as a callback of the Custom Login API. ProviderType(enum) of customProviderInfoData are all set as CUSTOM, and can be identified in detail with ProviderName(String).

  • The information of IdP that implemented custom login in-game is not include as a result of calling setup() and showSignIn() method of AuthV4 class.
  • If you get the playerId and playerToken after first executing custom login, the Result API of authV4SessionExist(code) will be passed as a callback when you re-call the custom login API. In this case, implement signIn() method with the parameter, ProviderType.Auto to execute automatic login with a previous login account.
  • The connect() and disconnect() method of AuthV4 class currently do not support additional connection and disconnection of a custom login IdP.
  • The additional sync or disconnection of IdPs for custom login are supported with the connectWithAuthKey() and disconnectWithName() methods.

Followings are sample codes to implement the custom login.

Unity®

API Reference: hive.AuthV4.signIn

C++

API Reference: Auth4::signIn

Kotlin

API Reference: com.hive.Auth4.signIn

Java

API Reference: com.hive.Auth4.signIn

Swift

API Reference: HIVEAuth4:signIn

Obj-C

API Reference: HIVEAuth4:signIn

Username

Due to issues such as the US COPPA, when accessing from the United States or its territories and logging in with an IdP, you must enter your username to enable authentication for additional user identification.

For reference, the countries included in the US territory are American Samoa (AS), Guam (GU), Northern Mariana Islands (MP), Puerto Rico (PR), US Minor Archipelago (UM), and US Virgin Islands (VI).

The username input screen for user identification is as follows.

  • The username input screen is used only for user identification, so it is exposed only once when first linking with the IdP and is not exposed other than that.
  • When logging in as a guest, the username input screen is not displayed.

Verifying Authentication Token Key

Game server can validate the authentication token key by using the returned token, playerId, and DID information after successful login. Hive Authentication allows multi-device logins and duplicate connections.

Unless your game allows duplicate access with one ID, game server exposes a notice on the logged-in device and terminates the game. Then, the secondly logged-in device keeps its login state for game play. If user keeps duplicate connections without terminating the game from one device, the game play may not be recorded concisely. Therefore, make sure to manage the token key that has been verified or implement the function by managing the session key of the game itself using the token key to process this function.

Implement the function by referring to Hive Server API >; Verifying Authentication v4 Token.

Obtaining Hive TalkPlus Login Token

To log in to Hive TalkPlus, you need the login token obtained by calling AuthV4.getHiveTalkPlusLoginToken API after login (signIn()) via Auth v4 interface. (See Hive TalkPlus Login Guide)

Unity®

Kotlin

Android

Swift

Objective-C

Detecting Changes in IdP Account in the Background

Users can change their Apple Game Center or Google Play game accounts through device settings while playing the game. If you need to check whether the IdP account is matched with the account connected with the current PlayerID, implement setProviderChangedListener() after initializing Hive SDK. If you implement the API, user can receive an event which notifies the changes in IdP account linked on the user device when game resumes.

iOS works when the account in Apple Game Center is changed, and Android works when the account in Google Play Games is changed. And The response will be delivered only if the currently logged in PlayerID is connected with the relevant IdP. If you receive the change event in IdP account, configure the UI which allows the user to choose whether to use the IdP account logged in on the device. If the user selects the IdP account logged in on the device, call signOut to sign out and proceed with Implicit Login.

Followings are sample codes to receive events that IdP account setting on device is changed when the player resumes the game.

Unity®

API Reference: hive.AuthV4.setProviderChangedListener

C++

API Reference: AuthV4::setProviderChangedListener

Kotlin

API Reference: AuthV4.setProviderChangedListener

Java

API reference : : com.hive.authv4.SetproviderChangeDlistener

Swift

API Reference: AuthV4Interface .setProviderChangedListener

Objective-C

API Reference: HIVEAuthV4:setProviderChangedListener

Initializing Game Data

Make sure not to implement logout when initializing game data. PlayerID is not deleted through the initialization, therefore, crash among accounts may occur. Let user play the game with the currently signed-in account, and do not implement the logout function before user clearly request by tapping the logout button.

Logout

If Hive login is performed, PlayerID and authentication token key are already issued. Logout is responsible for initializing the PlayerID and the token key. If logout is completed by implementing signOut(), move to the game title and execute the Explicit Login when user taps the title.

Followings are sample codes to implement sign-out.

Unity®

API Reference: hive.AuthV4.signOut

C++

API Reference: AuthV4::signOut

Kotlin

API Reference: AuthV4.Helper.signOut

Java

API Reference: AuthV4.Helper.INSTANCE.signOut

Swift

API Reference: AuthV4Interface.helper().signOut()

Objective-C

API Reference: [HIVEAuthV4 helper] signOut

Notification phrases for Game Center Sign-in Disabled
Language Phrase
Korean Apple Game Center 로그인이 취소되었습니다.
Game Center 계정과 연동하려면 [설정 >; Game Center]에서 로그인한 후 다시 시도해주세요.
English Your login to the Game Center has been canceled.
Log in at [Settings >; Game Center] to sync to the Game Center Account and try again.
Japanese Apple Game Center ログインがキャンセルされました。
Game Center アカウントと連動するには [設定 >; Game Center] にログインした後、再度お試しください。
Chinese (Simplified) Apple Game Center已退出登录。
若想与Game Center账号同步,请在设备[设置 >; Game Center]中重新登录后再试。
Chinese (Traditional) 登入Apple Game Center已取消。
若想連動Game Center帳號,請至[設定 >; Game Center]登入後,再試一次。
French Ta connexion au Game Center a été annulée.
Connecte-toi dans [Réglages >; Game Center] pour synchroniser ton compte Game Center et essaie de nouveau.
German Das Einloggen ins Apple Game Center wurde abgebrochen.
Die Synchronisation mit dem Game Center-Konto läuft über [Einstellungen >; Game Center]. Logge dich ein und versuche es erneut.
Russian Ваш авторизация в Game Center была отменена.
Авторизуйтесь в Game Center через [Настройки >; Game Center] и повторите попытку.
Spanish Tu Inicio de Sesión en Game Center ha sido cancelado.
Inicia Sesión en [Configuración >; Game Center] para sincronizar a la Cuenta de Game Center, e inténtalo de nuevo.
Portuguese O seu login no Game Center foi cancelado.
Faça o login em [Configurações >; Game Center] para sincronizar com a Conta do Game Center e tente novamente.
Indonesian Login ke Apple Game Center telah dibatalkan.
Hubungkan akun Game Center dengan login di [Pengaturan >; Game Center] dan coba lagi.
Malay Log masuk ke Game Center anda telah dibatalkan.
Log masuk di [Tetapan >; Game Center] untuk disegerakkan ke Akaun Game Center dan cuba lagi.
Vietnamese Đã hủy bỏ đăng nhập vào Apple Game Center.
Đăng nhập tại [Cài đặt >; Game Center] để đồng bộ với tài khoản Game Center và thử lại.
Thai การล็อกอินเข้า Game Center ของคุณถูกยกเลิก
ล็อกอินที่ [การตั้งค่า >; Game Center] เพื่อเชื่อมต่อบัญชี Game Center และโปรดลองอีกครั้ง
Italian L’accesso all’Apple Game Center è stato annullato.
Fai log-in su [Impostazioni >; Game Center] per sincronizzare il tuo account con il Game Center e riprova.
Turkish Apple Oyun Merkezine girişiniz iptal edilmiştir.
Oyun Merkezi Hesabına ulaşmak için [Ayarlar >; Oyun Merkezi]’nden giriş yapın ve tekrar deneyin.
Arabic تم إلغاء تسجيل الدخول إلى مركز الألعاب.
سجل الدخول إلى [الإعدادات >; مركز الألعاب] للمزامنة مع حساب مركز الألعاب وحاول مرة أخرى.