Developer Zone

License Management

Revulytics Usage Intelligence allows you to maintain your own license key registry on the Revulytics Usage Intelligence server in order to track license key usage and verify the status/validity of license keys used on your clients.

There are multiple ways the key registry is populated with license keys.

  1. Keys are collected automatically from your clients whenever you call the setLicenseKey method.
  2. You can add/edit keys manually via the Revulytics Usage Intelligence dashboard.
  3. You can add/edit keys directly from your CRM by using the Revulytics Usage Intelligence Web API.

Client vs. Server Managed Licensing

Revulytics Usage Intelligence gives you the option to choose between managing your license key status (i.e. Blacklisted, Whitelisted, Expired or Activated) and key type on the server (server managed) or managing this status yourself through your client (client managed). You can individually set whether each license status or license type is either Sever Managed or Client Managed by visiting the License Key Management Settings page on the Revulytics Usage Intelligence dashboard. The major difference is outlined below:

1- Client managed: The server licensing mechanism works in reporting-only mode and your application is expected to notify the server that the license status has changed through the use of setLicenseDataKeyType.

When to use: You have implemented your own licensing module/mechanism within your application that can identify whether the license key used by this client is blacklisted, whitelisted, expired or activated. In this case you do not need to query the Revulytics Usage Intelligence server to get this license status. However you can simply use this function to passively inform Revulytics Usage Intelligence about the license status used by the client. In this case:

  1. Revulytics Usage Intelligence will use this info filter and report the different key types and statuses and their activity.
  2. Revulytics Usage Intelligence licensing server will operate in passive mode (i.e. reporting only).
  3. Calling checkLicenseKey will return RUI_FUNCTION_NOT_AVAIL since the key status is client managed.

2- Server managed: You manage the key status on the server side and your application queries the server to determine the status of a particular license key by calling checkLicenseKey or setLicenseKey.

When to use: If you do not have your own licensing module/mechanism within your application and thus you have no way to to identify the license status at the client side. In this mode, whenever a client changes their license key your application can call setLicenseKey to register the new license key. In reply to this API call, the server will check if the license key exists on the key register and in the reply it will specify to your application whether this key is flagged as blacklisted, whitelisted, expired or activated, along with the type of key submitted. If you want to verify a key without actually registering a key change for this client you can use checkLicenseKey that returns the same values but does not register this key with the server. In this case:

  1. The key register is maintained manually on the server by the software owner
  2. Revulytics Usage Intelligence licensing server will operate in active mode so apart from using this key info for filtering and reporting, it will also report back the key status (validity) to the SDK whenever requested through the API.
  3. Calling checkLicenseKey or setLicenseKey will return the 4 status flags denoting whether a registered key is: Blacklisted, Whitelisted, Expired and Activated and the key type.
  4. If the key does not exist on the server, all 4 status flags will be returned as false (0).

(RUIRESULTOBJC) checkLicenseKey: (NSString*)licenseKey returningLicenseArray: (NSMutableArray*)licenseArray

Checks the RUI Server for the license data for the supplied licenseKey. Whereas checkLicenseKey:returningLicenseArray: is a passive check, setLicenseKey:returningLicenseArray:sessionID: 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 RUI (Trackerbird) SDK V4.

checkLicenseKey:returningLicenseArray: can be called between startSDK and stopSDK:, and can be called zero or more times.

checkLicenseKey:returningLicenseArray: is a synchronous function returning when all functionality is completed.

The function accepts a NSString* parameter that is the license key itself and an NSMutableArray 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:

