The examples consider applications that include one screen and several buttons. Each button implements one simple action and executes a framework method. All applications describe basic functions and enable the user to quickly start working with frameworks.
Each application should contain authentication method. If a local database is used, open a connection and load resources schemes.
To create an example using authentication method, see the Examples of Authentication on Mobile Platform Server section.
To create an example using mobile platform server availability check method, see the Example of Mobile Platform Server Availability Check section.
Examples of working with:
The example of source code for preparing application to work with a mobile platform server using a local database:
let apiVersion: String = "v1"
let host: String = "http://testmasterfmp.fsight.cloud/"
let environment: String = "DocumentationExampleEnv"
let project: String = "DocumentationExampleProj"
let device: String = (UIDevice.current.identifierForVendor?.uuidString)!
HHFWController.sharedInstance().initWithCredentials(
apiVersion,
host: host,
environment: environment,
project: project,
device: device
)
let userName: String = "test"
let password: String = "test123"
let databaseName = "database.sqlite"
let databaseKey = "databaseKey"
// Authentication
HHFWController.sharedInstance().auth(userName, password: password){ (jsonResult) in
if let jsonDict = jsonResult as? NSDictionary,
let status = jsonDict["status"] as? String, status == "ok" {
print("Auth success")
// Open database connection and load resources schema
HHFWController.sharedInstance().resources(databaseName, password: databaseKey, handler: { (jsonResult) in
if let jsonDict = jsonResult as? NSDictionary,
let status = jsonDict["status"] as? String, status == "ok" {
print("Open base and resource scheme success")
}
})
}
}
See. also: