设备控制SDK使用

一、概述

本文主要介绍如何使用设备控制 SDK 进行设备页面跳转等 API 调用。

重要变更

自最新版 SDK 起,设备页面跳转统一由 LMSDKDeviceRouter.framework 提供。该框架会根据设备接入类型(原生、RN、H5、摄像机等)自动路由到对应页面,推荐所有新接入项目使用此接口

旧版直接调用各垂直品类 SDK 跳转接口的方式已废弃,请统一使用 LMSDKDeviceRouter

二、前提条件

  1. 完成准备工作
  2. 完成环境搭建
  3. 完成设备控制SDK集成

三、使用

3.1 跳转到设备控制首页(推荐)

导入头文件:

#import <LMSDKDeviceRouter/LMSDKDeviceRouter.h>
import LMSDKDeviceRouter

Objective-C 示例:

[LMSDKDeviceRouter pushToDeviceControlPageWithDevice:device
                                navigationController:self.navigationController
                                            animated:YES
                                          completion:^(NSError * _Nullable error, id _Nullable result) {
    if (error) {
        // 处理跳转失败
    }
}];

Swift 示例:

LMSDKDeviceRouter.pushToDeviceControlPage(with: device,
                                          navigationController: self.navigationController,
                                          animated: true) { error, result in
    if let error = error {
        // 处理跳转失败
    }
}

参数说明

字段 数据类型 描述 获取渠道
device LMDevice 设备信息对象 设备配网成功后,从云端获取
navigationController UINavigationController 当前导航控制器 宿主 App 提供
animated BOOL 是否使用动画
completion Block 跳转完成回调,error 非空表示失败

LMSDKDeviceRouter 会根据设备 model 自动识别接入类型并跳转至对应页面(原生控制页、RN 插件页、摄像机播放页等),无需再手动判断设备品类后分别调用不同 SDK 接口

3.2 跳转到设备设置 / 详情页

[LMSDKDeviceRouter pushToDeviceDetailPageWithDevice:device
                               navigationController:self.navigationController
                                           animated:YES
                                         completion:^(NSError * _Nullable error, id _Nullable result) {
}];
LMSDKDeviceRouter.pushToDeviceDetailPage(with: device,
                                         navigationController: self.navigationController,
                                         animated: true) { error, result in
}

3.3 根据页面类型跳转

当需要明确指定跳转目标页面时,可使用通用跳转接口:

[LMSDKDeviceRouter pushToDevicePageWithDevice:device
                                     pageType:LMSDKDevicePageTypeControl
                         navigationController:self.navigationController
                                     animated:YES
                                  extraParams:nil
                                   completion:^(NSError * _Nullable error, id _Nullable result) {
}];

pageType 取值

枚举值 说明
LMSDKDevicePageTypeControl 设备控制首页
LMSDKDevicePageTypeDetail 设备设置 / 详情页

四、说明

场景 接口 所属 Framework
跳转设备控制首页 pushToDeviceControlPageWithDevice:... LMSDKDeviceRouter
跳转设备设置页 pushToDeviceDetailPageWithDevice:... LMSDKDeviceRouter
按页面类型跳转 pushToDevicePageWithDevice:pageType:... LMSDKDeviceRouter

对于摄像机设备,使用 LMSDKDeviceRouter 跳转控制首页时,框架会自动路由至摄像机播放页。详见摄像机SDK集成及使用

LHDeviceRouter 属于 LMMeshDriver_UI 内部路由,供 SDK 内部控件回调使用,宿主 App 不应直接调用

lumi LogoCopyright © 2023 深圳绿米联创科技有限公司 all right reserved,powered by Gitbook文档修改时间: 2026-08-26 16:55:47

results matching ""

    No results matching ""