Skip to content

SDK initialization

The initialization of the SDK means making most of the SDK features in an initialization state, that is, ready for use. When implementing the SDK code, you must first execute the initialization and then call the methods for implementing the features you need.

Note

After completing the basic settings, you need to initialize the SDK.

Note

Unlike other SDK features, Billing requires its own initialization.

Initialization method

To initialize the SDK, call AuthV4.setup. It is recommended to perform the initialization after the app runs and the corporate logo (CI) is displayed. If result.isSuccess received as a callback result is True, the initialization was successful. Here is an example code.

API Reference: AuthV4.setup

using hive;

    // Request Hive SDK Initialization
    AuthV4.setup((result, isAutoSignIn, did, providerTypeList) => {
        if (result.isSuccess()) {
            // the initialization is successfully done. Handle login based on whether the auto-login is enabled or not.
        } else if (result.needExit()) {
            // TODO: Implement the termination of the app
            // Users of the Cocos2d-x engine
            // ex) exit(0);
            // Unreal engine users
            // Example) UKismetSystemLibrary::QuitGame(GetWorld(), nullptr, EQuitPreference::Quit, false);    
        } else {
            // initialization failed 
        }
    });

API Reference: AuthV4::setup

#include <HIVE_SDK_Plugin/HIVE_CPP.h>

    // Request Hive SDK Initialization
    AuthV4::setup([=](ResultAPI const & result, bool isAutoSignIn, std::string did, std::vector<ProviderType> const & providerTypeList) {
        if (result.isSuccess()) {
            // the initialization is successfully done. Handle login based on whether the auto-login is enabled or not.
        } else if (result.needExit()) {
            // TODO: Implement the termination of the app
            // Users of the Cocos2d-x engine
            // ex) exit(0);
            // Unreal engine users
            // Example) UKismetSystemLibrary::QuitGame(GetWorld(), nullptr, EQuitPreference::Quit, false);    
        } else {
            // initialization failed 
        }
    });

API Reference: com.hive.AuthV4.setup

import com.hive.AuthV4;

    // Request Hive SDK Initialization    
    AuthV4.setup(object: AuthV4.AuthV4SetupListener{    
        override fun onAuthV4Setup(result: ResultAPI, isAutoSignIn: Boolean, did: String?, providerTypeList: ArrayList<AuthV4.ProviderType>?) {        if (result.isSuccess) {    
                // the initialization is successfully done. Handle login based on whether the auto-login is enabled or not.    
            } else if (result.needExit()) {    
                // TODO: Implement the termination of the app    
                // ex) exitProcess(0)    
            } else {    
                // initialization failed 
            } 
        } 
    })

API Reference: com.hive.AuthV4.setup

import com.hive.AuthV4;  

    // Request Hive SDK Initialization    
    AuthV4.setup(new AuthV4.AuthV4SetupListener() {    
        @Override    
        public void onAuthV4Setup(ResultAPI result, boolean isAutoSignIn, String did, ArrayList<AuthV4.ProviderType> providerTypeList) {    
            if (result.isSuccess()) {    
                // the initialization is successfully done. Handle login based on whether the auto-login is enabled or not.    
            } else if (result.needExit()) {    
                // TODO: Implement the termination of the app    
                // ex) System.exit(0);    
            } else {    
                // initialization failed 
            } 
        } 
    });

API Reference: HIVEAuthV4:setup

import HIVEService

    // Request Hive SDK Initialization
    AuthV4Interface.setup { (result, isAutoSignIn, did, providerTypeList) in    
        if result.isSuccess() {    
            // the initialization is successfully done. Handle login based on whether the auto-login is enabled or not.    
        } else if result.needExit() {    
            // TODO: Implement the termination of the app    
            // Example) exit(0)    
        } else {    
            // initialization failed    
        }    
    }

API Reference: HIVEAuthV4:setup

#import <HIVEService/HIVEService-Swift.h>

    // Request Hive SDK Initialization    
    [HIVEAuthV4 setup:^(HIVEResultAPI *result, BOOL isAutoSignIn, NSString *did, NSArray<NSNumber *> *providerTypeList) {    
        if (result.isSuccess) {    
            // the initialization is successfully done. Handle login based on whether the auto-login is enabled or not.    
        } else if (result.needExit) {    
            // TODO: Implement the termination of the app    
            // ex) exit(0);    
        } else {    
            // initialization failed    
        }    
    }];
#include "HiveAuthV4.h"

    FHiveAuthV4::Setup(FHiveAuthV4OnSetupDelegate::CreateLambda([this](const FHiveResultAPI& Result,
    bool IsAutoSignIn,
    const FString& Did,
    const TArray<EHiveProviderType>& ProviderTypeArray) 
    {
            if (Result.IsSuccess()) {
                    // Initialization successful. Handle login based on whether auto sign-in is possible.
            } else if (Result.NeedExit()) {
                    // TODO: Implement app exit functionality
                    // e.g.) UKismetSystemLibrary::QuitGame(GetWorld(), nullptr, EQuitPreference::Quit, false);
            } else {
                    // Initialization failed
            }
    }));


The result callback includes the information below. The developer should store the information below and use it when necessary.

Field Name Description Example
isAutoSignIn Whether automatic login is possible true
did An app identifier created upon app installation, used to identify apps of the same type. 123456789
providerTypeList The list of IdPs provided by the current app. It is required when configuring explicit login customizing or IdP connection status information. ProviderType.FACEBOOK
ProviderType.HIVE
Note

Console > App Center > Project Management When the project status is Service Ended, executing AuthV4.setup will return an error code.

Initialization result

The SDK initialization performs the following.

  • Initialize Authentication, Promotion, Notification, and Marketing Attribution
  • Automatically display the Terms registered in the Console and the Update Popup

Initialization flow

The workflow that the SDK internally executes when AuthV4.setup is run varies depending on the region where you plan to launch your app.

  1. Regions other than the US and Europe
  2. United States
  3. Europe
Warning

When using Adkit/Adiz in an iOS environment, you can create an IDFA description message in the AdMob console and display the App Tracking Transparency popup. In this case, since AdMob displays the App Tracking Transparency popup first, this popup is not displayed in the AuthV4.setup flow. This applies to all three launch scenarios above.

Initialization flow: default flow

The image below shows the default workflow that the SDK internally executes when AuthV4.setup is run. This applies when launching your app in regions other than the US and Europe.

Note

iOS popup display order: App Tracking Transparency popup ➡ Terms agreement popup

Initialization flow: US launch

The image below shows the workflow that the SDK internally executes when AuthV4.setup is run. This applies when you need to comply with COPPA (Children's Online Privacy Protection Act) when launching your app in the United States.

Note

iOS popup display order: Terms agreement popup ➡ User completes terms agreement ➡ App Tracking Transparency popup

Initialization flow: EU launch

The image below shows the workflow that the SDK internally executes when AuthV4.setup is run. This applies when you need to comply with GDPR (General Data Protection Regulation) when launching your app in Europe.

Note

iOS popup display order: App Tracking Transparency popup ➡ Terms agreement popup