LogoSignature Service
SmartContract SDKiOS SDK

Getting started

The examples below use the public SmartContract iOS SDK APIs. Complete Installation and configuration before initializing the SDK.

Initialize the SDK

The following code belongs in an application method that starts the signing flow:

@import SENSESmartContract;

Configuration *configuration = [SSCConfiguration sharedManager].configuration;
NSString *endpoint = configuration.secServerUrl;
if (endpoint.length == 0) {
    // Report a missing endpoint in the application's configuration.
    return;
}
NSURL *serverURL = [NSURL URLWithString:endpoint];
if (serverURL.scheme.length == 0 || serverURL.host.length == 0) {
    // Report a missing or invalid endpoint in the application's configuration.
    return;
}

SSCInitializer *initializer = [SSCInitializer instance];
initializer.senseServerURL = serverURL;
[initializer verifyServerReachabilityCompletion:^(NSError *error) {
    if (error != nil) {
        // Present the connection error and allow the user to retry.
        return;
    }
    // Open the user's session here, using the flow below.
}];

Open a session

For an integration using an enrollment code, the first session requires the username, password and enrollment code. Subsequent sessions use the same user's password. Obtain these values through the application's enrollment and authentication flow.

Check whether the requested username is enrolled. A different enrolled user on the same device does not mean that this user is enrolled.

// username, password and activationCode come from the application's flow.
NSArray<NSString *> *enrolledUsers = [SSCSessionService alreadyEnrolledUsers];
SSCErrorBlock completion = ^(NSError *error) {
    if (error != nil) {
        // Present the enrollment or authentication error.
        return;
    }
    // The session is ready. Contract and configuration APIs can now be used.
};

if (![enrolledUsers containsObject:username]) {
    SSCEnrollmentInfo *info = [SSCEnrollmentInfo new];
    info.username = username;
    info.password = password;
    info.code = activationCode;
    [SSCSessionService enrollApplicationWithInfo:info errorBlock:completion];
} else {
    [SSCSessionService createApplicationSessionWithUsername:username
                                                  password:password
                                                errorBlock:completion];
}

For OIDC enrollment, the public API also provides enrollApplicationWithInfoAndToken:errorBlock:. RSS integrations should use their Session Service, which handles OIDC enrollment through the RSS wrapper.

Session notifications

Register an observer for SSC_SESSION_TIMEOUT_NOTIFICATION before opening a session. When it fires, stop operations that depend on the session and reopen it through the application's authentication flow. Remove the observer when its owner is released.

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(sessionTimeOut:)
                                             name:SSC_SESSION_TIMEOUT_NOTIFICATION
                                           object:nil];

Implement sessionTimeOut: in the observer. UI updates must run on the main thread.

For applications distributed outside the App Store, SSC_UPDATE_AVAILABLE_NOTIFICATION can provide an update URL in notification.object[@"uri"]. Register its observer before opening the session and validate the supplied URL against your application's update policy before opening it. App Store updates are managed through the App Store.

Close a session

Call [SSCSessionService logOut] when the current signing session is no longer needed. This closes the active session without removing the user's enrollment. Open another session before making further authenticated requests.

Use the SmartContract service

After session establishment succeeds, use SSCSmartContractService. The following operations are separate steps: retrieve contracts, retrieve the selected contract's payload, and send the response prepared by the application.

[[SSCSmartContractService new] getPendingContractsCompletion:
    ^(NSArray<SSCContract *> *contracts, NSError *error) {
        if (error != nil) {
            // Handle the request error.
            return;
        }
        // Let the user select a contract from contracts.
    }];
// contract is the selected SSCContract.
[[SSCSmartContractService new] getPayloadForContract:contract
                                            error:^(NSError *error) {
    if (error != nil) {
        // Handle the payload error.
        return;
    }
    // The selected contract now contains its payload.
}];
// sendingResponse is the SSCContractSending prepared for the workflow.
[[SSCSmartContractService new] sendResponse:sendingResponse
                               completion:^(SSCContractResponse *response, NSError *error) {
    if (error != nil) {
        // Handle the response error.
        return;
    }
    // The response was accepted by the service.
}];

On this page