* RUI_LICENSE_ARRAY_INDEX_KEY_TYPE        (0)
* RUI_LICENSE_ARRAY_INDEX_KEY_EXPIRED     (1)
* RUI_LICENSE_ARRAY_INDEX_KEY_ACTIVE      (2)
* RUI_LICENSE_ARRAY_INDEX_KEY_BLACKLISTED (3)
* RUI_LICENSE_ARRAY_INDEX_KEY_WHITELISTED (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 (RUI_LICENSE_ARRAY_INDEX_KEY_TYPE) 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:

* RUI_KEY_TYPE_UNCHANGED  (-1) - Key Type is Unchanged (when in parameter) or Unknown (when out parameter)
* RUI_KEY_TYPE_EVALUATION (0)
* RUI_KEY_TYPE_PURCHASED  (1)
* RUI_KEY_TYPE_FREEWARE   (2)
* RUI_KEY_TYPE_UNKNOWN    (3)
* RUI_KEY_TYPE_NFR        (4) - Key Type is Not For Resale
* RUI_KEY_TYPE_CUSTOM1    (5)
* RUI_KEY_TYPE_CUSTOM2    (6)
* RUI_KEY_TYPE_CUSTOM3    (7)

The following are the possible key status values:

* RUI_KEY_STATUS_UNCHANGED (-1) - Key Status is Unchanged (when in parameter) or Unknown (when out parameter).
* RUI_KEY_STATUS_NO        (0)  - Key Status is No.
* RUI_KEY_STATUS_YES       (1)  - Key Status is Yes.

Parameters:

key (NSString*) - The license key to be tested.

licenseArray (NSMutableArray*) - This is an out parameter. The Revulytics Usage Intelligence SDK will always update the array

object. This object should be released when the Revulytics Usage Intelligence SDK Client no longer needs it. The value will be a 5-element integer array containing the License Status Flag values at the following indexes:

* RUI_LICENSE_ARRAY_INDEX_KEY_TYPE        (0)
* RUI_LICENSE_ARRAY_INDEX_KEY_EXPIRED     (1)
* RUI_LICENSE_ARRAY_INDEX_KEY_ACTIVE      (2)
* RUI_LICENSE_ARRAY_INDEX_KEY_BLACKLISTED (3)
* RUI_LICENSE_ARRAY_INDEX_KEY_WHITELISTED (4)

NOTE: Any of the array elements can be set to -1 to indicate the data is not available.

The array elements (RUI_LICENSE_ARRAY_INDEX_KEY_EXPIRED, RUI_LICENSE_ARRAY_INDEX_KEY_ACTIVE, RUI_LICENSE_ARRAY_INDEX_KEY_BLACKLISTED, RUI_LICENSE_ARRAY_INDEX_KEY_WHITELISTED) will be set to one of the following values:

* RUI_KEY_STATUS_UNCHANGED (-1) - Key Status is Unchanged (when in parameter) or Unknown (when out parameter).
* RUI_KEY_STATUS_NO        (0)  - Key Status is No.
* RUI_KEY_STATUS_YES       (1)  - Key Status is Yes.

The array element (RUI_LICENSE_ARRAY_INDEX_KEY_TYPE) will be set to one of the following License Type values:

* RUI_KEY_TYPE_UNCHANGED  (-1) - Key Type is Unchanged (when in parameter) or Unknown (when out parameter)
* RUI_KEY_TYPE_EVALUATION (0)
* RUI_KEY_TYPE_PURCHASED  (1)
* RUI_KEY_TYPE_FREEWARE   (2)
* RUI_KEY_TYPE_UNKNOWN    (3)
* RUI_KEY_TYPE_NFR        (4) - Key Type is Not For Resale
* RUI_KEY_TYPE_CUSTOM1    (5)
* RUI_KEY_TYPE_CUSTOM2    (6)
* RUI_KEY_TYPE_CUSTOM3    (7)

Return Type:

Integer constant from one of the following values:

* RUI_OK                                        Function successful
* RUI_SDK_INTERNAL_ERROR_FATAL                  Irrecoverable internal fatal error.  No further API calls should be made.
* RUI_SDK_ABORTED                               A required New Registration has failed, and hence the SDK is aborted.  StopSDK and RUISDK destructor are possible.
* RUI_SDK_SUSPENDED                             The RUI Server has instructed a temporary back-off.
* RUI_SDK_PERMANENTLY_DISABLED                  The RUI Server has instructed a permanent disable.
* RUI_SDK_OPTED_OUT                             Instance has been instructed by the application to opt-out.
* RUI_CONFIG_NOT_CREATED                        Configuration has not been successfully created.
* RUI_SDK_ALREADY_STOPPED                       SDK has already been successfully stopped.
* RUI_INVALID_PARAMETER_EXPECTED_NON_NULL       Some API parameter is expected to be non-NULL, and is not.
* RUI_INVALID_PARAMETER_EXPECTED_NON_EMPTY      Some API parameter is expected to be non-empty, and is not.
* RUI_TIME_THRESHOLD_NOT_REACHED                The API call frequency threshold (set by the RUI Server) has not been reached.
* RUI_NETWORK_CONNECTION_ERROR                  Not able to reach the RUI Server.
* RUI_NETWORK_SERVER_ERROR                      Error while communicating with the RUI Server.
* RUI_NETWORK_RESPONSE_INVALID                  Message format error while communicating with the RUI Server.

Code Example:

Passing “Test Key” as the key and checking the return

//OS X / ObjC Example.
//Test a license key
RUISDKOBJC* mySDK = [[RUISDKOBJC alloc]initRegisterDefaultGraphicalReachOutHandler:YES]; // = ...; //Creation and initialization shown in other snippets.


NSString* prod_key = @"Test Key";
NSMutableArray* license_result = [[NSMutableArray alloc] init];
if ([mySDK checkLicenseKey:prod_key returningLicenseArray:license_result] == RUI_OK) {

//Check license key type
    if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_TYPE] int32Value] == RUI_FUNCTION_NOT_AVAIL) {
        NSLog(@"License key information is unavailable");
    } else {
        NSLog(@"License key type is %d", [license_result[RUI_LICENSE_ARRAY_INDEX_KEY_TYPE] int32Value]);
    }
    //Check if the license is activated
    if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_ACTIVE] int32Value] == RUI_KEY_STATUS_YES) {
        NSLog(@"License is active");
    } else if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_ACTIVE] int32Value] == RUI_KEY_STATUS_NO) {
        NSLog(@"License is NOT active");
    } else {
        NSLog(@"License active status unknown");
    }
    //Check if key is blacklisted
    if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_BLACKLISTED] int32Value] == RUI_KEY_STATUS_YES) {
        NSLog(@"Key is blacklisted");
    } else if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_BLACKLISTED] int32Value] == RUI_KEY_STATUS_NO) {
        NSLog(@"Key is NOT blacklisted");
    } else {
        NSLog(@"Key blacklisted status unknown");
    }
    //Check if key is expired
    if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_EXPIRED] int32Value] == RUI_KEY_STATUS_YES) {
        NSLog(@"Key is expired");
    } else if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_EXPIRED] int32Value] == RUI_KEY_STATUS_NO) {
        NSLog(@"Key is NOT expired");
    } else {
        NSLog(@"Key expiration status unknown");
    }
    //Check if key is whitelisted
    if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_WHITELISTED] int32Value] == RUI_KEY_STATUS_YES) {
        NSLog(@"Key is whitelisted");
    } else if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_WHITELISTED] int32Value] == RUI_KEY_STATUS_NO) {
        NSLog(@"Key is NOT whitelisted");
    } else {
        NSLog(@"Key whitelisted status unknown");
    }
} else {
    NSLog(@"Failed to invoke function checkKey");
}
//  [prod_key release];       //Either release or use ARC.
//  [license_result release]; //Either release or use ARC.

