Using ALC SDK V2 in Unity

概要

ONE store APP许可证验证插件是支持在 Unity 环境中扩展 assets 来轻松应用收费应用程序购买验证的插件。 下面的指南说明在项目中设置和使用插件的方法,以及实现 ONE store 应用程序许可证验证Library功能的方法。

ONE store 应用软件许可证验证插件设置

下载并获取插件

  1. ONE store SDK 示例 GitHub的 Release 页面(链接)中,下载适用于 Unity的最新版本的 ONE store ALC支付插件。

  2. Unity 菜单栏中,点击 Assets > Import Package > Custom Package

  3. 找到ONE store SDK 插件的文件位置,选择 .unitypackage 文件

  4. Import Package 对话框中,选择所有 assets 后点击 Import.

导入包时添加文件夹。该文件夹包含应用程序的许可证验证Library。

  • Assets > OneStoreCorpPlugins 文件夹

Build设置

以下两种情况,请参考ONE store 公告进行设置

通过Unity Player 设置,添加下列项目

  • Custom Main Manifest

  • Custom Main Gradle Template

  • Custom Launcher Gradle Template

Assets > Plugins > Android 文件夹中创建文件。

游戏中应用ONE store ALC(Application License Checker) Library

复制ONE store许可证密钥

在 ONE store APP商品状态中进入许可证管理菜单。使用 ALC 需要许可证密钥。 通过复制 ONE store 开发者中心提供的应用程序的许可证密钥来创建 ALC 对象。

调用Initialize() 函数进行基本设置,通过ILicenseCheckCallback 接口接收验证结果Event。 调用函数函数进行基本设置,通过ILicenseCheckCallback接口接收验证结果事件。 以下操作是连接到 ONE store 服务和请求应用程序许可证验证的先决条件。

许可证验证请求

调用许可证验证时,通过与 ONE store 服务器的通信传递许可证。用户因网络故障或飞行模式等原因无法正常访问ONE store服务器时,一般采使用缓存策略,保证缓存License有效期内应用软件的正常运行。 如果不想使用缓存策略,可通过 strictQueryLicense API 不使用缓存的许可证。

调用QueryLicense API (Cached API)

协同缓存策略操作。 一般情况下,通过ONE store服务器接收用户购买历史的License,但因网络故障或飞行模式等原因无法访问ONE store服务器时,使用本地缓存的License来保证有效期内的正常运行。


using OneStore.Alc;

class YourCallback: ILicenseCheckCallback
{
// ILicenseCheckCallback implementations.
public void OnGranted(string license, string signature) { }
public void OnDenied() {}
public void OnError(int code, string message)
}

_appLicenseCheckerImpl.QueryLicense();

调用StrictQueryLicense API (Non-Cached API)

不使用缓存的许可证。 如果在网络故障或飞行模式下使用该 API, 因为无法访问 ONE store 服务器,用户无法使用应用程序 。


using OneStore.Alc;

class YourCallback: ILicenseCheckCallback
{
// ILicenseCheckCallback implementations.
public void OnGranted(string license, string signature) { }
public void OnDenied() {}
public void OnError(int code, string message)
}

_appLicenseCheckerImpl.StrictQueryLicense();

断开连接

调用AppLicenseChecker的destroy函数,断开ONE store服务连接


using OneStore.Alc;

_appLicenseCheckerImpl.Destroy();

Overview

The ONE store App License Verification Plug-in is a plug-in that allows you to easily apply paid app purchase checks by expanding assets in the Unity environment.

The guide below explains how to set up and use plug-ins in your project and how to implement the ONE store App License Verification Library feature.

ONE store App License Verification Plug-in settings

Downloading and using plug-ins

  1. Download the latest version of the ONE store ALC plug-in for Unity from the Release page of the ONE store SDK sample GitHub.

  2. In the Unity menu bar, click Assets > Import Package > Custom Package.

  3. Locate where you downloaded the ONE store SDK plugin and select the .unitypackage file.

  4. In the Import Package dialog box, leave all assets selected and click Import.

Folders are added when packages are imported. These folders contain the app license validation library.

  • Assets > OneStoreCorpPlugins folder

Setting up builds

Please refer to the ONE store notices for setting up the following two cases:

Add the items below through the Player settings of Unity.

  • Custom Main Manifest

  • Custom Main Gradle Template

  • Custom Launcher Gradle Template

The files are created in the Assets > Plug-ins > Android folder.

Applying ONE store ALC (Application License Checker) library to games

Copying a ONE store license key

Enter the license management menu from the ONE store app product status. A license key is required to use ALC.

Create an ALC object by copying the license key of the app provided by the ONE store Developer Center.

Call the Initialize() function to set the default settings and receive the verification result event through the ILicenseCheckCallback interface.

The tasks below are prerequisites for connecting to the ONE store service and requesting app license verification.

Requesting license verification

When calling the license check, the license is delivered through communication with the ONE store server. When users cannot access the ONE store server normally due to network failures or airplane mode, etc., a cache policy is generally used to ensure the app runs during the validity period of the cached license. If you do not want to use the cache policy, you can use it without using the cached license through the strictQueryLicense API.

Calling QueryLicense API (Cached API)

Works in conjunction with the cache policy. Generally, a user's purchase history license is delivered through the ONE store server, but when access to the ONE store server is not possible due to network failure or airplane mode, a locally cached license is used to ensure execution until the expiration date.


using OneStore.Alc;

class YourCallback: ILicenseCheckCallback
{
// ILicenseCheckCallback implementations.
public void OnGranted(string license, string signature) { }
public void OnDenied() {}
public void OnError(int code, string message)
}

_appLicenseCheckerImpl.QueryLicense();

Calling StrictQueryLicense API (Non-Cached API)

Cached licenses are not to be used. If the API is used in a network failure situation or airplane mode, the user cannot use the app because the ONE store server is not accessible.


using OneStore.Alc;

class YourCallback: ILicenseCheckCallback
{
// ILicenseCheckCallback implementations.
public void OnGranted(string license, string signature) { }
public void OnDenied() {}
public void OnError(int code, string message)
}

_appLicenseCheckerImpl.StrictQueryLicense();

Disconnecting

Call the destroy function in AppLicenseChecker to disconnect from the ONE store service.


using OneStore.Alc;

_appLicenseCheckerImpl.Destroy();

Last updated