Add ALC library dependency

Add ALC library dependency

Register the ONE store maven address in the project top-level build.gradle file.

For the Android Studio (version: bumblebee), add from settings.gradle.


...
buildscript {
repositories {
...
    maven { url 'https://repo.onestore.co.kr/repository/onestore-sdk-public' }
}
}
...

Next, add the ONE store ALC library dependency to the app’s build.gradle file.


...
dependencies {
def onestore_sdk_version = "2.0.0"
implementation "com.onestorecorp.sdk:sdk-licensing:$onestore_sdk_version"
}
...

Add queries to AndroidManifest.xml

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

For Android 11 or higher (Target SDK 30 or higher), you must add queries.


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dev.sample">
<queries>
<intent>
<action android:name="com.onestore.extern.licensing.LicensingService.ACTION" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="onestore" />
</intent>
</queries>
...

Add configuration for ONE store login

Register the ONE store maven address in the project top-level build.gradle file.

It is the same as the pre-operation when adding ALC library dependencies.


...
buildscript {
repositories {
...
    maven { url 'https://repo.onestore.co.kr/repository/onestore-sdk-public' }
}
}
...

Next, add the ONE store configuration library dependency to the app's build.gradle file.


...
dependencies {
def onestore_configuration_version = "1.0.0"
implementation "com.onestorecorp.sdk:sdk-configuration-kr:$onestore_configuration_version"
}
...

Initialize AppLicenseChecker

To request a user's purchase license using the Application License Checker, you must create an instance of AppLicenseChecker.

You must pass the license key issued by the Developer Center for license verification. As the results of whether you have a valid license are delivered through LicenseCheckerListener, you must also create a Listener at initialization.

Saving the license key

For license keys, it is recommended to use it after receiving it through a server rather than saving it as an in-app code to ensure security.

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
val appLicenseChecker = AppLicenseChecker.get(this@MainActivity, getString(R.string.publick_key, new AppLicenseListener())
}

...
inner class AppLicenseListener : LicenseCheckerListener {
override fun granted(license: String, signature: String) {}

override fun denied() {}

override fun error(code: Int, message: String) {}
}

Callback registration

When initializing AppLicenseChecker, LicenseCheckerListener must be registered.

LicenseCheckeerListener is an interface for processing the results of license verifications. License verification results always call one of the LicenseCheckeerListener methods.

There are three methods: granted(), denied(), and error(), and simple result processing behavior can be used. The error() method forwards error codes and messages. For error codes, please refer to the response codes below.

class AppLicenseListener : LicenseCheckerListener {
override fun granted(license: String, signature: String) {
// License check successful
}

override fun denied() {
// Rejeck license check
}

override fun error(code: Int, message: String) {
// License check error
}
}

Request license verification

When calling the license check, the license is delivered through communication with the ONE store server. When users are unable to 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 a license cached 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 failures or airplane mode, a locally cached license is used to ensure execution until the expiration date.

appLicenseChecker.queryLicense()

Calling StrictQueryLicense API (Non-Cached API)

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

appLicenseChecker.strictQueryLicense()

Disconnecting

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

override fun onDestroy() {
if (null != appLicenseChecker) {
appLicenseChecker.destroy()
}

super.onDestory()
}

Response Codes

The table below shows the response codes and messages for errors delivered from the ONE store ALC library to the application. Applications that use the library must process the response codes.

Last updated