(RUIRESULTOBJC) setLicenseKey: (NSString*)licenseKey returningLicenseArray: (NSMutableArray*)licenseArray sessionID: (NSString*) sessionID

This method should be called when an end user is trying to enter a new license key into your application and you would like to confirm that the key is in fact valid (i.e. blacklisted or whitelisted), active, or expired.

Checks the RUI Server for the license data for the supplied licenseKey and sets the current license to licenseKey. Whereas checkLicenseKey:returningLicenseArray: is a passive check, setLicenseKey:returningLicenseArray:sessionID: changes the license key. The RUI Server always registers the licenseKey even if the RUI Server knows nothing about the licenseKey. When a new (unknown) licenseKey is registered, the RUI Server sets the license data to keyType RUI_KEY_TYPE_UNKNOWN and the four status flags (blacklisted, whitelisted, expired, activated) to RUI_KEY_STATUS_NO. The license array has size, indexes and values as specified in RUISDKDefines.h:

NOTE: Different from the V4 of the RUI SDK, a sessionID parameter can be supplied,

NOTE: The order of the license array data has changed from the RUI SDK V4.

setLicenseKey:returningLicenseArray:sessionID: can be called between startSDK and stopSDK:, and can be called zero or more times.

setLicenseKey:returningLicenseArray:sessionID: is primarily a synchronous function, returning once the check with RUI Server has completed. Some post-processing functionality is performed asynchronously, executed on separate thread(s).

