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.requestExtendPermissions(withDIAC: code,
         onSuccess: {
             // Handle Extend Permissions Success
         }, onNoConnection: {
             // Handle no connection Error
         }, onInvalidToken: { (error) in
             // Handle invalid token error
         }, onInvalidToken: { (error) in
             // Handle invalid token error
         }, onUserNotAccreditedError: { (error) in
             // Handle user not accredited error
         }, onValidationError: { (error) in
             // Handle validation error
         }, onDeviceNotVerified: { (error) in
             // Handle device not verified error
         }, onClientError: { (error) in
             // Handle client error
     })

ObjC

     [biidCoreSDK.getClient requestExtendPermissionsWithDIAC:code
         onSuccess:^{
             // Handle Extend Permissions Success
         }
         onNoConnection:^void() {
             // Handle no connection Error
         }
         onInvalidToken:^void(NSError * _Nonnull error) {
             // Handle invalid token error
         }
         onUserNotAccreditedError:^void(NSError * _Nonnull error) {
             // Handle user not accredited error
         }
         onValidationError:^void(NSError * _Nonnull error) {
             // Handle validation error
         }
         onDeviceNotVerified:^void(NSError * _Nonnull error) {
             // Handle device not verified 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
        }, onInvalidToken: { (error) in
            // Handle invalid token 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
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Documentation

updateUser()

Update the user details for the selected entity

Swift3

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

ObjC

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

Documentation

updateUserPhoneNumber()

Update the user’s phone number for the selected entity

Swift3

   SDK.getClient.updateUserPhoneNumber(withPhoneNumber: telephoneNumber, withDiac: diac,
        onSuccess: {
        // Phone number updated successfully
       }, onNoConnection: {
          // Handle no connection Error
       }, onInvalidToken: { (error) in
          // Handle invalid token error
       }, onValidationError: { (error) in
          // Handle validation 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
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onValidationError:^void(NSError * _Nonnull error) {
            // Handle validation error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Documentation

Authentication Transactions Calls

createAuthenticationTransaction()

Creates an authentication transaction for the currently selected entity

Swift3

    let authenticationTransactionInfo = AuthenticationTransactionInfo()
    authenticationTransactionInfo[AuthenticationTransactionInfo.title] = "Example Auth Transaction"
    authenticationTransactionInfo[AuthenticationTransactionInfo.description] = "Auth transaction example"
    authenticationTransactionInfo[AuthenticationTransactionInfo.latitude] = 51.509865
    authenticationTransactionInfo[AuthenticationTransactionInfo.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
        }, onClientError: { (error) in
            // Handle client error
        }
    )

ObjC

    AuthenticationTransactionInfo *authenticationTransactionInfo = [[AuthenticationTransactionInfo alloc] init];
    authenticationTransactionInfo[AuthenticationTransactionInfo.kTitle] = "Example Auth Transaction";
    authenticationTransactionInfo[AuthenticationTransactionInfo.kDescription] = "Auth transaction example";
    authenticationTransactionInfo[AuthenticationTransactionInfo.kLatitude] =  51.509865;
    authenticationTransactionInfo[AuthenticationTransactionInfo.kLongitude] =  -0.118092;
    authenticationTransactionInfo[@"Additional Info"] = @""Some additional info about this transaction"";

    [biidCoreSDK.getClient createAuthenticationTransactionWithTransactionInfo:authenticationTransactionInfo
         Success:^(AuthenticationTransaction * _Nonnull transaction) {
            // Authentication transaction created successfully
        }
        onNoConnection:^void() {
            // Handle no connection Error
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token 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
       }, 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
       }
       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

     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
         }, onClientError: { (error) in
             // Handle client error
         }
     )

ObjC

     [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
         }
         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

     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
         }, onClientError: { (error) in
             // Handle client error
         }
     )

ObjC


     [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
         }
         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: "18727667", location: location,
         onSuccess: { (checkpoint) in
             // Do something with checkpoint
         }, onNoConnection: {
             // Handle no connection
         }, onInvalidToken: { (error) in
             // Handle invalid token
         }, 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
         }
         onClientError:^void(NSError * _Nonnull error) {
             // Handle client error
         }
     ];

Documentation