Install and initialize the module
To use terms features, you must install the terms module in the Hive Axyl SDK and initialize it. If you have not installed the Hive Axyl SDK yet, first install the Hive Axyl SDK.
1. Install the terms module
1.1. Select common modules
The common module provides the minimum features for using Hive Axyl, so you must select it.
com.com2usplatform.hiveaxyl.core: SDK initialization and the basic features that other modules share
1.2. Select modules for terms features
Terms features additionally require the following modules.
com.com2usplatform.hiveaxyl.terms: Features for retrieving terms, retrieving the consent status, saving and deleting consent, and retrieving consent historycom.com2usplatform.hiveaxyl.auth: Features needed to prepare the login session when you obtain consent with the Player ID after login
If you obtain terms consent only before login, you can install just the terms module without the authentication module. For consent subjects, see Consent subject.
1.3. Install modules
Install the modules the same way as in SDK installation. Keep the Hive Axyl Scoped Registry you registered when you installed the SDK as it is, and add only the modules that terms features need to dependencies in Packages/manifest.json. If you already installed some modules, do not remove the existing entries; add only the modules that are not there yet.
1.4. Verify the installation
Use the following code to check that the namespaces of the installed modules are recognized correctly.
The installation step is complete when the installed modules appear in the Installed state in Unity Package Manager.
2. Initialize the SDK
Initialize
When the app starts, call the initialization method and register the terms module.
- Check the App ID you created in Create app information. The part before the first
.of the App ID is the company code. Pass this value asCompanyCodewhen you call terms methods. - Run
CoreConfig.CreateBuilderwith the App ID to create aCoreConfigobject. If you registerAddToken(), you must also set the Client ID withSetOAuthClientId. Check the Client ID in Get the security key. - Initialize with
HiveBootstrap.Initializeand registerAddTerms()inbuilder. If you obtain consent after login, also registerAddAuth()andAddToken().
Call the initialization method only once while the app runs. If you already wrote initialization code in Step 4. Initialize the SDK or for another feature, do not call it again; just add AddTerms() to the builder of the existing Initialize call.
Call parameters
| Field name | Type | Required | Description |
|---|---|---|---|
config | CoreConfig | Required | A CoreConfig object that holds the App ID. Create it with CoreConfig.CreateBuilder. If you register AddToken(), it must also hold the Client ID. |
assemble | Action<IHiveBuilder> | Required | A builder callback that registers the feature modules to use. To use terms features, include builder.AddTerms(). |
Call example
using Hive.Axyl.Core;
using Hive.Axyl.Core.Unity;
using Hive.Axyl.Auth;
using Hive.Axyl.Terms;
// Call once when the app starts (for example, in Start of the first scene's MonoBehaviour).
// This setup also takes consent from logged-in users. If you take consent only before login, register only AddTerms()
// without the auth module, and leave out using Hive.Axyl.Auth, SetOAuthClientId, AddAuth() and AddToken().
CoreConfig config = CoreConfig.CreateBuilder("{appId}")
.SetOAuthClientId("{clientId}") // OAuth client ID sent when the token is refreshed automatically
.Build();
HiveBootstrap.Initialize(config, builder =>
{
builder.AddAuth(); // Account and authentication (IAuthService)
builder.AddToken(); // Token issuance and automatic refresh (ITokenService)
builder.AddTerms(); // Terms (ITermsService)
});
Get the registered terms module with HiveCore.Resolve<ITermsService>() and use it.
Response status
If HiveCore.Resolve<ITermsService>() returns an instance without an exception, initialization and module registration are complete. For the exception that occurs when you get a module that is not registered and the common principles of error handling, see Common error handling.
In the following cases, an exception occurs during initialization.
ArgumentNullException:nullwas passed forconfigInvalidOperationException: The initialization method was called again after initialization was already completeInvalidOperationException:AddToken()was registered but the Client ID was not set withSetOAuthClientId, or was set to an empty valueDllNotFoundException: The native plugin that the SDK uses could not be loaded on Windows. For the cause and how to respond, see Windows prerequisites
3. Prepare the terms
The terms module retrieves only terms deployed in the Hive Console. Before calling terms methods, the operator prepares the terms in the following order.
- In Terms > Terms Registration, enter a service code and register the terms items.
- Deploy the terms in Terms > Terms Deployment.
When you call terms methods, pass the service code you entered here as ServiceCode. A service code is a string of 2 to 30 characters that starts with an uppercase English letter and uses only uppercase English letters, digits, and _.
Pass the company code of the same company as the App ID as CompanyCode. If the companies differ, every terms method returns ServiceNotFound.