---
agentTools:
  projectIndex: https://docs.privakey.com/llms.txt
---

# API Reference

[block:api-header]
{
  "title": "PrivakeyCX"
}
[/block]

```swift
public class PrivakeyCX : NSObject
```

Swift API library for interacting with the PrivakeyCX server.

## Summary

Here is a list of all public methods with a quick description. Further down the page, they are all listed in more detail with any relevant examples. Click on any method to go to its detailed description.

**Note**: Many of the methods utilize completion handlers to return their results, due to their asynchronous nature. For more info on this, see the [Swift documentation on Closures](https://docs.swift.org/swift-book/LanguageGuide/Closures.html).

[block:parameters]
{
  "data": {
    "h-0": "Public Constructors",
    "0-0": "`init()`\n\nInitializes Privakey with the default CX API, CoreData data service, Apple’s Local Authentication Context for biometry, and the default Pin Entry Manager.",
    "1-0": "`init(apiService: APIService, dataService: DataManager, localAuthenticationService: LocalAuthenticationManager, pinEntriesService: PinEntriesManager)`\n\nInitializes Privakey with the given custom services to facilitate testing and customization using dependency injection."
  },
  "cols": 1,
  "rows": 2
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Public Properties",
    "0-0": "delegate?",
    "1-0": "uiDelegate?",
    "0-1": "A PrivakeyCXDelegate for handling various asynchronous actions.",
    "1-1": "A PinEntriesManagerUIDelegate for handling Pin attempts left in the UI."
  },
  "cols": 2,
  "rows": 2
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Public Methods",
    "1-0": "[enablePrivakey](#enableprivakey)`( password: String, notificationId: String, notificationFramework: String, deviceName: String, sessionToken: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )`\nUse this method to register an account and tokenize the device after performing a simple bind.",
    "1-1": "",
    "6-0": "[enableBiometric](#enablebiometric)`( password: String, bioPromptText: String?, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )`\nEnables the use of biometric for processing requests. E.G. Touch ID or Face ID.",
    "6-1": "",
    "7-0": "[isBound](#isbound)`( completion: @escaping ( _ isBound: Bool, _ error: Error? ) -> Void )`\nDetermines if this device is currently bound to any App Spaces.",
    "7-1": "",
    "9-0": "[changePassword](#changepassword)`( oldPassword: String, newPassword: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )`\nChanges the PIN/Password used for processing strong auth requests.",
    "9-1": "",
    "11-0": "[disablePrivakeyCX](#disableprivakeycx)`( completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )`\nRemoves the Privakey Account from the device and notifies the CX server that the device is no longer Privakey enabled.",
    "11-1": "",
    "13-0": "[getDevices](#getdevices)`( status: DeviceStatus, completion: @escaping ( _ devices: [PrivakeyDevice]?, _ error: Error? ) -> Void )`\nReturns an Array of Devices matching the requested DeviceStatus.",
    "13-1": "",
    "14-0": "[getCurrentDevice](#getcurrentdevice)`( completion: @escaping ( _ device: PrivakeyDevice?, _ error: Error? ) -> Void )`\nGets the current device data from the local cache.",
    "14-1": "",
    "15-0": "[getDevice](#getdevice)`( deviceGuid: String, completion: @escaping ( _ device: PrivakeyDevice?, _ account: PrivakeyAccount?, _ error: Error? ) -> Void )`\nGets the device data for the requested device. The device must be owned by the same Privakey account making the request.",
    "15-1": "",
    "16-0": "[updateDevice](#updatedevice)`( name: String, notificationFramework: String, notificationId: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )`\nUpdates some of the device data on the CX server. This method has to be called when the notification Id changes to continue to receive push notifications.",
    "16-1": "",
    "17-0": "[getRequestByGuid](#getrequestbyguid)`( appSpaceGuid: String, requestGuid: String, completion: @escaping ( _ request: PrivakeyRequest?, _ error: Error? ) -> Void )`\nReturns the Request data for the specified request. The request must be bound to the Privakey account making the call.",
    "17-1": "",
    "19-0": "[getRequests](#getrequests)`( appSpaceGuid: String, requestStatus: RequestStatus?, beginDate: Date?, endDate: Date?, limit: Int?, completion: @escaping ( _ requests: [PKRequest]?, _ error: Error? ) -> Void )`\nA generic Request search. Returns an Array of requests based on the parameters supplied.",
    "19-1": "",
    "20-0": "[processRequest](#processrequest)`( appSpaceGuid: String, requestGuid: String, password: String?, selectedButtonIndex: Int, responseContent: String?, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )`\nProcesses a request using the account PIN/Password. `password` is only required if this is a strong auth request.",
    "20-1": "",
    "21-0": "[processRequestBiometric](#processrequestbiometric)`( appSpaceGuid: String, requestGuid: String, selectedButtonIndex: Int, responseContent: String?, biometricAuthReason: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )`\nProcesses a request using the account registered Biometric.",
    "21-1": "",
    "22-0": "[requestNotificationActedOn](#requestnotificationactedon)`( notificationUserInfo: [AnyHashable: Any] )`\nUploads telemetry data for the event a request notification is clicked.",
    "22-1": "",
    "23-0": "[requestViewStart](#requestviewstart)`( request: PrivakeyRequest )`\nInitiates the process of uploading a request viewed telemetry event.",
    "23-1": "",
    "10-0": "[validatePassword](#validatepassword)`( password: String )`\nValidates an entered PIN/Password.",
    "10-1": "",
    "24-0": "[requestViewEnd](#requestviewend)`( request: PrivakeyRequest )`\nCompletes the process of uploading a request viewed telemetry event.",
    "24-1": "",
    "26-0": "[checkStatus](#checkstatus)`( completion: @escaping ( _ didRevokeDevice: Bool, _ didSuspendAccount: Bool ) -> Void )`\nChecks if the current device or associated account status has changed and handles it appropriately.",
    "25-0": "[handlePrivakeyNotification](#handleprivakeynotification)`( notificationUserInfo: [AnyHashable : Any], completion: @escaping ( _ didRevokeDevice: Bool ) -> Void )`\nForward any received Privakey push notifications so they can be processed.",
    "25-1": "",
    "26-1": "",
    "0-0": "[getVersion](#getversion)`() -> String`\nGet the version of the library.",
    "4-0": "[isBiometricSensorAvailable](#isbiometricsensoravailable)`( completion: @escaping ( _ isAvailable: Bool, _ message: String ) -> Void )`\nQueries the system to see if a biometric sensor is available and ready for use.",
    "5-0": "[isBiometricEnabled](#isbiometricenabled)`( completion: @escaping ( _ success: Bool, _ error: Error? ) -> Void )`\nQueries the system to see if the user has explicitly enabled biometric authentication.",
    "18-0": "[getRequestsByStatus](#getrequestsbystatus)`( appSpaceGuid: String, requestStatus: RequestStatus, completion: @escaping ( _ requests: [PrivakeyRequest]?, _ error: Error? ) -> Void )`\nGet all requests of a certain status that belong to this account. This method is shorthand for the other method, `getRequests()`.",
    "2-0": "[addAppSpaceCredential](#addappspacecredential)`( password: String, appSpaceGuid: String, sessionToken: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )`\nAdds a new AppSpace credential to an existing Privakey account using PIN. This is very rarely used.",
    "3-0": "[addAppSpaceCredentialBiometric](#addappspacecredentialbiometric)`( appSpaceGuid: String, sessionToken: String, bioPromptText: String?, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )\nAdds a new AppSpace credential to an existing Privakey account using biometrics. This is very rarely used.",
    "8-0": "[disableBiometric](#disablebiometric)`( completion: @escaping ( _ success: Bool?,  _ error: Error? ) -> Void )`\nDisables the use of biometrics for processing requests.",
    "12-0": "[revokeDevice](#revokedevice)`( appSpaceGuid: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )`\nRemoves the device from the Privakey Account. This device will no longer be able to process requests until it is registered to the Privakey account again."
  },
  "cols": 1,
  "rows": 27
}
[/block]

