Skip to content

Install and initialize the module

This page describes how to install the TCB 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 TCB module

Install the TCB module in the Hive Axyl SDK in the following order.

1.1. Select common modules

Select the common module, which provides the minimum features needed to use Hive Axyl.

Module Description
com.hive.axyl.core Provides the initialization you call when the SDK starts and the basic features that other modules share.

1.2. Select modules for TCB features

To call Cloud Functions registered in TCB, select the following module.

Module Description
com.hive.axyl.tcb Provides the feature that runs Cloud Functions registered in TCB (Tencent CloudBase).

1.3. Install modules

Modules are installed basically the same way as in SDK installation.

If you use Packages/manifest.json, add com.hive.axyl.core and the TCB feature module com.hive.axyl.tcb together to dependencies.

{
  "scopedRegistries": [
    {
      "name": "Hive Axyl",
      "url": "PLACEHOLDER_AXYL_REGISTRY_URL",
      "scopes": [
        "com.hive.axyl"
      ]
    }
  ],
  "dependencies": {
    "com.hive.axyl.core": "PLACEHOLDER_AXYL_CORE_VERSION",
    "com.hive.axyl.tcb": "PLACEHOLDER_AXYL_TCB_VERSION"
  }
}

Direct installation with a Git URL

If you use a Git URL, set the ?path= path to the TCB feature module com.hive.axyl.tcb and install it additionally.

PLACEHOLDER_AXYL_GIT_URL?path=PLACEHOLDER_PACKAGE_PATH/com.hive.axyl.tcb

1.4. Verify the installation

The following code is an example that checks whether the namespaces of the installed SDK and TCB module are recognized correctly.

using Hive.Axyl.Core;
using Hive.Axyl.Tcb;

The installation step is complete when all of the following conditions are met.

  • The installed module appears in the Installed state in Unity Package Manager.

2. Initialize the SDK

Method

Initialize


Hive Axyl SDK initialization is a preparation step that the app goes through once before it uses TCB features. Call initialization when the app starts to prepare to call the Cloud Functions registered in TCB.

Call it only once when the app starts, in the following order.

  1. Check the App ID you created in Create app information.
  2. Run CoreConfig.CreateBuilder with the App ID to create a CoreConfig object.
    • Run SetZone to specify Zone.Sandbox during development and Zone.Real for production.
  3. Run initialization with HiveBootstrap.Initialize. Register AddTcb() on builder.
  4. After initialization, get the TCB features with HiveCore.Resolve<ITcbService>() and use them.


Call parameters

Field name Type Required Description
config CoreConfig Required The CoreConfig object that holds the App ID and the connection environment (Zone). Create it with CoreConfig.CreateBuilder.
assemble Builder callback Required The builder callback that registers the feature modules to use. To use TCB features, include builder.AddTcb().


Call example

using Hive.Axyl.Core;
using Hive.Axyl.Core.Unity; // HiveBootstrap
using Hive.Axyl.Tcb;         // AddTcb extension

var config = CoreConfig.CreateBuilder("{appId}")
    .SetZone(Zone.Sandbox)   // Development and test environment. Use Zone.Real for production builds
    .Build();

HiveBootstrap.Initialize(config, builder =>
{
    builder.AddTcb();
});

If you already initialize other modules, just add AddTcb() to the same Initialize call. After registration, get the registered module with HiveCore.Resolve<ITcbService>() and use it.

The default AddTcb() of the TCB module registers the default production host of the TCB API. Because the TCB API specification does not define a separate sandbox host, no AddTcb() overload that takes a sandbox flag is provided. Use AddTcb(baseUrl) only when you need to specify the host of a separate environment yourself.

Note

Like other modules, the TCB API also requires login session information. You must complete login and session setup before you call it.


Response data

No data is returned on success.


Response example

ITcbService tcb = HiveCore.Resolve<ITcbService>();


Response status

If calling HiveCore.Resolve<ITcbService>() in your code returns a TCB module handle without throwing an exception, initialization and module registration are complete.

If initialization fails, exceptions are thrown as follows.

  • If you pass null to config, an ArgumentNullException is thrown.
  • If you call the initialization method again after initialization is already complete, an InvalidOperationException is thrown.


Next steps

Proceed to set up the TCB integration.