Licensing#
To integrate LUNA ID with your project and use its features, you need to activate the license.
License activation#
In LUNA ID for Android#
To activate the license:
1․ Request Server, EID, and ProductID from VisionLabs. For details, see License parameters.
2․ Specify the received parameters in the license.conf file and save the changes.
3․ Place the file in the assets/data/license.conf directory of your project.
The license key will be generated and saved to the specified directory. The license file has a binary format. At the next launch of the mobile app on the same device, the license will be read from this file.
4․ Initialize LUNA ID and activate the license by calling the activateLicense()
method:
Note: The parameters in the example are set to default values.
private fun initLunaSdk() {
val baseUrl = "url"
val token = "token"
val headers = mapOf("Authorization" to token)
val apiHumanConfig = ApiHumanConfig(baseUrl, headers)
val lunaConfig = LunaConfig.create(
acceptOccludedFaces = true,
acceptOneEyed = false,
acceptEyesClosed = false,
detectFrameSize = 350,
skipFrames = 36,
ags = 0.5f,
bestShotInterval = 500,
detectorStep = 1,
usePrimaryFaceTracking = true,
glassesChecks = setOf(GlassesCheckType.GLASSES_CHECK_SUN)
)
LunaID.activateLicense(
app = this@App,
lunaConfig = lunaConfig,
apiHumanConfig = apiHumanConfig
)
}
The example has the following components:
Component | Description |
---|---|
baseUrl |
A variable that specifies the URL to LUNA PLATFORM 5. For details, see Interaction of LUNA ID with LUNA PLATFORM 5. |
token |
A variable that specifies a LUNA PLATFORM 5 token, which will be transferred to a request header from LUNA ID. |
headers |
A map that specifies headers that will be added to each request to be sent to LUNA PLATFORM 5. |
apiHumanConfig |
An optional configuration parameter for calling the LUNA PLATFORM 5 API. Can be set to null if no LUNA PLATFORM 5 API calls are required. This will also disable the Online OneShotLiveness estimation, regardless of the onlineLivenessSettings argument. |
ApiHumanConfig |
A class required for configuration to call the LUNA PLATFORM 5 API. |
lunaConfig |
An argument to be passed for best shot parameters. |
LunaConfig |
A class that describes best shot parameters. |
acceptOccludedFaces |
A parameter that specifies whether an image with an occluded face will be considered the best shot. For details, see Getting the best shot with an occluded face. |
acceptOneEyed |
A parameter that specifies whether blinking with one eye is enabled. |
acceptEyesClosed |
A parameter that specifies whether an image with two closed eyes will be considered the best shot. For details, see Getting the best shot with faces with closed eyes. |
detectFrameSize |
A parameter that specifies a face detection bounding box size. |
skipFrames |
A parameter that specifies a number of frames to wait until a face is detected in the face recognition area before video recording is stopped. |
ags |
A parameter that specifies a source image score for further descriptor extraction and matching. For details, see AGS. |
bestShotInterval |
A parameter that specifies a minimum time interval between best shots. |
detectorStep |
A parameter that specifies a number of frames between frames with full face detection. |
usePrimaryFaceTracking |
Specifies whether to track the face that was detected in the face recognition area first. For details, see Tracking face identity. |
glassesChecks |
Specifies what images with glasses can be best shots. For details, see Getting the best shot with faces with occluded eyes. |
LunaID.activateLicense |
A method that activates the LUNA ID license. |
5․ Subscribe to an event from the LunaID.EngineInitStatus
flow:
LunaID.EngineInitStatus.flowWithLifecycle(this.lifecycle, Lifecycle.State.STARTED)
.onEach {
if(it is LunaID.EngineInitStatus.InProgress) {
// LUNA ID is loading
}else if(it is LunaID.EngineInitStatus.Success) {
// LUNA ID is ready
}
}.flowOn(Dispatchers.Main)
.launchIn(this.lifecycleScope)
Now, you can start the camera and proceed with embedding LUNA ID functionality in your app.
For a detailed example, see App.kt.
Example license file#
Below is a sample content of the "license.conf" file:
<?xml version="1.0"?>
<settings>
<section name="Licensing::Settings">
<param name="Server" type="Value::String" text=""/>
<param name="EID" type="Value::String" text=""/>
<param name="ProductID" type="Value::String" text=""/>
<param name="Filename" type="Value::String" text="license.dat"/>
<param name="ContainerMode" type="Value::Int1" x="0"/>
<param name="ConnectionTimeout" type="Value::Int1" x="15"/>
</section>
</settings>
In LUNA ID for iOS#
To activate the license:
1․ Request Server, EID, and ProductID from VisionLabs. For details, see License parameters.
2․ Specify the received parameters in the "vllicense.plist" file and save the changes.
3․ Add the file to your final app.
The license key will be generated and saved to the specified directory. The license file has a binary format. At the next launch of the mobile app on the same device, the license will be read from this file.
You can optionally rename the "vllicense.plist" file. To do this, change the default value, which is vllicense.plist
, of the LCLunaConfiguration::plistLicenseFileName
property.
Example license file#
Below is a sample content of the "vllicense.plist" file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Server</key>
<string></string>
<key>ProductID</key>
<string></string>
<key>EID</key>
<string></string>
<key>ContainerMode</key>
<real></real>
<key>ConnectionTimeout</key>
<integer></integer>
<key>Filename</key>
<string>license.dat</string>
</dict>
</plist>
License parameters#
License parameters and further processing requires the following parameter:
Parameter | Description | Type | Default value | Required |
---|---|---|---|---|
Server |
Activation server URL. | String | Not set | Yes |
EID |
Entitlement ID. | String | Not set | Yes |
ProductID |
Product ID. | String | Not set | Yes |
Filename |
The default name of the file to save the license to after activation. The maximum length of the file name is 64 symbols. We do not recommend that you change this name. | String | Not set | No |
ContainerMode |
If run in container. | Real | 0 | No |
ConnectionTimeout |
The maximum time, in seconds, for the transfer operation to take. Setting the timeout to 0 means that it never times out during transfer. You can't set the parameter to a negative value. The maximum value is 300 seconds. | Integer | 15 | No |
Working with status code 1025#
Status code 1025 applies to LUNA ID for iOS and informs about a license check failure.
To retrieve status code 1025 and its corresponding error message, do the following:
1․ Call the activateLicense
method. Here is an example of how you might set this up:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any] ? )->Bool {
AppAppearance.setupAppearance()
let configuration = LCLunaConfiguration()
configuration.identifyHandlerID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
configuration.registrationHandlerID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
configuration.verifyID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
configuration.lunaAccountID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
configuration.lunaServerURL = URL(string: "https://luna-api-aws.visionlabs.ru/6")
configuration.plistLicenseFileName = "vllicense.plist"
let error = configuration.activateLicense()debugPrint("error while license check \(error)")
let viewController = LERootViewController()
let navvc = UINavigationController(rootViewController: viewController)window = UIWindow(frame: UIScreen.main.bounds)
window?.backgroundColor = .white window?.rootViewController = navvc
window?.makeKeyAndVisible()
return true
}
2․ Get the error message by calling (error as NSError).localizedDescription
. This will give you a more detailed description of what went wrong.
3․ Get the error code by calling (error as NSError).code
. This will help you identify and troubleshoot specific issues related to the license activation process.