skills/developer.tuya.com/building-tuya-ios-device-foundation

building-tuya-ios-device-foundation

Installation
SKILL.md

概述 {#description}

为已接入 Tuya Smart App SDK 的 iOS ObjC 工程落地设备管理基础能力。涵盖设备信息与监听、设备操作(重命名/移除/恢复出厂)、设备共享三大模块。

核心类:

  • ThingSmartDevice:单设备操作入口,通过 [ThingSmartDevice deviceWithDeviceId:devId] 获取。
  • ThingSmartDeviceModel:设备数据模型,包含 devId、name、dps、isOnline、isLocalOnline、productId、iconUrl 等。
  • ThingSmartDeviceDelegate:设备监听 delegate,提供 dpsUpdatedeviceInfoUpdatedeviceRemoved 等回调。
  • ThingSmartHomeDelegate:家庭维度的设备变化回调(注意 SDK 中拼写为 Deivice,非笔误)。
  • ThingSmartHomeDeviceShare:设备共享管理入口,最多 20 个用户。

适用场景 {#scene}

需要在已完成 SDK 集成、用户已登录、至少有一个家庭的工程中操作单个设备时使用。

Phase 1 — 设备信息获取:调用 getHomeDataWithSuccess:failure: 后,从 ThingSmartHomeModel.deviceList 获取 ThingSmartDeviceModel 列表;[ThingSmartDevice deviceWithDeviceId:devId] 创建设备操作实例;DP 数据直接从 ThingSmartDeviceModel.dps(NSDictionary)读取,无需额外查询。

Phase 2 — 设备监听:在 ViewController 或 ViewModel 初始化时设置 device.delegate = self;在 dealloc 或消失时 device.delegate = nil

Installs
4
First Seen
May 28, 2026
building-tuya-ios-device-foundation from developer.tuya.com