Skip to content

Install and initialize the module

Install the service access control 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 service access control module

1.1. Select common modules

Select the common module, which provides the minimum functionality for using the Hive Axyl SDK.

  • com.com2usplatform.hiveaxyl.core: The initialization that you call when you start the SDK, and the basic functions that other modules use in common

1.2. Select modules for the service access control feature

To use the service access control feature, also select the following module.

  • com.com2usplatform.hiveaxyl.serviceaccess: Service country restriction, server maintenance, and client update check features

When you register the single service access control module, you call the Service country restriction, Server maintenance, and Client update features all through one IServiceAccessService.

1.3. Install modules

Install the service access control module in the same way as SDK installation. The Hive Axyl SDK is installed only through a Scoped Registry, so additionally declare the service access control module for the Hive Axyl Scoped Registry that you registered when you installed the SDK.

In dependencies of Packages/manifest.json, add com.com2usplatform.hiveaxyl.serviceaccess, the service access control feature module, together with com.com2usplatform.hiveaxyl.core.

{
  "scopedRegistries": [
    {
      "name": "Hive Axyl",
      "url": "https://package.openupm.com",
      "scopes": [
        "com.com2usplatform.hiveaxyl"
      ]
    }
  ],
  "dependencies": {
    "com.com2usplatform.hiveaxyl.core": "1.0.0",
    "com.com2usplatform.hiveaxyl.serviceaccess": "1.0.0"
  }
}

1.4. Verify the installation

Check that you can use the namespaces of the installed SDK and the service access control module in using statements.

using Hive.Axyl.Core;
using Hive.Axyl.ServiceAccess;

If the installed module is displayed with the Installed status in Unity Package Manager, the installation is complete.

2. Initialize the SDK

Method

Initialize

To use the service access control feature, you must initialize the Hive Axyl SDK once when the app starts. Initialization prepares the SDK runtime needed for country restriction, server maintenance, and client update checks.

  1. Check the App ID that you created in app information.
  2. Run CoreConfig.CreateBuilder with the App ID to create a CoreConfig object.
  3. Run initialization with HiveBootstrap.Initialize. Register AddServiceAccess(), the service access control module, in builder.
  4. After initialization, get the service access control feature with HiveCore.Resolve<IServiceAccessService>() and use it.

Call parameters

Field name Type Required Description
config CoreConfig Required The CoreConfig object that contains the App ID. Create it with CoreConfig.CreateBuilder.
assemble Action<IHiveBuilder> Required Builder callback that registers the feature modules to use. To use the service access control feature, include builder.AddServiceAccess().

Call example

using Hive.Axyl.Core;
using Hive.Axyl.Core.Unity;   // HiveBootstrap
using Hive.Axyl.ServiceAccess;   // AddServiceAccess extension

var config = CoreConfig.CreateBuilder("{appId}").Build();

HiveBootstrap.Initialize(config, builder =>
{
    builder.AddServiceAccess();
    // If you also use other modules, register them together in the same initialization call.
    // builder.AddAuth().AddToken().AddServiceAccess();
});

If you have already initialized other modules, you only need to add AddServiceAccess() to the same Initialize call. After that, retrieve the registered module with HiveCore.Resolve<IServiceAccessService>() and use it.

The SDK automatically passes the App ID used for initialization with every later service access control call. Therefore, you do not specify the App ID again when you call the Service country restriction, Server maintenance, and Client update methods.

The SDK also automatically passes which language to receive among the notice messages registered by language in the console. Unless you set it separately, the device language at the time of initialization is used. If the app uses its own language setting, specify a language tag after initialization, such as HiveCore.SetLanguage("ko-KR"). If the console has no message in that language, the message registered in the default language is delivered instead.

Response data

No data is returned on success.

Response example

// No exception is thrown on success.
IServiceAccessService service = HiveCore.Resolve<IServiceAccessService>();

Response status

Check whether initialization and module registration succeeded with the result of HiveCore.Resolve<IServiceAccessService>(). If it returns the service access control module handle without throwing an exception, both steps are complete.

Initialization throws exceptions in the following cases.

  • Passing null to config throws ArgumentNullException
  • Calling the initialization method again after initialization is already complete throws InvalidOperationException

Unlike a Failure in a method call result, these exceptions make the initial setup fail immediately. For common principles, including the missing registration exception of Resolve<T>(), see Common error handling.

Next steps