Additional Code Samples

Authentication Calls

Re-authenticate()

Re-authenticates the User’s current Entity

Swift

    SDK.getClient.reauthenticate(
        onSuccess: {
            // Handle Success
        }, onNoConnection: {
            // Handle no connection Error
        }, onInvalidToken: { (error) in
            // Handle invalid token Error
        }, onClientError: { (error) in
            // Handle client error
    })

ObjC


    [biidCoreSDK.getClient reauthenticateOnSuccess:^ {
            // Handle Success
        }
        onNoConnection:^void() {
            // Handle no connection Error
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Documentation

Logout

Logs the user out

Swift

    do {
        try SDK.getClient.logout()
    }
    catch (let exception) {
        // Handle logout exception
    }

ObjC

    NSError *error;
    [biidCoreSDK.getClient logout:&error];

Documentation

User Calls

extendPermissions()

Extends Permissions allows a certified user to see their transactions on a secondary device without having to have certified on that device itself.

Swift

     SDK.getClient.extendPermissions(withDIAC: code,
         onSuccess: {
             // Handle Extend Permissions Success
         }, onNoConnection: {
             // Handle no connection Error
         }, onInvalidUserStateError: { (error) in
             // Handle incorrect user state
         }, onInvalidToken: { (error) in
             // Handle invalid token error
         }, onInvalidToken: { (error) in
             // Handle invalid token error
         }, onValidationError: { (error) in
             // Handle validation error
         }, onUserLockedError: { (error) in
             // Handle locked user error
         }, onClientError: { (error) in
             // Handle client error
     })

ObjC

    [biidCoreSDK.getClient extendPermissionsWithDIAC:code
        onSuccess:^{
            // Handle Extend Permissions Success
        }
        onNoConnection:^void() {
            // Handle no connection Error
        }
        onInvalidUserStateError:^void(NSError * _Nonnull error) {
            // Handle incorrect user state
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onValidationError:^void(NSError * _Nonnull error) {
            // Handle validation error
        }
        onUserLockedError:^void(NSError * _Nonnull error) {
            // Handle locked user error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Documentation

Extend Permissions Flow

requestUserDevices()

Requests a list of the current user’s devices and their respective status

Swift

     SDK.getClient.requestUserDevices(
         onSuccess: { (devices) in
             // Do something with returned devices list
         }, onNoConnection: {
             // Handle no connection Error
         }, onInvalidUserStateError: { (error) in
             // Handle incorrect user state
         }, onInvalidToken: { (error) in
             // Handle invalid token error
         }, onUserLockedError: { (error) in
             // Handle locked user error
         }, onClientError:  { (error) in
             // Handle client error
     })

ObjC

    [biidCoreSDK.getClient requestUserDevicesOnSuccess:^(NSArray <Device *>* _Nonnull devices) {
            // Do something with returned devices list
        }
        onNoConnection:^void() {
            // Handle no connection Error
        }
        onInvalidUserStateError:^void(NSError * _Nonnull error) {
            // Handle incorrect user state
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onUserLockedError:^void(NSError * _Nonnull error) {
            // Handle locked user error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Documentation

updateUser()

Update the user details for the selected entity

Swift4

     SDK.getClient.updateUser(withUser: user,
         onSuccess: {
             // User successfully updated
         }, onNoConnection: {
             // Handle no connection Error
         }, onInvalidUserStateError: { (error) in
             // Handle incorrect user state
         }, onInvalidToken: { (error) in
             // Handle invalid token error
         }, onValidationError: { (error) in
             // Handle validation error
         }, onUserLockedError: { (error) in
             // Handle locked user error
         }, onClientError: { (error) in
             // Handle client error
     })

ObjC

     [biidCoreSDK.getClient updateUser:(User * _Nonnull)user
         onSuccess:^{
             // User successfully updated
         }
         onNoConnection:^void() {
             // Handle no connection Error
         }
         onInvalidUserStateError:^void(NSError * _Nonnull error) {
             // Handle incorrect user state
         }
         onInvalidToken:^void(NSError * _Nonnull error) {
             // Handle invalid token error
         }
         onValidationError:^void(NSError * _Nonnull error) {
             // Handle validation error
         }
         onUserLockedError:^void(NSError * _Nonnull error) {
             // Handle locked user error
         }
         onClientError:^void(NSError * _Nonnull error) {
             // Handle client error
         }
     ];

Documentation

updateUserPhoneNumber()

Update the user’s phone number for the selected entity

Swift4

     SDK.getClient.updateUserPhoneNumber(withPhoneNumber: telephoneNumber, withDIAC: diac,
         onSuccess: {
             // Phone number updated successfully
         }, onNoConnection: {
             // Handle no connection Error
         }, onInvalidUserStateError: { (error) in
             // Handle incorrect user state
         }, onInvalidToken: { (error) in
             // Handle invalid token error
         }, onValidationError: { (error) in
             // Handle validation error
         }, onUserLockedError: { (error) in
             // Handle locked user error
         }, onClientError: { (error) in
             // Handle client error
     })

ObjC

     [biidCoreSDK.getClient updateUserPhoneNumber:telephoneNumber
                                 withDIAC:diac
         onSuccess:^{
             // Phone number updated successfully
         }
         onNoConnection:^void() {
             // Handle no connection Error
         }
         onInvalidUserStateError:^void(NSError * _Nonnull error) {
             // Handle incorrect user state
         }
         onInvalidToken:^void(NSError * _Nonnull error) {
             // Handle invalid token error
         }
         onValidationError:^void(NSError * _Nonnull error) {
             // Handle validation error
         }
         onUserLockedError:^void(NSError * _Nonnull error) {
             // Handle locked user error
         }
         onClientError:^void(NSError * _Nonnull error) {
             // Handle client error
         }
     ];

Documentation

Authentication Transactions Calls

createAuthenticationTransaction()

Creates an authentication transaction for the currently selected entity

Swift4

    let authenticationTransactionInfo = AuthenticationTransactionInfo()
    authenticationTransactionInfo[AuthenticationTransactionInfo.title] = "Example Auth Transaction"
    authenticationTransactionInfo[AuthenticationTransactionInfo.description] = "Auth transaction example"
    authenticationTransactionInfo[TransactionInfo.location] = Location(latitude: 51.509865, longitude: -0.118092)
    authenticationTransactionInfo["Additional Info"] = "Some additional info about this transaction"

    SDK.getClient.createAuthenticationTransaction(withTransactionInfo: authenticationTransactionInfo,
        onSuccess: { (transaction) in
            // Authentication transaction created successfully
        }, onNoConnection: {
            // Handle no connection Error
        }, onInvalidToken: { (error) in
            // Handle invalid token error
        }, onUserLockedError: { (error) in
            // Handle locked user error
        }, onClientError: { (error) in
            // Handle client error
        }
    )

ObjC

    AuthenticationTransactionInfo *authenticationTransactionInfo = [[AuthenticationTransactionInfo alloc] init];
    authenticationTransactionInfo[BIIDCRTransactionInfo.kTitle] = "Example Auth Transaction";
    authenticationTransactionInfo[BIIDCRTransactionInfo.kDescription] = "Auth transaction example";
    authenticationTransactionInfo[BIIDCRTransactionInfo.kLocation] =  [[BIIDCRLocation alloc] initWithLatitude: 51.509865 longitude:-0.118092];
    authenticationTransactionInfo[@"Additional Info"] = @""Some additional info about this transaction"";

    [biidCoreSDK.getClient createAuthenticationTransactionWithTransactionInfo:authenticationTransactionInfo
         onSuccess:^(AuthenticationTransaction * _Nonnull authenticationTransaction) {
                // Authentication transaction created successfully
         }
         onNoConnection:^void() {
             // Handle no connection Error
         }
         onInvalidToken:^void(NSError * _Nonnull error) {
             // Handle invalid token error
         }
         onUserLockedError:^void(NSError * _Nonnull error) {
             // Handle locked user error
         }
         onClientError:^void(NSError * _Nonnull error) {
             // Handle client error
         }
     ];

Documentation

Document Management Calls

downloadPublicDocument()

Download a publicly accessible document (hosted on the biid platform).

Swift

     SDK.getClient.downloadPublicDocument(named: document,
         onSuccess: { (url) in
             // Do something with the downloaded document content
         }, onNoConnection: {
             // Handle no connection Error
         }, onInvalidUserStateError: { (error) in
             // Handle incorrect user state
         }, onInvalidToken: { (error) in
             // Handle invalid token error
         }, onClientError: { (error) in
             // Handle client error
     })

ObjC

     [biidCoreSDK.getClient downloadPublicDocumentNamed:document
         onSuccess:^(NSURL * _Nonnull url) {
             // Do something with the downloaded document content
         }
         onNoConnection:^void() {
             // Handle no connection Error
         }
         onInvalidUserStateError:^void(NSError * _Nonnull error) {
             // Handle incorrect user state
         }
         onInvalidToken:^void(NSError * _Nonnull error) {
             // Handle invalid token error
         }
         onClientError:^void(NSError * _Nonnull error) {
             // Handle client error
         }
     ];

Documentation

Note:

It is also possible to download/display a documents content via it’s publicURL property.

For example to display a document in a WKWebView, the following code could be used:

    let url = URL(string: theDocument.publicURL)
    let request = URLRequest(url: url!)
    webView.load(request)

Checkpoints Calls

requestCheckpoints()

Returns a list of Checkpoints for the current entity. If a location is specified, only checkpoints near (within 30 km) to the location are returned.

Swift


      CLLocation location = CLLocation(latitude: 51.4772098, longitude: 0.0158556)

     SDK.getClient.requestCheckpoints(max: nil, offset: nil, location: location, sortOrder: .ascending
         onSuccess: { (checkpoints) in
             // Do something with checkpoints
         }, onNoConnection: {
             // Handle no connection
         }, onInvalidToken: { (error) in
             // Handle invalid token
         }, onUserLockedError: { (error) in
             // Handle locked user error
         }, onClientError: { (error) in
             // Handle client error
         }
     )

ObjC


     CLLocation *location = [[CLLocation alloc] initWithLatitude:51.4772098 longitude:0.0158556];

    [biidCoreSDK.getClient requestCheckpointsWithMax:100
                                      offset:0
                                      location:location
                                      sortOrder:CheckpointsSortOrderAscending
    onSuccess:^(NSArray<Checkpoint *> * _Nonnull checkpoints) {
            // Do something with checkpoints
        onNoConnection:^void() {
            // Handle no connection Error
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onUserLockedError:^void(NSError * _Nonnull error) {
            // Handle locked user error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Documentation

requestNearestCheckpoints()

Returns a list of Checkpoints (for the current entity) nearest to the specified location and sorted nearest to furthest.

Swift


      CLLocation location = CLLocation(latitude: 51.4772098, longitude: 0.0158556)

     SDK.getClient.requestNearestCheckpoints(max: nil, offset: nil, location: location
         onSuccess: { (checkpoints) in
             // Do something with checkpoints
         }, onNoConnection: {
             // Handle no connection
         }, onInvalidToken: { (error) in
             // Handle invalid token
         }, onUserLockedError: { (error) in
             // Handle locked user error
         }, onClientError: { (error) in
             // Handle client error
         }
     )

ObjC


     CLLocation *location = [[CLLocation alloc] initWithLatitude:51.4772098 longitude:0.0158556];

    [biidCoreSDK.getClient requestNearestCheckpointsWithMax:100
                                             offset:0
                                           location:location
    onSuccess:^(NSArray<Checkpoint *> * _Nonnull checkpoints) {
            // Do something with checkpoints
        onNoConnection:^void() {
            // Handle no connection Error
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onUserLockedError:^void(NSError * _Nonnull error) {
            // Handle locked user error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Documentation

requestCheckpointDetails()

Requests checkpoint details for a checkpoint ID.

NB Pass in an optional location if you want the calculated distance between this location and the checkpoint to be returned in the results :

Swift

     SDK.getClient.requestCheckpointDetails(checkpointID: "12345667", location: location,
         onSuccess: { (checkpoint) in
             // Do something with checkpoint
         }, onNoConnection: {
             // Handle no connection
         }, onInvalidToken: { (error) in
             // Handle invalid token
         }, onUserLockedError: { (error) in
             // Handle locked user error
         }, onClientError: { (error) in
             // Handle client error
         }
     )

ObjC


     [biidCoreSDK.getClient requestCheckpointDetailsWithCheckpointID:12345667
                                             location:location
     onSuccess:^(CheckpointDetails * _Nonnull checkpointDetails) {
             // Do something with checkpoint details
         onNoConnection:^void() {
             // Handle no connection Error
         }
         onInvalidToken:^void(NSError * _Nonnull error) {
             // Handle invalid token error
         }
         onUserLockedError:^void(NSError * _Nonnull error) {
             // Handle locked user error
         }
         onClientError:^void(NSError * _Nonnull error) {
             // Handle client error
         }
     ];

Documentation