signoAPI iOS – STLicenceManager class

The STLicenceManager class is used to license the respective API components libSignoPdfSigner or libSignoSignatureCapture. The class makes it possible to activate, update, apply and release a licence in the new UUID format (XXXXXXXX–XXXX–XXXX–XXXX–XXXXXXXXXXXX) and to request the status of the licence that is currently being used. For licence keys in the old format, please use the method from the classes and .

The licence is activated by means of a licence key. After a successful licence key check, the activation is performed and the demo notice is removed from the signature image and the signature dialog. If the licence check reveals that the maximum number of activations has been reached, the licence will need to be extended for a fee. Alternatively, the activation can be transferred from a different device, e.g. if it is no longer used; please observe in this regard the method. Where possible, however, activation should be released before deinstallation with the method to avoid this problem.

There are two licensing variants available: A simpler variant without error output which only returns a status value as an integer, and an extended variant with an NSError** parameter which provides detailed error information in the event of an error.

In the simpler variant, all methods for activating, updating and releasing the licence return an integer that can be used to identify whether the respective method was executed successfully or whether an error occurred.

In the extended variant, the properties and contain the following information: a value of the enum Error defined with NS_ENUM, which can be used to recognise an error. This Error value is also accessible via the object returned by the method [], more precisely via the licenceError property of STLicenceResult as follows: -[[[STLicenceManager getLicenceStatus] licenceResult] licenceError] When executing the methods for activating, updating and releasing the licence, an NSError may occur in the event of an error. The corresponding error and the error message can be queried via the NSError object. The object contains additional information in the userInfo dictionary. The userInfo dictionary of the NSError object contains an NSNumber under the “LicenceError” key, which represents a value of the LicenceError enum defined with NS_ENUM(NSInteger, LicenceError). The localised error message is available via the localizedDescription property of the NSError object.

The class declaration is as follows:

@interface STLicenceManager: NSObject

The instantiation of the STLicenceManager class is not possible by means of init methods, but only with the static method +[].

getLicenceManager: method

For the STLicenceManager class there is only one single instance (singleton instance) that can be accessed by this static method.

+(STLicenceManager*)getLicenceManager

Parameter

Description

-

-

Return value

Description

STLicenceManager*

The singleton instance of the STLicenceManager class.

Usage:

STLicenceManager *licenceManager = [STLicenceManager getLicenceManager];

activateLicence:withForceActivation: method

This method can be used to perform the licence activation and the licence acquisition. The licence is activated by means of a licence key. After successful activation, the demo notice is removed from the signature image and the signature dialog. Please use the licence key that was given to you by your contact at signotec or give the user the ability to enter a licence key.

Transferring an activation from another device results in all activations of the licence being reset and reallocated automatically on the basis of the maximum permitted number of activations by means of the regular licence check. Please note that an activation can only be transferred one single time without having to reinstall the app.

(int)activateLicence:(NSString*)licenceKey withForceActivation:(BOOL)forceActivation

Parameter

Description


(NSString*)licenceKey

Licence keys


(BOOL)forceActivation

YES

Transfer an activation from another device.


NO

Do not transfer activation.

Return value

Description


int

0

Method was executed successfully.


< 0

An error occurred (see above) – it was not possible to activate the software.

Usage:

int ret = [licenceManager activateLicenceKey:@"1234" withForceActivation:NO];
if (ret < 0)
{
    if (ret == -510)
    {
        // activation limit reached, ask user if he wants to transfer 
        // the licence from another device
        // ... 
        if (transfer)
        {
            ret = [licenceManager activateLicenceKey:@"1234" withForceActivation:YES];
        }
        else
        {
            ret = 0;
        }
    }
    if (ret < 0)
    {
        // error handling
    }
}

updateLicence: method

This method can be used to call the properties of the licence again if they have changed.

(int)updateLicence

Parameter

Description


-

-


Return value

Description


int

0

Method was executed successfully.


< 0

An error occurred (see above) – the licensing status has not changed.

Usage:

int ret = [licenceManager updateLicence];
if (ret < 0)
{
    // error handling
}

releaseLicence: method

This method makes it possible to revoke the activation and therefore enable an activation.

(int)releaseLicence

Parameter

Description


-

-


Return value

Description


int

0

Method was executed successfully – the software is running in demo mode.


< 0

An error occurred (see above) – the licensing status has not changed.

Usage:

int ret = [licenceManager releaseLicence];
if (ret < 0)
{
    // error handling
}

activateLicence:withForceActivation:error method