## Public Constructors

### init

```swift
public convenience override init ()
```

Initializes Privakey with the default CX API, CoreData data service, Apple’s Local Authentication Context for biometry, and the default Pin Entry Manager.

```swift
public init ( apiService: APIService, dataService: DataManager, localAuthenticationService: LocalAuthenticationManager, pinEntriesService: PinEntriesManager )
```

Initializes Privakey with the given custom services to facilitate testing and customization using dependency injection.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**apiService**",
    "1-0": "**dataService**",
    "2-0": "**localAuthenticationService**",
    "3-0": "**pinEntriesService**",
    "0-1": "The service to connect to the CX API. Default is PrivakeyCXAPIService().",
    "1-1": "The data service for Privakey to persist data. Default is CoreDataStack().",
    "2-1": "The Authentication Manager for handling biometrics. Default is LocalAuthenticationManager().",
    "3-1": "The manager for handling invalid pin attempts. Default is PinEntriesManager()."
  },
  "cols": 2,
  "rows": 4
}
[/block]

## Public Properties

### delegate

```swift
public weak var delegate : PrivakeyCXDelegate?
```

Assign a PrivakeyCXDelegate to this property to handle certain asynchronous events. For more info, see the [Delegates](https://docs.privakey.com/docs/delegates) page.

### uiDelegate

```swift
public weak var uiDelegate: PinEntriesManagerUIDelegate?
```

Assign a delegate to this property to update the UI for failed PIN entry events. We recommend updating your view to let the user know how many PIN entry attempts they have remaining, and adding an additional warning if they only have 1 attempt remaining, as they will be revoked if they fail at that point.

## Public Methods

### getVersion

```swift
public func getVersion () -> String
```

Returns the current version of the library, in the form X.Y.Z

<br/>

### enablePrivakey

```swift
public func enablePrivakey ( password: String, notificationId: String, notificationFramework: String, deviceName: String, appSpaceGuid: String, sessionToken: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )
```

Enable Privakey for an account. Keys are generated for use with Privakey, binding this device to the user's Privakey account.

A user should authenticate with your server, your server will then contact the CX Server to create or retrieve a Privakey account. The CX Server will return a `privakeyId` and a `sessionToken`. This call will generate the required Keypairs and register the device with the CX Server. After the device is enrolled and the account has been created the device will be able to process requests.

[block:parameters]
{
  "data": {
    "0-0": "**password**",
    "0-1": "The PIN/Password used to secure the private key for making strong authorizations.",
    "1-0": "**notificationId**",
    "1-1": "The device notification Id. The ID that is used for the device to receive remote push notifications.",
    "2-0": "**notificationFramework**",
    "2-1": "The framework being used to receive push notifications. This value should match the key used by the CX Comm server for choosing which framework to send notifications. eg. Firebase, APNS, etc.",
    "3-0": "**deviceName**",
    "3-1": "Friendly human readable device identifier or nickname.",
    "5-0": "**sessionToken**",
    "5-1": "A token used by the server to confirm the device being tokenized is the same device that authenticated with your server. This value should be passed back to the device after a successful authentication with your server.",
    "6-0": "**completion**",
    "6-1": "Completion handler with these params:\n***success*** - True if successful.\n***error*** - nil if successful, otherwise an error object.",
    "h-0": "Parameters",
    "4-0": "**appSpaceGuid**",
    "4-1": "Identifier of the App Space being bound to this device."
  },
  "cols": 2,
  "rows": 7
}
[/block]

<br/>

### addAppSpaceCredential

```swift
public func addAppSpaceCredential ( password: String, appSpaceGuid: String, sessionToken: String, completion: @escaping ( _ success: Bool?, _ error: Error?) -> Void )
```

Add an additional credential for a new AppSpace. For your first AppSpace, you should call `enablePrivakey()` instead of this.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**password**",
    "0-1": "The PIN/Password used to secure the private key for making strong authorizations.",
    "1-0": "**appSpaceGuid**",
    "1-1": "GUID of the new App Space being added",
    "2-0": "**sessionToken**",
    "2-1": "A token used by the server to confirm the device being tokenized is the same device that authenticated with your server. This value should be passed back to the device after a successful authentication with your server.",
    "3-0": "**completion**",
    "3-1": "Completion handler with these params:\n***success***: True if successful.\n***error***: nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 4
}
[/block]

