Connection.setServerKey()
DESCRIPTION
Set the server key associated with this client application through the Nabto Cloud Console.
DECLARATION
public func setServerKey(key: String) throws
PARAMETERS
key:
- The server key to use.
ERRORS
Throws the following errors:
INVALID_STATE:
- if connection already established
RETURN VALUES
None.
EXAMPLES
func invoke() throws {
let client = NabtoEdgeClient.Client()
client.enableNsLogLogging()
try client.setLogLevel(level: "trace")
let connection = try client.createConnection()
let privateKey = try client.createPrivateKey()
try connection.setPrivateKey(key: privateKey)
try connection.setProductId(id: "pr-fatqcwj9")
try connection.setDeviceId(id: "de-ijrdq47i")
try connection.setServerKey(key: "sk-9c826d2ebb4343a789b280fe22b98305")
try connection.setServerConnectToken(sct: "WzwjoTabnvux")
try connection.connect()
let details: NabtoEdgeClient.DeviceDetails = try NabtoEdgeClient.IamUtil.getDeviceDetails(connection: connection)
DispatchQueue.main.async {
self.spinner.stopAnimating()
self.label.text = "Device SDK Version: \(details.NabtoVersion)"
}
}