Checking the License Data of the Supplied License Key
The RUISDK.CheckLicenseKey function checks the Server for the license data for the supplied licenseKey. Whereas RUISDK.CheckLicenseKey is a passive check, RUISDK.SetLicenseKey changes the license key. The license array has size, indexes and values as specified in RUISDKDefines.h.
Note:The order of the license array data has changed from the Usage Intelligence (Trackerbird) SDK V4.
The RUISDK.CheckLicenseKey function can be called between RUISDK.StartSDK and RUISDK.StopSDK, and can be called zero or more times.
The RUISDK.CheckLicenseKey function is a synchronous function returning when all functionality is completed.
RUIResult RUISDK.CheckLicenseKey (String licenseKey, out List<Int32> licenseArray)
Parameters
The RUISDK.CheckLicenseKey function has the following parameters.
Parameter |
Description |
|||||||||
licenseKey (String) |
The license key to be checked. This value cannot be empty. The function accepts a String parameter that is the license key itself and a List<Int32> array of length 5 that it fills with the returned result. You may use the following constants to refer to the required value by its index from the RUILicenseKeyIndex enum: typeIndex (0) expiredIndex (1) activeIndex (2) blacklistedIndex (3) whitelistedIndex (4) Each of the values 1 through 5 will be set to either 0 or 1 that refers to false or true respectively. The first value (RUILicenseKeyIndex.typeIndex) will be set to a number between 0 and 7 (inclusive) that refers to the 8 possible license types listed below. The values may also be -1 that means “Unknown”. The following are the possible license types from the RUILicenseKeyType enum: unchanged (-1) - Key Type is Unchanged (when in parameter) or Unknown (when out parameter) evaluation (0) purchased (1) freeware (2) unknown (3) nfr (4) - Key Type is Not For Resale custom1 (5) custom2 (6) custom3 (7) The following are the possible key status values from the RUILicenseKeyStatus enum:
|
|||||||||
licenseArray (List<Int32> length of 5) |
The vector that will be filled to contain the license status flags. |
Returns
The RUISDK.CheckLicenseKey function returns a RUIResult enum value with the following possible values.
Return |
Description |
ok |
Function successful. |
sdkInternalErrorFatal |
Irrecoverable internal fatal error. No further API calls should be made. |
sdkAborted |
A required New Registration has failed, and hence the SDK is aborted. RUISDK.StopSDK and RUISDK destructor are possible. |
suspended |
Instance has been instructed by Server to back-off. Will return to Running once back-off cleared. |
permanentlyDisabled |
Instance has been instructed by Server to disable. This is permanent, irrecoverable state. |
sdkOptedOut |
Instance has been instructed by the application to opt-out. |
configNotCreated |
Function validation: Configuration has not been successfully created. |
sdkNotStarted |
Function validation: SDK has not been successfully started. |
sdkAlreadyStopped |
Function validation: SDK has already been successfully stopped. |
invalidParameterExpectedNonEmpty |
Some API parameter is expected to be non-empty, and is not. |
timeThresholdNotReached |
Function validation: The API call frequency threshold (set by the Server) has not been reached. |
networkConnectionError |
Not able to reach the Server. |
networkServerError |
Error while communicating with the Server. |
networkResponseInvalid |
Message format error while communicating with the Server. |
Code Example
//Test a license key
mySDK.StartSDK(); //...; //Creation and initialization shown in other snippets.
String myProductKey = "xyz";
List<Int32> licenseResult;
RUIResult rc = mySDK.CheckLicenseKey(myProductKey, out licenseResult);
if(rc == RUIResult.ok)
{
if (licenseResult[(Int32)RUILicenseKeyIndex.typeIndex] == (Int32)RUILicenseKeyType.unchanged) {
MessageBox.Show("License Key is unchanged");
} else {
String myType = "License type = " + (licenseResult[(Int32)RUILicenseKeyIndex.typeIndex]).ToString();
MessageBox.Show(myType);
}
//Check if the license key is activated
if (licenseResult[(Int32)RUILicenseKeyIndex.activeIndex] == (Int32)RUILicenseKeyStatus.yes){
MessageBox.Show("License Active");
} else if (licenseResult[(Int32)RUILicenseKeyIndex.activeIndex] == (Int32)RUILicenseKeyStatus.no) {
MessageBox.Show("License Inactive");
} else {
MessageBox.Show("License status unknown");
}
//check if license key is blacklisted
if (licenseResult[(Int32)RUILicenseKeyIndex.blacklistedIndex] == (Int32)RUILicenseKeyStatus.yes){
MessageBox.Show("Key is black listed");
} else if (licenseResult[(Int32)RUILicenseKeyIndex.blacklistedIndex] == (Int32)RUILicenseKeyStatus.no) {
MessageBox.Show("Key is NOT black listed");
} else {
MessageBox.Show("Key blank listed status is unknown");
}
//Check if license key is expired
if (licenseResult[(Int32)RUILicenseKeyIndex.expiredIndex] == (Int32)RUILicenseKeyStatus.yes){
MessageBox.Show("Key is expired");
} else if (licenseResult[(Int32)RUILicenseKeyIndex.expiredIndex] == (Int32)RUILicenseKeyStatus.no) {
MessageBox.Show("Key is NOT expired");
} else {
MessageBox.Show("Key expiration status is unknown");
}
//Check if license key is white listed
if (licenseResult[(Int32)RUILicenseKeyIndex.whitelistedIndex] == (Int32)RUILicenseKeyStatus.yes){
MessageBox.Show("Key is white listed");
} else if (licenseResult[(Int32)RUILicenseKeyIndex.whitelistedIndex] == (Int32)RUILicenseKeyStatus.no) {
MessageBox.Show("Key is NOT white listed");
} else {
MessageBox.Show("Key white listed status is unknown");
}
} else {
MessageBox.Show("Failed to invoke function RUISDK.CheckLicenseKey()");
}