Storage module
This is a key-value storage module that encrypts sensitive string values, such as authentication tokens, and keeps them in the device's secure storage. It provides saving, retrieving, and deleting values, and clearing the storage. Saved values persist even after the app restarts.
The Hive Axyl SDK keeps the login session only in memory. To restore the login state after the app restarts, the app must save the credentials itself, and you can use this module as that storage. The app decides which values to save and delete, and when.
Module information
- Package:
com.com2usplatform.hiveaxyl.storage - Namespace:
Hive.Axyl.Storage - Supported platforms: Android, Windows, iOS, macOS
- Minimum requirements: Android API 29+, iOS 17+, macOS 15+, Unity 6000.0+
Provided interfaces
| Interface | Registration method | Description |
|---|---|---|
| ISecureStorage | AddSecureStorage() | Saving, retrieving, and deleting values, and clearing the storage |
Registration and retrieval
Register the module with AddSecureStorage() in the registration step of HiveBootstrap.Initialize, and then retrieve it with HiveCore.TryResolve<T>().
using Hive.Axyl.Core;
using Hive.Axyl.Core.Unity; // HiveBootstrap
using Hive.Axyl.Storage;
var config = CoreConfig.CreateBuilder("{appId}").Build();
HiveBootstrap.Initialize(config, builder =>
{
builder.AddSecureStorage();
});
if (HiveCore.TryResolve<ISecureStorage>(out var storage))
{
// Code that runs only in players built for supported platforms
}
ISecureStorage is registered only in players built for supported platforms and is not registered in the Unity Editor. For the flow that restores the login state with saved credentials, see Implement automatic login.