Parameters:

licenseKey (NSString*) - The license key to check and set as current. Cannot be empty.

licenseArray (NSMutableArray*) - This is an out parameter. The Revulytics Usage Intelligence SDK will always update the array

object. This object should be released when the Revulytics Usage Intelligence SDK Client no longer needs it. The value will be a 5-element integer array containing the License Status Flag values at the following indexes:

* RUI_LICENSE_ARRAY_INDEX_KEY_TYPE        (0)
* RUI_LICENSE_ARRAY_INDEX_KEY_EXPIRED     (1)
* RUI_LICENSE_ARRAY_INDEX_KEY_ACTIVE      (2)
* RUI_LICENSE_ARRAY_INDEX_KEY_BLACKLISTED (3)
* RUI_LICENSE_ARRAY_INDEX_KEY_WHITELISTED (4)

NOTE: Any of the array elements can be set to -1 to indicate the data is not available.

The array elements (RUI_LICENSE_ARRAY_INDEX_KEY_EXPIRED, RUI_LICENSE_ARRAY_INDEX_KEY_ACTIVE, RUI_LICENSE_ARRAY_INDEX_KEY_BLACKLISTED, RUI_LICENSE_ARRAY_INDEX_KEY_WHITELISTED) will be set to one of the following values:

* RUI_KEY_STATUS_UNCHANGED (-1) - Key Status is Unchanged (when in parameter) or Unknown (when out parameter).
* RUI_KEY_STATUS_NO        (0)  - Key Status is No.
* RUI_KEY_STATUS_YES       (1)  - Key Status is Yes.

The array element (RUI_LICENSE_ARRAY_INDEX_KEY_TYPE) will be set to one of the following License Type values:

* RUI_KEY_TYPE_UNCHANGED  (-1) - Key Type is Unchanged (when in parameter) or Unknown (when out parameter)
* RUI_KEY_TYPE_EVALUATION (0)
* RUI_KEY_TYPE_PURCHASED  (1)
* RUI_KEY_TYPE_FREEWARE   (2)
* RUI_KEY_TYPE_UNKNOWN    (3)
* RUI_KEY_TYPE_NFR        (4) - Key Type is Not For Resale
* RUI_KEY_TYPE_CUSTOM1    (5)
* RUI_KEY_TYPE_CUSTOM2    (6)
* RUI_KEY_TYPE_CUSTOM3    (7)

Return Type:

Integer constant from one of the following values:

