Set/Get Device Information
Once logged in to the application, you can get the device information and update it. Set / Get Device information flows involve the events detailed in the respective tables.
iOS/Swift
For Swift, you can use the following code snippets, where the completion handler handles the response to the event:
Triggering GetDeviceInformation Event(Swift)
func triggerGetDeviceInformationEvent(
userIdentifier: KsUserIdentifier,
withCompletionHandler completionBlock: ((KsEvent?) -> Void)? = nil)
{
let event = KSMGetDeviceInformationEvent(
userIdentifier: userIdentifier )
masterControllerAdapter.sendEvent2MasterController(event) { (event) in
// Handle this result according to your requirement
completionBlock?(event)
}
}
Triggering SetDeviceName Event(Swift)
func triggerSetDeviceNameEvent(
setDeviceNameRequest: SetDeviceNameRequest,
completion: @escaping(_ result:KsEvent?) -> Void)
{
let setDeviceInfo = KSMSetDeviceNameEvent(
deviceName: setDeviceNameRequest.deviceName)
masterControllerAdapter.sendEvent2MasterController(setDeviceInfo) {
(event) in
// Handle this result according to your requirement
completion(event)
}
}
Android/Kotlin
Triggering GetDeviceInformation Event(Kotlin)
fun triggerGetDeviceInformationEvent(userId: String, tenantId: String) {
val getDeviceInformationEvent =
GetDeviceInformationEvent(UserIdentifier(tenantId, userId))
synchronousEventHandler.postEvent(getDeviceInformationEvent)?.then {
// handle result
}
}
Triggering SetDeviceName Event(Kotlin)
fun triggerSetDeviceNameEvent(deviceName: String) {
val setDeviceNameEvent = SetDeviceNameEvent(deviceName)
synchronousEventHandler.postEvent(setDeviceNameEvent)?.then {
// handle result
}
}
Handling SetDeviceNameResult Event
override fun executeEvent(event: EventFrameworkEvent?) {
when (eventFrameworkEvent) {
is SetDeviceNameResultEvent -> {
when (eventFrameworkEvent.status) {
StatusType.OK -> {
}
StatusType.NOT_UNIQUE -> {
}
StatusType.NOT_REACHABLE -> {
}
else -> {
}
}
}
}
}