To develop a mobile application, requests to mobile platform server use iOS framework methods of the HHFWController main class.
The most of methods are executed asynchronously in a background stream. To display request execution result, send the "hander" closure of the HHFWCompletionHandler? type to the method that is automatically called in the main stream after method execution.
NOTE. Before executing methods execute authenticatin by means of the auth method. To work with a local database and resources, open connection and load resources schemes, otherwise methods will call the "handler" closure with the Null parameter.

Authenticate user by login and password (auth)
The auth method authenticates the user by login and password.
NOTE. Before executing the method make sure that data source credentials are added in the project.
HHFWController.sharedInstance().auth(_ login: String, password: String, handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| login | String | User login. |
| password | String | User password. |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let userName: String = "user"
let password: String = "password"
HHFWController.sharedInstance().auth(userName, password: password){ (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains authentication status, error description and other information
// This block can also be used to open database connection
}
After executing the method a user token is obtained. The token is used in each request to mobile platform server.

Cancel authentication (unAuth)
The unAuth method cancels user authentication.
HHFWController.sharedInstance().unAuth()
The use of methods is given in the Example of Authentication at Mobile Platform Server example.

Open or create a database (openBase)
The openBase method opens connection with the database at the specified path.
When the connection is established, data can be written to local database. If the database is not found at the specified path, a new database is created, with which a connection is established.
NOTE. Create a database in the Documents application folder. Framework methods address to the database of this folder.
HHFWController.sharedInstance().openBase(_ pathBase: String, key: String) -> Bool
Input parameters:
| Parameter | Data type | Description |
| pathBase | String | Path to database file (on a mobile device). |
| key | String | Database encryption key. |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let paths: [URL] = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let fullDatabaseURL: URL = paths[0].appendingPathComponent("database.sqlite")
let databaseKey: String = "key" // if encryption is not needed, then key = ""
HHFWController.sharedInstance().openBase(fullDatabaseURL.path, key: databaseKey)
After executing the method a connection is opened with the local database, and True is returned, otherwise False is returned.
The query method sends SQL query to local database.
HHFWController.sharedInstance().query(_ base: String?, query: String) -> String?
Input parameters:
| Parameter | Data type | Description |
| base | String? | Path to database file (in application folder) |
| query | String | SQL query. |
Table name format in local database: <resourceName>_<hash>_<tableName>, where:
resourceName. Resource name.
hash. Hash sum calculated based on request parameters. Parameters are specified in the request to write data to database using the "data" property of the *CallParams class.
tableName. Table name.
Example:
let jsonResult: String? = HHFWController.sharedInstance().query("/Documents/\(databaseName)", query: "SELECT * FROM TableNameInDatabase WHERE `key` = 'value'")

Get table name (getTablesName)
The getTablesName method returns the table name in local database.
HHFWController.sharedInstance().getTablesName(_ databasePath: String, resourceName resource: String, requestParams params: String, tableName table: String?) -> String?
Input parameters:
| Parameter | Data type | Description |
| databasePath | String | Path to database file (in application folder) |
| resourceName, resource | String | Resource name. |
| requestParams, params | String | JSON string with parameters, with which query was executed. |
| tableName, table | String? | Table name at server. It is used to get a specific table in a multi-table resource. |
Example:
let databaseName: String = "database.sqlite"
let resourceName: String = "ResourceName"
let params: String = "{}"
let tableName: String = "TableName"
let jsonResult: String! = HHFWController.sharedInstance().getTablesName("/Documents/\(databaseName)", resourceName: resourceName, requestParams: "", tableName: tableName)
After executing the example the list of all table names is obtained.

Delete tables from database (dropCache)
The dropCache method deletes tables from database.
HHFWController.sharedInstance().dropCache(_ databasePath: String, resourceName resource: String, requestParams params: String) -> String?
Input parameters:
| Parameter | Data type | Description |
| databasePath | String | Path to database file (in application folder) |
| resourceName, resource | String | Resource name. |
| requestParams, params | String | JSON string with parameters, with which query was executed. |
Example:
To clear cache in a local database, delete tables that were created after queries with specifying specific parameters:
let databaseName: String = "database.sqlite"
let resourceName: String = "ResourceName"
let params: String = "{}"
let jsonResult: String! = HHFWController.sharedInstance().dropCache("/Documents/\(databaseName)", resourceName: resourceName, requestParams: params)
To delete all files with the *.sqlite extension from the DocumentDirectory application folder, use the query without specifying parameters:
HHFWController.sharedInstance().dropCache()
The closeBase method closes database connection.
HHFWController.sharedInstance().closeBase(_ pathBase: String) -> Bool
Input parameters:
| Parameter | Data type | Description |
| pathBase | String | Path to database file (on a mobile device). |
The method can be used if authentication is canceled.
The use of methods is given in examples in the Examples of Working with Resources section.

Load resources scheme (resources)
The resources method gets schemes of available resources and automatically creates corresponding tables in the database.
HHFWController.sharedInstance().resources(_ database: String?, handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| database | String | Name of database in use. |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let databaseName: String = "database.sqlite"
HHFWController.sharedInstance().resources(databaseName){ (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about scheme request, server response and resources scheme
}
After executing the method the resources scheme is automatically written to the specified database.

Load delta to database (deltaStream)
The deltaStream method loads delta to database.
NOTE. Before executing the method load resources scheme.
HHFWController.sharedInstance().deltaStream(_ resourseName: String, deltaStreamCallParams: DeltaStreamCallParams?, handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| resourseName | String | Resource name. |
| deltaStreamCallParams | DeltaStreamCallParams? | An instance of the DeltaStreamCallParams class describing request parameters. |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
When initializing with defaultDb the hhfw.sqlite name is used by default. If the searched database name differs, after initialization of DeltaStreamCallParams specify full path to the database using the dataBasePath property.
Example:
let deltaStreamCallParams: DeltaStreamCallParams = DeltaStreamCallParams(defaultDb: ())
deltaStreamCallParams?.dataBasePath = fullDatabaseURL.path
let resourceName: String = "ResourceName" // resource name
HHFWController.sharedInstance().deltaStream(resourceName, deltaStreamCallParams: deltaStreamCallParams){ (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}
After executing the method the data delta is automatically written to the specified database according to the previously obtained scheme.

Load table data to database (tableStream)
The tableStream method loads table data to database.
NOTE. Before executing the method load resources scheme.
HHFWController.sharedInstance().tableStream(_ resourseName: String, transactionID: String?, tableCallParams: RequestCallParams?, handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| resourseName | String | Resource name. |
| transactionID | String? | Transaction identifier. |
| tableCallParams | RequestCallParams? | An instance of the RequestCallParams class describing query parameters. |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
When initializing with defaultDb the hhfw.sqlite name is used by default. If the searched database name differs, after initialization of RequestCallParams specify full path to the database using the dataBasePath property.
Example:
let requestCallParams: RequestCallParams = RequestCallParams(defaultDb: ())
requestCallParams?.dataBasePath = fullDatabaseURL.path
let resourceName: String = "ResourceName" // resource name
HHFWController.sharedInstance().tableStream(resourceName, transactionID: nil, tableCallParams: requestCallParams){ (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}
After executing the method table data is automatically written to the specified database according to the previously obtained scheme.
Table data can also be filtered. To filter data, specify query arguments in the query via sending the dictionary with arguments into the "args" parameter for the instance of the *CallParams class.
For details about filtering types, see the Method for Working with Table Resources section.
The example of query to get data filtered by values in columnName columns:
let requestCallParams: RequestCallParams = RequestCallParams(defaultDb: ())
requestCallParams?.dataBasePath = fullDatabaseURL.path
requestCallParams?.args = ["col_columnName1": value1, "col_columnName2": value2, ...]

Get resource table data without loading to database (table)
The table method returns resource table data without loading to database.
HHFWController.sharedInstance().table(_ resourseName: String, transactionID: String?, tableCallParams: TableCallParams?, handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| resourseName | String | Resource name. |
| transactionID | String? | Transaction identifier. |
| tableCallParams | TableCallParams? | An instance of the TableCallParams class describing query parameters. |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let tableCallParams: TableCallParams = TableCallParams(defaultProperty: ())
HHFWController.sharedInstance().table(resourceName, transactionID: nil, tableCallParams: tableCallParams){ (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Request to resource without loading to database (request)
The request method sends an uniform request to resource without loading to database.
HHFWController.sharedInstance().request(_ resourseName: String, requestCallParams: RequestCallParams?, handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| resourseName | String | Resource name. |
| tableCallParams | RequestCallParams? | An instance of the RequestCallParams class describing query parameters. |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
The method use is relevant when working with WEB resources where mobile platform server is used as a proxy.
Example:
let requestCallParams: RequestCallParams = RequestCallParams(defaultProperty: ())
HHFWController.sharedInstance().request(resourceName, requestCallParams: requestCallParams){ (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}
The use of methods is given in examples in the Examples of Working with Resources section.
To work with push notifications, use a mobile device, prepare the application to get push notifications and determine a device token.
To send push notifications from mobile platform server to a mobile device, generate Apple Push Services certificate based on the certificates obtained in Apple Developer Account:
Download the required certificate from the developer account and add it to Keychain Access.
Open the certificate in Keychain Access.
Select the certificate and the closed key, export them to the required location with the *.p12 extension.
In the terminal go to the directory with exported file and convert it into the file with the *.pem extension.
cd Desktop // directory that contains exported file, for example, in the desktop
openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts
Add the certificate in the Apple Push Notification Service section when setting up push notifications.
For details about queries to send push notifications see the Method of Working with Push Notifications section.

Get list of active tokens (getTokens)
The getTokens method returns the list of tokens linked to the user at the server.
HHFWController.sharedInstance().getTokens(_ handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
HHFWController.sharedInstance().getTokens() { (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Send token to server (addToken)
The addToken method sends token to server.
HHFWController.sharedInstance().addToken(_ token: String, service: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| token | String | Device token. |
| service | String | Name of push notifications service. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let token: String = "DeviceToken" // get during registration for remote notifications
let service: String = "apns"
HHFWController.sharedInstance().addToken(token, service: service) { (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Remove tokens from server (removeTokens)
The removeTokens method removes sent tokens from server.
Several tokens can be removed at once by sending an array to the method.
HHFWController.sharedInstance().removeTokens(_ tokens: NSMutableArray, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| tokens | NSMutableArray | Device tokens array. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let tokens: [String] = [token1, token2, ...] // message topic names
HHFWController.sharedInstance().removeTokens(tokens) { (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Get message topics list (getTopics)
The getTopics method returns message topics list.
HHFWController.sharedInstance().getTopics(_ handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
HHFWController.sharedInstance().getTopics { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Subscribe to messages (subscribeTopics)
The subscribeTopics method subscribes to messages with the specified topic.
HHFWController.sharedInstance().subscribeTopics(_ topics: NSMutableArray, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| topics | NSMutableArray | Message topic names array. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let topics: [String] = [topic1, topic2, ...] // message topic names
HHFWController.sharedInstance().subscribeTopics(topics) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Unsubscribe from messages (unsubscribeTopics)
The unsubscribeTopics method unsubscribes from messages with the specified topic.
HHFWController.sharedInstance().unsubscribeTopics(_ topics: NSMutableArray, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| topics | NSMutableArray | Message topic names array. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let topics: [String] = [topic1, topic2, ...] // message topic names
HHFWController.sharedInstance().unsubscribeTopics(topics) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}
The use of methods is given in the Example of Working with Push Notifications section.
Before executing the methods set up connection to folder at file server and add a permissions to load data in the Info.plist in the mobile application project:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

Get information about directory contents (getDirectory)
The getDirectory method returns information about directory contents.
HHFWController.sharedInstance().getDirectory(_ directory: String, mountName: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| directory | String | Directory. |
| mountName | String | Name of file server connection. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let directory: String = "DirectoryName"
let mountName: String = "MountName"
HHFWController.sharedInstance().getDirectory(directory, mountName: mountName) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Get file information (getFileMeta)
The getFileMeta method returns file information.
HHFWController.sharedInstance().getFileMeta(_ filename: String, mountName: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| filename | String | Path to file. |
| mountName | String | Name of file server connection. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let fileName: String = "FileName"
let mountName: String = "MountName"
HHFWController.sharedInstance().getFileMeta(fileName, mountName: mountName) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Download file from server (getFile)
The getFile method downloads a file from mobile platform server.
HHFWController.sharedInstance().getFile(_ filename: String, mountName: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| filename | String | Path to file. |
| mountName | String | Name of file server connection. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let fileName: String = "FileName"
let mountName: String = "MountName"
HHFWController.sharedInstance().getFileMeta(fileName, mountName: mountName) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Upload file to server (putFile)
The putFile method uploads file to mobile platform server.
HHFWController.sharedInstance().putFile(_ filename: String, mountName: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| filename | String | Path to file. |
| mountName | String | Name of file server connection. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let fileName: String = "FileName"
let mountName: String = "MountName"
HHFWController.sharedInstance().putFile(fileName, mountName: mountName) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Delete file from server (deleteFile)
The deleteFile method deletes file from mobile platform server.
HHFWController.sharedInstance().deleteFile(_ filename: String, mountName: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| filename | String | Path to file. |
| mountName | String | Name of file server connection. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let fileName: String = "FileName"
let mountName: String = "MountName"
HHFWController.sharedInstance().deleteFile(fileName, mountName: mountName) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}
The use of methods is given in the Example of Working with Files section.
For details about sending transaction data see the Sending Transaction Data section.

Get all transactions list (getAllTransactionResourceName)
The getAllTransactionResourceName method returns all transactions list.
HHFWController.sharedInstance().getAllTransactionResourceName(_ name: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| name | String | Resource name. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
HHFWController.sharedInstance().getAllTransactionResourceName(resourceName, completionHandler: { (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Get response by transaction ID (getTransaction)
The getTransaction method returns the response from mobile platform server by transaction ID.
HHFWController.sharedInstance().getTransaction(_ transactionID: String, resourceName name: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| transactionID | String | Transaction identifier. |
| resourceName, name | String | Resource name. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let transactionID: String = UUID().uuidString
let tableCallParams: TableCallParams = TableCallParams(defaultProperty: ())
HHFWController.sharedInstance().table(resourceName, transactionID: transactionID, tableCallParams: tableCallParams, handler: {(jsonResult) in
// Get response to query by transactionID
HHFWController.sharedInstance().getTransaction(transactionID, resourceName: resourceName, completionHandler: { (jsonResult: Any?) in
// This block can process response from mobile platform server jsonResult that is presented JSON
// jsonResult contains information about query, server response, and query result
})
})

Repeated query with specifying transaction ID (retryTable)
The retryTable method executes repeated query to mobile platform server to get saved data marked with transaction ID.
NOTE. The method is used after getting resource table data without loading to database.
HHFWController.sharedInstance().retryTable(_ resuurceName: String, transactionID: String?, tableCallParams: TableCallParams?, handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| resourceName, name | String | Resource name. |
| transactionID | String? | Transaction identifier. |
| tableCallParams | TableCallParams? | An instance of the TableCallParams class describing query parameters. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let tableCallParams: TableCallParams = TableCallParams(defaultProperty: ())
HHFWController.sharedInstance().retryTable(resourceName, transactionID: transactionID, tableCallParams: tableCallParams){ (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response, and query result

Delete transaction information (deleteTransaction)
The deleteTransaction method deletes transaction information.
HHFWController.sharedInstance().deleteTransaction(_ transactionID: String, resourceName name: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| transactionID | String | Transaction identifier. |
| resourceName, name | String | Resource name. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let transactionID: String = "c4f64acd-7e0f-4bd7-ba32-9a15271f3eb4"
HHFWController.sharedInstance().deleteTransaction(transactionID, resourceName: resourceName, completionHandler: { (jsonResult: Any?) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
})
The use of methods is given in the Example of Working with Transactions section.
Before executing the methods set up parameters of connection to DSS CryptoPro.

Get certificates list (getCertificatesWithPassword)
The getCertificatesWithPassword method returns certificates list.
HHFWController.sharedInstance().getCertificatesWithPassword(_ password: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| password | String | DSS user password. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let dssPassword: String = "DSSPassword"
HHFWController.sharedInstance().getCertificatesWithPassword(dssPassword) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Get digital signatures history (signs)
The signs method returns the list of digital signatures that were created by the current user.
HHFWController.sharedInstance().signs(completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
HHFWController.sharedInstance().signs { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}

Send document to sign (signCertificate)
The signCertificate method sends a document to sign.
HHFWController.sharedInstance().signCertificate(withResource resource: String, table: String, params requestParams: String, column: String, hhiveId: String, password: String, certificateId: String, certificatePin: String, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| withResource, resource | String | Resource name. |
| table | String | Table name. |
| params, requestParams | String | JSON string with parameters, with which query was executed. |
| column | String | Table column name. |
| hhiveId | String | Table row name. |
| password | String | DSS password. |
| certificateId | String | Certificate identifier. |
| certificatePin | String | Certificate PIN. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let resourceName: String = "ResourceName"
let tableName: String = "TableName"
let params: String = "{key1: value1, key2: value2, ...}"
let column: String = "ColumnName"
let hhiveId: String = "HhiveId"
let dssPassword: String = "DSSPassword"
let certificateId: String = "CertificateId"
let certificatePin: String = "CertificatePin"
HHFWController.sharedInstance().signCertificate(
withResource: resourceName,
table: tableName,
params: params,
column: column,
hhiveId: hhiveId,
password: dssPassword,
certificateId: certificateId,
certificatePin: certificatePin
) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}
After executing the method the document is signed, and the mobile platform server returns signature identifier as {"signature_id": 35}.

Remove digital signature (remove)
The remove method removes digital signature.
HHFWController.sharedInstance().remove(withSignId signId: Int, completionHandler handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| withSignId, signId | Int | Signature identifier. |
| completionHandler, handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
Example:
let signatureID: Int = 1
HHFWController.sharedInstance().remove(withSignId: signatureId) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}
The use of methods is given in the Example of Working with Digital Signature section.
Access to WEB resources is made as via proxy. The mobile platform server is used as an intermediary between a mobile device and WEB resources.
Before executing the method make sure that the connection is opened with local database, and resources schemes are loaded.

Request to WEB resources (request)
The request method sends a request to WEB resources.
HHFWController.sharedInstance().request(_ resourseName: String, requestCallParams: RequestCallParams?, handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| resourseName | String | Resource name. |
| tableCallParams | RequestCallParams? | An instance of the RequestCallParams class describing query parameters. |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
If the used instance of the RequestCallParams class sets the "data" parameter (JSON string), a POST request is executedl if the string is empty, a GET request is executed.
Example:
let resourceName: String = "WebResourceName"
let requestCallParams: RequestCallParams = RequestCallParams(defaultProperty: ())
// For POST request
requestCallParams?.data = "{}"
HHFWController.sharedInstance().request(resourceName, requestCallParams: requestCallParams) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}
The method use is given in the Example of Working with WEB Resources section.
Accessing Foresight Analytics Platform is executed identically to accessing WEB resources.

Request to Foresight Analytics Platform (request)
The "request" method sends a request to Foresight Analytics Platform.
HHFWController.sharedInstance().request(_ resourseName: String, requestCallParams: RequestCallParams?, handler: HHFWCompletionHandler? = nil)
Input parameters:
| Parameter | Data type | Description |
| resourseName | String | Resource name. |
| tableCallParams | RequestCallParams? | An instance of the RequestCallParams class describing query parameters. |
| handler | HHFWCompletionHandler? | Callback function executed after query is completed. It is set to nil by default. |
let resourceName: String = "FAPResourceName"
let requestCallParams: RequestCallParams = RequestCallParams(defaultProperty: ())
requestCallParams?.data = "{}"
HHFWController.sharedInstance().request(resourceName, requestCallParams: requestCallParams) { (jsonResult) in
// This block can be used to process response from jsonResult mobile platform server that is presented as JSON
// jsonResult contains information about query, server response and query result
}
The method use is given in the Example of Working with Foresight Analytics Platform. section.

Set logging level (setLogLevel)
The setLogLevel method sets a logging level.
Logging level enables the user to manage the amount of information that is returned on executing framework methods and is displayed in the debug output box in the development environment. Managing information output facilitates the development.
For example, the first logging level displays JSON responses from mobile platform server to data queries and SQL queries to local database. When the first logging level is changed for the third logging level, JSON responses are not displayed.
HHFWController.sharedInstance().setLogLevel(_ level: Int32)
Input parameters:
| Parameter | Data type | Description |
| level | Int32 | Logging level:
|
Example:
let logLevel: Int32 = 1
HHFWController.sharedInstance().setLogLevel(logLevel)
See also:
iOS Framework | Initializing iOS Framework | Examples of iOS Framework Use