<br/>

### addAppSpaceCredentialBiometric

```swift
public func addAppSpaceCredentialBiometric ( appSpaceGuid: String, sessionToken: String, bioPromptText: String?, completion: @escaping ( _ success: Bool?, _ error: Error?) -> Void )
```

Add an additional credential for a new AppSpace. This function uses the user's biometrics instead of a PIN/password. For your first AppSpace, you should call `enablePrivakey()`.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**appSpaceGuid**",
    "1-0": "**sessionToken**",
    "2-0": "**bioPromptText**",
    "3-0": "**completion**",
    "3-1": "Completion handler with these params:\n***success***: True if successful.\n***error***: nil if successful, otherwise an error object.",
    "0-1": "GUID of the new App Space being added",
    "1-1": "A token used by the server to confirm the device being tokenized is the same device that authenticated with your server. This value should be passed back to the device after a successful authentication with your server.",
    "2-1": "Text to present the user as the reason for capturing their biometrics. Defaults to \"Privakey will use <Touch ID/Face ID> during approvals that require a strong assertion of your intent.\""
  },
  "cols": 2,
  "rows": 4
}
[/block]

<br/>

### isBiometricSensorAvailable

```swift
public func isBiometricSensorAvailable ( completion: @escaping ( _ isAvailable: Bool, _ message: String ) -> Void )
```

