Handling Requests

The main function of the library is handling requests generated by a request origin on the Privakey CX Authorization server. When a request challenge is sent to the devices on your account, a notification will be sent to all of your devices that are intended to recieve it. You can get the request's details by calling getRequestByGuid() or to get a list of requests call getRequests() with the relevant search filters.

self.privakeyCX.getRequestByGuid(appSpaceGuid: appSpaceGuid, requestGuid: requestGuid) { request, error in
    if error != nil {
        // an error occurred
    } else {
        // start using the request
    }
}
let appSpaceGuid = "your app space GUID"
let status = RequestStatus.PENDING // return only pending requests

self.privakeyCX.getRequestsByStatus(appSpaceGuid: appSpaceGuid, requestStatus: status) { requests, error in
    if error != nil {
        // an error occurred
    } else {
        // start using the requests
    }
}

To select a choice and complete a request challenge, you can call the processRequest() method using a Pin for authorization or the processRequestBiometric() method to use Touch ID/Face ID for authorization.

let appSpaceGuid = "your app space GUID"
let requestGuid = "request-guid"
let password = "the Pin securing the library"
let selectedButtonIndex = 0 // the choice the user selected. 0 = first choice, 1 = second choice, etc...
let responseContent = "any data you would like to be signed"

self.privakeyCX.processRequest(appSpaceGuid: appSpaceGuid, requestGuid: requestGuid, password: password, selectedButtonIndex: selectedButtonIndex, responseContent: responseContent) { success, error in      
    if error == nil {
        // success
    } else {
        // error
    }
}
let appSpaceGuid = "your app space GUID"
let requestGuid = "request-guid"
let biometricAuthReason = "The Touch/Face ID reason for requesting authentication, which displays in the authentication dialog presented to the user"
let selectedButtonIndex = 0 // the choice the user selected. 0 = first choice, 1 = second choice, etc...
let responseContent = "any data you would like to be signed"

self.privakeyCX.processRequestWithBiometric(appSpaceGuid: appSpaceGuid, requestGuid: requestGuid, selectedButtonIndex: selectedButtonIndex, responseContent: responseContent, biometricAuthReason: biometricAuthReason) { success, error in      
    if error == nil {
        // success
    } else {
        // error
    }
}