SDK initialization¶
The initialization of the Hive 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 Hive features.
Note
After completing the basic settings, you need to initialize the Hive SDK.
Note
Unlike other Hive SDK features, billing requires its own initialization.
Initialization method¶
To initialize the Hive 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
Hive 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, promotions, notifications, and marketing attribution
- Automatically display the terms registered in the Hive console and the update popup
The image below shows the workflow that the SDK internally executes when AuthV4.setup
is run.
Note
The iOS App Tracking Transparency popup is displayed after the terms agreement popup is shown and the user completes the terms agreement.