Queries the system to see if a biometric sensor is available and ready for use.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**completion**",
    "0-1": "Completion handler with these params:\n***isAvailable***: True if a sensor is available.\n***message***: \"Biometrics Available\" if a sensor is available, otherwise an error message."
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### isBiometricEnabled

```swift
public func isBiometricEnabled ( completion: @escaping ( _ success: Bool, _ error: Error? ) -> Void )
```

Queries the system to see if a user has explicitly enabled biometric authentication for the implementing app.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**completion**",
    "0-1": "Completion handler with these params:\n***success***: True if successful.\n***error***: nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### enableBiometric

```swift
public func enableBiometric ( password: String, bioPromptText: String?, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )
```

Enables PrivakeyCX to accept biometrics for authentications. E.G. Touch ID or Face ID.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**password**",
    "2-0": "**completion**",
    "0-1": "The PIN/Password used to secure the private key for making strong authorizations.",
    "2-1": "Completion handler with these params:\n***success*** - True if successful.\n***error*** - nil if successful, otherwise an error object.",
    "1-0": "**bioPromptText**",
    "1-1": "Text to present the user as the reason for capturing their biometrics. Defaults to \"Privakey will use <Touch ID/Face ID> during approvals that require a strong assertion of your intent.\""
  },
  "cols": 2,
  "rows": 3
}
[/block]

<br/>

### isBound

```swift
public func isBound ( completion: @escaping ( _ isBound: Bool, _ error: Error? ) -> Void )
```

Determines if this device is currently bound to any App Spaces. Useful for E.G. checking during the launch of your app if it's a new user or existing one.

[block:parameters]
{
  "data": {
    "0-0": "**completion**",
    "h-0": "Parameters",
    "0-1": "Completion handler with these params:\n***isBound*** - Whether user is bound or not.\n***error*** - nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### disableBiometric

```swift
public func disableBiometric ( completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )
```

Disabled PrivakeyCX support for biometrics (Touch ID/Face ID). Only a PIN/password will be allowed to authorize requests.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**completion**",
    "0-1": "Completion handler with these params:\n***success*** - True if successful.\n***error*** - nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### changePassword

```swift
public func changePassword ( oldPassword: String, newPassword: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )
```

Allows a user to change their PIN/password.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "2-0": "**completion**",
    "0-0": "**oldPassword**",
    "1-0": "**newPassword**",
    "0-1": "The current password used to process strong authorization requests.",
    "1-1": "The password to replace the `oldPassword`.",
    "2-1": "Completion handler with these params:\n***success*** - True if successful.\n***error*** - nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 3
}
[/block]

<br/>

### validatePassword

```swift
public func validatePassword ( password: String ) -> Bool
```

Validates an entered PIN/Password. Invalid PIN attempts are protected by the Pin Entries Manager which disables the device after the max attempts have been used.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**password**",
    "0-1": "The password to validate."
  },
  "cols": 2,
  "rows": 1
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Returns",
    "0-0": "Bool",
    "0-1": "True if the password was correct."
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### disablePrivakeyCX

