# Using ALC SDK V2 in Unity

### Overview <a href="#usingalcsdkv2inunity-overview" id="usingalcsdkv2inunity-overview"></a>

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.

<br>

### ONE store App License Verification Plug-in settings <a href="#usingalcsdkv2inunity-onestoreapplicenseverificationplug-insettings" id="usingalcsdkv2inunity-onestoreapplicenseverificationplug-insettings"></a>

#### Downloading and using plug-ins <a href="#usingalcsdkv2inunity-downloadingandusingplug-ins" id="usingalcsdkv2inunity-downloadingandusingplug-ins"></a>

1. Download the latest version of the [ONE store ALC plug-in for Unity from the Release page](https://github.com/ONE-store/app_license_checker) of the ONE store SDK sample GitHub.
2. In the Unity menu bar, click **Assets > Import Package > Custom Package**.<br>
   1\.

   ```
   <figure><img src="https://2218522982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgStyyzRzNh9x2u93ZH03%2Fuploads%2FiEbgeFi91qyMouaaqIGr%2Fimage.png?alt=media&#x26;token=14217830-b167-4a4b-83da-472cd126a145" alt=""><figcaption></figcaption></figure>
   ```
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 <a href="#usingalcsdkv2inunity-settingupbuilds" id="usingalcsdkv2inunity-settingupbuilds"></a>

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

* [For Target SDK version set to 30 (OS11) or higher](https://dev.onestore.co.kr/devpoc/support/news/noticeView.omp?pageNo=4\&noticeId=32968\&viewPageNo=\&searchValue=)
* [For Target SDK version set to 31 (OS12) or higher](https://dev.onestore.co.kr/devpoc/support/news/noticeView.omp?pageNo=1\&noticeId=33072\&viewPageNo=\&searchValue=)

Add the items **below** through the Player settings of Unity.

* **Custom Main Manifest**
* **Custom Main Gradle Template**
* **Custom Launcher Gradle Template**

<figure><img src="https://2218522982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgStyyzRzNh9x2u93ZH03%2Fuploads%2FEKxMwkLWFZIyv9HI0BAR%2Fimage.png?alt=media&#x26;token=656c4acd-33f4-4de3-8f5e-da7eff79a5bb" alt=""><figcaption></figcaption></figure>

<br>

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

<figure><img src="https://2218522982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgStyyzRzNh9x2u93ZH03%2Fuploads%2FjUrIeUzNZoJlaxS7F7SF%2Fimage.png?alt=media&#x26;token=f6b7b749-9b23-4f99-836a-dcea64ea3897" alt=""><figcaption></figcaption></figure>

### Applying ONE store ALC (Application License Checker) library to games <a href="#usingalcsdkv2inunity-applyingonestorealc-applicationlicensechecker-librarytogames" id="usingalcsdkv2inunity-applyingonestorealc-applicationlicensechecker-librarytogames"></a>

#### Copying a ONE store license key <a href="#usingalcsdkv2inunity-copyingaonestorelicensekey" id="usingalcsdkv2inunity-copyingaonestorelicensekey"></a>

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.

<figure><img src="https://2218522982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgStyyzRzNh9x2u93ZH03%2Fuploads%2FaMzp4cKdCO7p4tfok8T5%2Fimage.png?alt=media&#x26;token=2b4b5f3c-a16e-4c96-ba50-cb5fc4424105" alt=""><figcaption></figcaption></figure>

<br>

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.

<br>

### Requesting license verification <a href="#usingalcsdkv2inunity-requestinglicenseverification" id="usingalcsdkv2inunity-requestinglicenseverification"></a>

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) <a href="#usingalcsdkv2inunity-callingquerylicenseapi-cachedapi" id="usingalcsdkv2inunity-callingquerylicenseapi-cachedapi"></a>

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.

```csharp

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) <a href="#usingalcsdkv2inunity-callingstrictquerylicenseapi-non-cachedapi" id="usingalcsdkv2inunity-callingstrictquerylicenseapi-non-cachedapi"></a>

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.

```csharp

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 <a href="#usingalcsdkv2inunity-disconnecting" id="usingalcsdkv2inunity-disconnecting"></a>

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

```csharp

using OneStore.Alc;

_appLicenseCheckerImpl.Destroy();
```