This method can be used to perform the licence activation and the licence acquisition. The licence is activated by means of a licence key. After successful activation, the demo notice is removed from the signature image and the signature dialog. Please use the licence key that was given to you by your contact at signotec or give the user the ability to enter a licence key.

Transferring an activation from another device results in all activations of the licence being reset and reallocated automatically on the basis of the maximum permitted number of activations by means of the regular licence check. Please note that an activation can only be transferred one single time without having to reinstall the app.

(void)activateLicence:(NSString*)licenceKey withForceActivation:(BOOL)forceActivation error:(NSError**)error

Parameter

Description


(NSString*)licenceKey

Licence keys


(BOOL)forceActivation

YES

Transfer an activation from another device.


NO

Do not transfer activation.

(NSError*)error

Returns an NSError object in the event of an error, which contains information about the cause of the error. If this object is not nil, the software could not be activated. The object contains additional information in the userInfo dictionary. The userInfo dictionary of the NSError object contains an NSNumber under the “LicenceError” key, which represents a value of the LicenceError enum defined with NS_ENUM(NSInteger, LicenceError). The localised error message is available via the localizedDescription property of the NSError object. However, if the NSError object is nil, the method was executed successfully.


Return value

Description


-

-


Usage:

NSError *error = nil;
[self.licenceManager activateLicence:licenceKey withForceActivation:NO error:&error];

if (error) {
    NSNumber *errorNumber = error.userInfo[@"LicenceError"];
    if ([errorNumber isKindOfClass:[NSNumber class]]) {
        LicenceError licenceError = (LicenceError)[errorNumber intValue];
        if (licenceError == LicenceErrorActivation_Limit_Reached) {
            NSLog(@"%@", [error localizedDescription]);
            // activation limit reached, ask user if he wants to transfer 
            // the licence from another device
            // ... 
            if (transfer){
               NSError *error1 = nil;
               ret = [licenceManager activateLicenceKey:@"1234" withForceActivation:YES error:&error1];
               if(error1){
                  // error handling
               } else {
                  // transfer successfully executed
               }
            }
        }
    }
} else {
    // license successfully activated
}

updateLicence:error: method

This method can be used to call the properties of the licence again if they have changed.

(void)updateLicence:(NSError**)error

Parameter

Description

(NSError*)error

Returns an NSError object in the event of an error, which contains information about the cause of the error. If this object is not nil, the licence status has not changed. The object contains additional information in the userInfo dictionary. The userInfo dictionary of the NSError object contains an NSNumber under the “LicenceError” key, which represents a value of the LicenceError enum defined with NS_ENUM(NSInteger, LicenceError). The localised error message is available via the localizedDescription property of the NSError object. However, if the NSError object is nil, the method was executed successfully.

Return value

Description

-

-

Usage:

NSError *error = nil;
[licenceManager updateLicence:&error];
if (error)
{
    // error handling
} else {
    // license successfully updated
}

releaseLicence:error: method

This method makes it possible to revoke the activation and therefore enable an activation.

(void)releaseLicence:(NSError**)error

Parameter

Description

(NSError*)error

Returns an NSError object in the event of an error, which contains information about the cause of the error. If this object is not nil, the licence status has not changed. The object contains additional information in the userInfo dictionary. The userInfo dictionary of the NSError object contains an NSNumber under the “LicenceError” key, which represents a value of the LicenceError enum defined with NS_ENUM(NSInteger, LicenceError). The localised error message is available via the localizedDescription property of the NSError object. However, if the NSError object is nil, the method was executed successfully.

Return value

Description

-

-

Usage:

NSError *error = nil;
int ret = [licenceManager releaseLicence:&error];
if (error)
{
    // error handling
} else {
    // license successfully released
}

getLicenceStatus method

This method can be used to query the status information of the licence that is currently used.

(STLicenceStatus*)getLicenceStatus

Parameter

Description

-

-

Return value

Description

STLicenceStatus*

Instance of the -class.

Usage:

STLicenceStatus* licenceStatus = [licenceManager getLicenceStatus];
STLicenceResult* licenceResult = licenceStatus.licenceResult;
if (!licenceResult.isSuccessful)
{
    // demo mode
}

getClientIDs method

This method can be used to query the ID used by the licence service to identify the device. It can be used if automatic activation of the licence is not possible. In this case, the ID together with the invoice number must be sent to lizenz@signotec.de in order to request a licence file.

(NSString*)getClientIDs

Parameter

Description

-

-

Return value

Description

NSString*

ID of the device for identification by the licence service

Usage:

NSString* clientID = [licenceManager getClientIDs];