```swift
public func disablePrivakeyCX ( completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )
```

Deletes all the PrivakeyCX data and notifies the server that PrivakeyCX has been disabled for this device.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**completion**",
    "0-1": "Completion handler with these params:\n***success*** - True if successful.\n***error*** - nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### revokeDevice

```swift
public func revokeDevice ( appSpaceGuid: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )
```

Disables and deletes keys used for authorizing requests from the given App Space. To authorize requests related to that App Space again, the device will have to be re-added via the binding process.

[block:parameters]
{
  "data": {
    "0-0": "**appSpaceGuid**",
    "0-1": "Identifier of the App Space credentials to remove.",
    "1-0": "**completion**",
    "1-1": "Completion handler with these params:\n***success*** - True if successful.\n***error*** - nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 2
}
[/block]

<br/>

### getDevices

```swift
public func getDevices ( status: DeviceStatus, completion: @escaping (_ devices: [PrivakeyDevice]?, _ error: Error? ) -> Void )
```

A device search method. Use this method to return select devices based on their status, that are bound to the Privakey account.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**status**",
    "0-1": "The status of devices that are to be returned.",
    "1-0": "**completion**",
    "1-1": "Completion handler with these params:\n***devices*** - The fetched devices.\n***error*** - nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 2
}
[/block]

<br/>

### getCurrentDevice

```swift
public func getCurrentDevice ( completion: @escaping ( _ device: PrivakeyDevice?, _ error: Error? ) -> Void )
```

Gets the locally cached device information.

[block:parameters]
{
  "data": {
    "0-0": "**completion**",
    "0-1": "Completion handler with these params:\n***device*** - The current device.\n***error*** - nil if successful, otherwise an error object.",
    "h-0": "Parameters"
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### getDevice

```swift
public func getDevice ( deviceGuid: String, completion: @escaping ( _ device: PrivakeyDevice?, _ account: PrivakeyAccount?, _ error: Error? ) -> Void )
```

Gets information for a specific device. The specified device must belong to the same account as the calling device.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**deviceGuid**",
    "0-1": "The device identifier of the device whose data is  being requested.",
    "1-0": "**completion**",
    "1-1": "Completion handler with these params:\n***device*** - The fetched device.\n***account*** - The account that the device is associated to.\n***error*** - nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 2
}
[/block]

<br/>

### updateDevice

```swift
public func updateDevice ( name: String, notificationFramework: String, notificationId: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )
```

Updates some of the device specific information. You are required to call this method when your app’s notification token or ID changes to continue receiving notifications from the CX Server.

[block:callout]
{
  "type": "info",
  "title": "Push Notifications",
  "body": "Use `updateDevice()` to update the `NotificationId` on the CX server. The notificationId must always be current to continue receiving push notifications from the CX Server."
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "1-1": "The framework being used to receive push notifications. This value should match the key used by the CX Comm server for choosing which framework to send notifications. eg. Firebase, APNS, etc.",
    "1-0": "**notificationFramework**",
    "2-0": "**notificationId**",
    "2-1": "The device notification Id. The ID that is used for the device to receive push notifications.",
    "3-0": "**completion**",
    "3-1": "Completion handler with these params:\n***success*** - True if successful.\n***error*** - nil if successful, otherwise an error object.",
    "0-0": "**name**",
    "0-1": "Friendly human readable device identifier."
  },
  "cols": 2,
  "rows": 4
}
[/block]

<br/>

### getRequestByGuid

