Device Ownership & Access Management

Send Invitation

The primary user account with active CV services has the ability to add a secondary user to their account by providing secondary user information.


IoTDeviceManager.sendInvite(recipient: "user-id-of-recipient", 
                            iotId: "device-id") { (error) in
    if let error = error {
        print("Failed to send invitation with error: \(error.description)")
        // Handle error
        ...
    }else {
        print("Successfully sent invitation")

        ...
    }
}

Request Access

Allows someone to access request to be secondary user to an IoT device. This method is deprecated as the API Endpoint no longer exists.

IoTDeviceManager.requestAccess(iotId: "iot-device-id") { (error) in
    if let error = error {
        print("Failed to request access with error: \(error.description)")
        // Handle error
        ...
    }else {
        print("Successfully sent invitation")

        ...
    }
}

Approve Access Request

Approve secondary user’s request using the request message ID. This method is deprecated as the API Endpoint no longer exists.

IoTDeviceManager.approveAccess(messageId: "request-message-Id") { (error) in
    if let error = error {
        print("Failed to approve access with error: \(error.description)")
        // Handle error
        ...
    }else {
        print("Successfully.")

        ...
    }
}

Transfer Ownership

Allow the primary user to hand over its authority to a secondary user while the current primary user becomes a secondary user. This method is deprecated as the API Endpoint no longer exists.

IoTDeviceManager.transferOwnership(iotId: "device-Id",
                                   transferTo: "secondary-user-id") { (error) in
    if let error = error {
        print("Failed to transfer ownership with error: \(error.description)")
        // Handle error
        ...
    }else {
        print("Successfully.")

        ...
    }
}

Revoke Access

Revoke secondary user’s access to an IoT device. This method is deprecated as the API Endpoint no longer exists.

IoTDeviceManager.revokeSecondaryUser(iotId: "device-id", 
                                     iotType: .vehicle, // Defaults to .vehicle if not specified.
                                     revokeFrom: "secondary-user-id") { (error) in
    if let error = error {
        print("Failed to revoke access with error: \(error.description)")
        // Handle error
        ...
    }else {
        print("Successfully.")

        ...
    }
}

Get Request List

Get a list of all access request messages. The messages can be filtered using parameters for the purpose, request status, and device type.

IoTDeviceManager.getMessages(purpose: self.purposeFilter, 
                             status: .pending, // Defaults to .pending if not specified.
                             iotId: device.iotId,
                             iotType: .vehicle) { (messages, error) in
    if let error = error {
        print("Failed to fetch access messages with error: \(error.description)")
        // Handle error
        ...
    }else {
        print("Successfully.")

        // Do something with messages
        ...
    }
}

Remove Request

Delete an access request message.

IoTDeviceManager.deleteMessage(messageId: "request-message-id") { (error) in
    if let error = error {
        print("Failed to fetch delete messages with error: \(error.description)")
        // Handle error
        ...
    }else {
        print("Successfully.")

        ...
    }
}

After a user finished enrollment with a device, use this API to delink the device from user, all primary ownership and secondary ownerships will be removed, along with all pending requests/invitations. This method is deprecated as the API Endpoint no longer exists.

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