* RUI_OK                                        Function successful
* RUI_SDK_INTERNAL_ERROR_FATAL                  Irrecoverable internal fatal error.  No further API calls should be made.
* RUI_SDK_ABORTED                               A required New Registration has failed, and hence the SDK is aborted.  StopSDK and RUISDK destructor are possible.
* RUI_SDK_SUSPENDED                             The RUI Server has instructed a temporary back-off.
* RUI_SDK_PERMANENTLY_DISABLED                  The RUI Server has instructed a permanent disable.
* RUI_SDK_OPTED_OUT                             Instance has been instructed by the application to opt-out.
* RUI_CONFIG_NOT_CREATED                        Configuration has not been successfully created.
* RUI_SDK_ALREADY_STOPPED                       SDK has already been successfully stopped.
* RUI_INVALID_PARAMETER_EXPECTED_NON_NULL       Some API parameter is expected to be non-NULL, and is not.
* RUI_INVALID_PARAMETER_EXPECTED_NON_EMPTY      Some API parameter is expected to be non-empty, and is not.
* RUI_TIME_THRESHOLD_NOT_REACHED                The API call frequency threshold (set by the RUI Server) has not been reached.
* RUI_NETWORK_CONNECTION_ERROR                  Not able to reach the RUI Server.
* RUI_NETWORK_SERVER_ERROR                      Error while communicating with the RUI Server.
* RUI_NETWORK_RESPONSE_INVALID                  Message format error while communicating with the RUI Server.

Code Example:

Changing the key to “Test Key Number 2” and checking the return
//OS X / ObjC Example.
//Register a new license key
RUISDKOBJC* mySDK = [[RUISDKOBJC alloc]initRegisterDefaultGraphicalReachOutHandler:YES]; // = ...; //Creation and initialization shown in other snippets.

NSString* new_key = @"Test Key Number 2";
NSMutableArray* license_result = [[NSMutableArray alloc] init];

NSString* session_id = @"";

licenseResult[RUI_LICENSE_ARRAY_INDEX_KEY_TYPE] = RUI_KEY_TYPE_EVALUATION;

if ([mySDK setLicenseKey:new_key returningLicenseArray:license_result sessionID:session_id] == RUI_OK) {

    //Check license key type
     if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_TYPE] int32Value] == RUI_FUNCTION_NOT_AVAIL) {
        NSLog(@"License key information is unavailable");
    } else {
        NSLog(@"License key type is %d", [license_result[RUI_LICENSE_ARRAY_INDEX_KEY_TYPE] int32Value]);
    }
    //Check if the license is activated
    if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_ACTIVE] int32Value] == RUI_KEY_STATUS_YES) {
        NSLog(@"License is active");
    } else if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_ACTIVE] int32Value] == RUI_KEY_STATUS_NO) {
        NSLog(@"License is NOT active");
    } else {
        NSLog(@"License active status unknown");
    }
    //Check if key is blacklisted
    if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_BLACKLISTED] int32Value] == RUI_KEY_STATUS_YES) {
        NSLog(@"Key is blacklisted");
    } else if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_BLACKLISTED] int32Value] == RUI_KEY_STATUS_NO) {
        NSLog(@"Key is NOT blacklisted");
    } else {
        NSLog(@"Key blacklisted status unknown");
    }
    //Check if key is expired
    if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_EXPIRED] int32Value] == RUI_KEY_STATUS_YES) {
        NSLog(@"Key is expired");
    } else if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_EXPIRED] int32Value] == RUI_KEY_STATUS_NO) {
        NSLog(@"Key is NOT expired");
    } else {
        NSLog(@"Key expiration status unknown");
    }
    //Check if key is whitelisted
    if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_WHITELISTED] int32Value] == RUI_KEY_STATUS_YES) {
        NSLog(@"Key is whitelisted");
    } else if ([license_result[RUI_LICENSE_ARRAY_INDEX_KEY_WHITELISTED] int32Value] == RUI_KEY_STATUS_NO) {
        NSLog(@"Key is NOT whitelisted");
    } else {
        NSLog(@"Key whitelisted status unknown");
    }
} else {
    NSLog(@"Failed to invoke function checkKey");
}
//  [prod_key release];       //Either release or use ARC.
//  [license_result release]; //Either release or use ARC.