```swift
public func getRequestByGuid ( appSpaceGuid: String, requestGuid: String, completion: @escaping ( _ request: PrivakeyRequest?, _ error: Error? ) -> Void )
```

Gets a single request based on its identifier.

If the request exists in local cache, the cached item will be returned via `completion`. At the same time, a call will be made to the CX Server to get the latest data for the request. When this call returns, the data will be sent through `PrivakeyCXDelegate.onGetRequestsResult()`. See the [Delegates](https://docs.privakey.com/docs/delegates) page for more info.

If the request **does not** exist in local cache, the call to the CX Server is made and its data is returned through `completion`.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "2-0": "**completion**",
    "1-0": "**requestGuid**",
    "1-1": "The request identifier of the request that you are fetching the details for.",
    "2-1": "Completion handler with these params:\n***request*** - The matching request.\n***error*** - nil if successful, otherwise an error object.",
    "0-0": "**appSpaceGuid**",
    "0-1": "Identifier of the App Space the request belongs to."
  },
  "cols": 2,
  "rows": 3
}
[/block]

<br/>

### getRequestsByStatus

```swift
public func getRequestsByStatus ( appSpaceGuid: String, requestStatus: RequestStatus, completion: @escaping ( _ requests: [PKRequest]?, _ error: Error? ) -> Void )
```

Get all requests of a certain status for a particular App Space. This method is a shorthand for the other method, `getRequests()`.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "1-0": "**requestStatus**",
    "2-0": "**completion**",
    "1-1": "Status of requests to fetch.",
    "2-1": "Completion handler with these params:\n***requests*** - The matching requests.\n***error*** - nil if successful, otherwise an error object.",
    "0-0": "**appSpaceGuid**",
    "0-1": "Identifier of the App Space to get requests for."
  },
  "cols": 2,
  "rows": 3
}
[/block]

<br/>

### getRequests

```swift
public func getRequests ( appSpaceGuid: String, requestStatus: RequestStatus?, beginDate: Date?, endDate: Date?, limit: Int?, completion: @escaping ( _ requests: [PKRequest]?, _ error: Error? ) -> Void )
```

Request search method. This will return all the requests that meet the specified conditions.

[block:parameters]
{
  "data": {
    "0-0": "**appSpaceGuid**",
    "0-1": "Identifier of the App Space to get requests for.",
    "1-0": "**requestStatus**",
    "1-1": "Status of requests to fetch.",
    "2-0": "**beginDate**",
    "2-1": "The beginning of the date range. Returns requests that were created after and including this date.",
    "3-0": "**endDate**",
    "3-1": "The end of the date range. Returns requests that were created before and including this date.",
    "4-0": "**limit**",
    "4-1": "The max number of requests to return. If this is less than 1, it will be automatically set to 50.",
    "h-0": "Parameters",
    "5-0": "**completion**",
    "5-1": "Completion handler with these params:\n***requests*** - The matching requests.\n***error*** - nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 6
}
[/block]

<br/>

### processRequest

```swift
public func processRequest ( appSpaceGuid: String, requestGuid: String, password: String?, selectedButtonIndex: Int, responseContent: String?, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )
```

Processes the given request. This tells the Privakey CX server that you have confirmed an action on the request.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**appSpaceGuid**",
    "0-1": "Identifier of the App Space the request belongs to.",
    "1-0": "**requestGuid**",
    "1-1": "Identifier of the Request to process.",
    "2-0": "**password**",
    "2-1": "The password used to unlock the Privakey account's Authorization Key, used for approving requests that require strong authentication. Can be null for requests that do not require strong authentication.",
    "3-0": "**selectedButtonIndex**",
    "3-1": "The JSON index of the button object that was selected by the user. This is used to determine the authorization level the request requires to be processed. It can be used to confirm the action the user selected.",
    "4-0": "**responseContent**",
    "4-1": "This field is used to record any data as a result of user interaction that should be signed with the request. EG. user inputted form data, typed text input.",
    "5-0": "**completion**",
    "5-1": "Completion handler with these params:\n***success*** - True if successful.\n***error*** - nil if successful, otherwise an error object."
  },
  "cols": 2,
  "rows": 6
}
[/block]

