IoT Device Management

Get Device List


IoTDeviceManager.getIoTDeviceList { (devices, error) in
            self.items = devices

            if error == nil {
                self.updateUI()
            } else {
                NotificationUI.showMessage(type: .error, title: "Error", message: error!.localizedDescription)
            }
        }

Add Device


IoTDeviceManager.addIoTDevice(device: device) { (error) in
                if error != nil {
                    NotificationUI.showMessage(type: .error,
                                               title: "Failed to add device to user",
                                               message: error!.localizedDescription)
                } else {
                    NotificationUI.showMessage(type: .success,
                                               title: "Successfully added device to user",
                                               message: "")

                    self.navigationController?.popViewController(animated: true)
                }
            }

Remove Device


IoTDeviceManager.removeIoTDevice(device: device) { (error) in
                if error != nil {
                    NotificationUI.showMessage(type: .error,
                                               title: "Failed to remove device",
                                               message: error!.localizedDescription)
                } else {
                    NotificationUI.showMessage(type: .success,
                                               title: "Successfully removed device from user",
                                               message: "")

                }
            }

Update Device


IoTDeviceManager.updateIoTDevice(device: device) { (error) in
                if error != nil {
                    NotificationUI.showMessage(type: .error,
                                               title: "Failed to update device info",
                                               message: error!.localizedDescription)
                } else {
                    NotificationUI.showMessage(type: .success,
                                               title: "Successfully updated device info",
                                               message: "")

                }
            }