{"id":19858413,"url":"https://github.com/tuya/tuya-socket-ios-sdk","last_synced_at":"2025-10-24T06:16:59.794Z","repository":{"id":103228822,"uuid":"313532387","full_name":"tuya/tuya-socket-ios-sdk","owner":"tuya","description":"TuyaSmartSocketKit is for products that connect to Tuya Cloud Platform, provides LAN connection between iOS devices and hardware devices.","archived":false,"fork":false,"pushed_at":"2021-02-27T09:53:59.000Z","size":2013,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-01-11T14:25:52.034Z","etag":null,"topics":["tuya"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-17T06:53:00.000Z","updated_at":"2021-08-05T06:41:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"3343bf1d-f86c-42c3-a55c-0d1ac5a1d3e6","html_url":"https://github.com/tuya/tuya-socket-ios-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-socket-ios-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-socket-ios-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-socket-ios-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-socket-ios-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuya","download_url":"https://codeload.github.com/tuya/tuya-socket-ios-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241255123,"owners_count":19934815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["tuya"],"created_at":"2024-11-12T14:23:21.323Z","updated_at":"2025-10-24T06:16:59.719Z","avatar_url":"https://github.com/tuya.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"#### Note: This repository is inherited from the [old Tuya Github repository](https://github.com/TuyaInc/tuyasmart_socket_ios_sdk) that will be deprecated soon. Please use this repository for Tuya SDK development instead. For changing the existing remote repository URL, see this [tutorial](https://docs.github.com/en/github/using-git/changing-a-remotes-url)\n\n## Tuya Socket iOS SDK\n\n[中文版](README_cn.md) | [English](README.md)\n\n\u003e `TuyaSmartSocketKit` is mainly for iOS developers concerning Tuya cloud-to-cloud connection products. This project is launched to provide LAN connection between iPhones (hereinafter referred to as a phone) and hardware devices (hereinafter referred to as a device)and send dpCode in LAN to control communication.\n\nThe Tuya device connection and control process is as follows: https://cdn.nlark.com/yuque/__puml/1de1d74497bdbb14a4debde42f3f3f34.svg\n\n## Procedure\n`TuyaSmartSocketKit` uses `TuyaSmartSocket` as an access.\n\n#### 1. LAN initialization\n\nYou can connect to the LAN with the following methods:\n```\n[[TuyaSmartSocket sharedInstance] startSocketService];\n```\n\nYou can monitor the LAN changes with the following methods:\n```\n[TuyaSmartSocket sharedInstance].delegate = self;\n```\n\n#### 2. Device connection\nThe device informs that the LAN will be connected through TuyaSmartSocoket in the following below. This parameter can be obtained through the API of cloud-to-cloud connection `/v1.0/devices/schema`.\n```\n/**\n *  set device info\n Configure basic device information \n *\n *  @param devInfo   devInfo\n */\n- (void)addDeviceInfoWIthDevInfo:(NSDictionary *)devInfo;\n```\n\n#### 3. Device communication\nIn the delegate callback, the device can be controlled after a successful connection.\n```\n- (void)socketDidTcpConnected:(TuyaSmartSocket *)socket devId:(NSString *)devId;\n```\n\nControl the device by sending dpCode to the device in the following method.\n```\n/**\n *  publish message in lan use standard data point\n *\n Send LAN message with standard dpCode *\n *  @param devId    devId\n *  @param dpCodeDict   dpCode : dpValue\n *  @param success  Success block\n *  @param failure  Failure block\n */\n - (void)sendRequestWithDevId:(NSString *)devId\n                 dpcodeValue:(NSDictionary\u003cNSString */* dpCode */,id/* dpValue */\u003e *)dpCodeDict\n                     success:(void(^)(void))success\n                     failure:(void(^)(void))failure;\n```\n\n`dpCodeValue` Composition rule： For detailed information about the DP, see [Update device information](https://tuyainc.github.io/tuyasmart_home_ios_sdk_doc/en/resource/Device.html#device-management)\n\n`dpCode` describes the DPs of the device, namely, what control functions does a device support. The DPs supported by the device will be returned in the **schema** that is returned in the \" /v1.0/devices/schema\" API. The sections below describe the typical DPs respectively. \n`dpCodeDict` is performed in the format of `dpCode` : `dpValue` . `The dpCode` can be obtained from the code field in **schema**. `dpValue` needs to be sent in the format that the DP supports. The section below describes the composition of dpCode, using the Demo in the API documentation as an example.\n##### 1. Switch\n    \"type\": \"bool\"\n    e.g. {@\"switch_led\" : YES} or {@\"switch_led\" : YES}\n```\n{\n    \"mode\": \"rw\",\n    \"code\": \"switch_led\",\n    \"name\": \"Switch\",\n    \"property\": {\n        \"type\": \"bool\"\n    },\n    \"iconname\": \"icon- dp_power2\",\n    \"id\": 20,\n    \"type\": \"obj\",\n    \"desc\": \"\"\n }\n```\n##### 2. Mode selection (single option)\n\n    \"type\": \"enum\"\n    e.g. dpCode : {@\"work_mode\" : @\"white\"} {@\"work_mode\" : @\"colour\"}\n```\n{\n    \"mode\": \"rw\",\n    \"code\": \"work_mode\",\n    \"name\": \"mode\",\n    \"property\": {\n        \"range\": [\"white\", \"colour\", \"scene\", \"music\"],\n        \"type\": \"enum\"\n    },\n    \"iconname\": \"i con-dp_list\",\n    \"id\": 21,\n    \"type\": \"obj\",\n    \"desc\": \"\"\n }\n```\n\n##### 3. Brightness value (Send value)\n    \"type\": \"value\"\n    e.g. dpCode: {@\"bright_value\": @(400)}\n    Note: The values are limited by maximum, minimum and step values.\n```\n{\n   \"mode\": \"rw\",\n   \"code\": \"bright_value\",\n   \"name\": \"Brightness value\",\n   \"property\": {\n     \"min\": 10,\n     \"max\": 1000,\n     \"scale\": 0,\n     \"step\": 1,\n     \"type\": \"value\"\n   },\n   \"iconname \": \"icon-dp_sun\",\n   \"id\": 22,\n   \"type\": \"obj\",\n   \"desc\": \"\"\n }\n ```\n##### 4. Colored light (send string)\n    \"type\": \"string\"\n    e.g. dpCode: {@\"colour_data\":@\"000100010001\"}\n    The method above is just one of the transmission methods, and the specific deValue value needs to be analyzed according to the specific situation\n```\n{\n    \"mode\": \"rw\",\n    \"code\": \"colour_data\",\n    \"name\": \"Colored light\",\n    \"property\": {\n        \"type\": \"string\",\n        \"maxlen\": 255\n    },\n    \"iconname\": \"icon- dp_light\",\n    \"id\": 24,\n    \"type\": \"obj\",\n    \"desc\": \"\"\n }\n```\n#### 4. Disconnect\n```\n[[TuyaSmartSocket sharedInstance] closeSocketService];\n[TuyaSmartSocket sharedInstance].delegate = nil;\n```\n## Support\n\nYou can get support through the following accesses:\n\n* [Tuya Smart Help Center](https://support.tuya.com/en/help)\n\n* [Technical Support Council](https://iot.tuya.com/council/) \n\n## License\n\nThe Tuya Home iOS SDK Sample is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuya%2Ftuya-socket-ios-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuya%2Ftuya-socket-ios-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuya%2Ftuya-socket-ios-sdk/lists"}