<br/>

### processRequestBiometric

```swift
public func processRequestBiometric ( appSpaceGuid: String, requestGuid: String, selectedButtonIndex: Int, responseContent: String?, biometricAuthReason: String, completion: @escaping ( _ success: Bool?, _ error: Error? ) -> Void )
```

Processes the given request using a biometric. This tells the Privakey CX server that you have confirmed an action on the request.

[block:parameters]
{
  "data": {
    "0-0": "**appSpaceGuid**",
    "0-1": "Identifier of the App Space the request belongs to.",
    "1-0": "**requestGuid**",
    "1-1": "Identifier of the Request to process.",
    "2-0": "**selectedButtonIndex**",
    "2-1": "The JSON index of the button object that was selected by the user. This is used to determine the authorization level the request requires to be processed. It can be used to confirm the action the user selected.",
    "3-0": "**responseContent**",
    "3-1": "This field is used to record any data as a result of user interaction that should be signed with the request. EG. user inputed form data, typed text input.",
    "5-0": "**completion**",
    "5-1": "Completion handler with these params:\n***success*** - True if successful.\n***error*** - nil if successful, otherwise an error object.",
    "h-0": "Parameters",
    "4-0": "biometricAuthReason",
    "4-1": "The Touch/Face ID reason for requesting authentication, which displays in the authentication dialog presented to the user."
  },
  "cols": 2,
  "rows": 6
}
[/block]

<br/>

### requestNotificationActedOn

```swift
public func requestNotificationActedOn ( notificationUserInfo: [AnyHashable: Any] )
```

Uploads telemetry data for the event that a request notification is clicked. Call this method from within you App Delegate's notification handler, E.G. inside of:

```swift
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
```

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**notificationUserInfo**",
    "0-1": "The received Privakey notification userInfo forwarded from your app delegate's notification handler."
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### requestViewStart

```swift
public func requestViewStart ( request: PrivakeyRequest )
```

Initiates the process of uploading a request viewed telemetry event. Call this method whenever request content is being displayed in the app. Once the view goes off screen, be sure to call `requestViewEnd(request)` to complete the process.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**request**",
    "0-1": "The Privakey Request being displayed."
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### requestViewEnd

```swift
public func requestViewEnd ( request: PrivakeyRequest )
```

Completes the process of uploading a request viewed telemetry event. Call this method whenever request content is done being displayed in the app. It should be called as a followup to `requestViewStart(request)`, above.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**request**",
    "0-1": "The Privakey Request being displayed."
  },
  "cols": 2,
  "rows": 1
}
[/block]

<br/>

### handlePrivakeyNotification

```swift
public func handlePrivakeyNotification ( notificationUserInfo: [AnyHashable : Any], completion: @escaping ( _ didRevokeDevice: Bool ) -> Void )
```

Processes Privakey notifications. Forward any received Privakey notifications to this method. If a notification to revoke is received, then didRevokeDevice will be true and you should clear your app data accordingly.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**notificationUserInfo**",
    "1-0": "**completion**",
    "1-1": "Completion handler with these params:\n***didRevokeDevice*** - True if the device was revoked.",
    "0-1": "The received Privakey notification userInfo forwarded from your app delegate's notification handler."
  },
  "cols": 2,
  "rows": 2
}
[/block]

<br/>

### checkStatus

```swift
public func checkStatus ( completion: @escaping ( _ didRevokeDevice: Bool, _ didSuspendAccount: Bool ) -> Void )
```

Checks if the current device or associated account status has changed and handles it appropriately. If the device is revoked, then didRevokeDevice will be true and you should clear your app data accordingly. If the account was suspended, then didSuspendAccount will be true and you should update the UI accordingly.

[block:parameters]
{
  "data": {
    "h-0": "Parameters",
    "0-0": "**completion**",
    "0-1": "Completion handler with these params:\n***didRevokeDevice*** - True if the device was revoked.\n***didSuspendAccount*** - True if the account was suspended."
  },
  "cols": 2,
  "rows": 1
}
[/block]