Skip to content

tuya/tuya-home-ios-sdk-sample-swift

Repository files navigation

Tuya iOS HomeSDK Sample for Swift

This sample demonstrates the use of Tuya iOS Smart Life App SDK to build an IoT app from scratch.Tuya iOS Smart Life App SDK is divided into several function groups to give developers a clear insight into the implementation of different features, including the user registration process, home management for different users, device network configuration, and controls. For device network configuration, the EZ mode and AP mode are implemented. This allows developers to pair devices over Wi-Fi and control the devices over LAN and MQTT. For device control, a common panel is used to send and receive any types of data points.

Tuya Smart app

Self-developed Smart Life App Service

Self-Developed Smart Life App is one of Tuya’s IoT app development solutions. This solution provides the services that enable connections between the app and the cloud. It also supports a full range of services and capabilities that customers can use to independently develop mobile apps. The Smart Life App SDK used in this sample is included in the Self-developed Smart Life App Service.

Self-Developed Smart Life App is classified into the Development and Official editions:

  • Self-Developed App Development: provided for a free trial. It supports up to 1 million cloud API calls per month and up to 100 registered end users in total.

  • Self-Developed App Official: provided for commercial use and costs $5,000/year (¥33,500/year) for the initial subscription and $2,000/year (¥13,500/year) for subsequent annual renewal. It is supplied with the Custom Domain Name service and up to 100 million cloud API calls per month.

For more information, please check the Pricing.

Prerequisites

  • Xcode 12.0 and later
  • iOS 12 and later

Use the sample

  1. The Tuya iOS Smart Life App SDK is distributed through CocoaPods and other dependencies in this sample. Make sure that you have installed CocoaPods. If not, run the following command to install CocoaPods first:
sudo gem install cocoapods
pod setup
  1. Clone or download this sample, change the directory to the one that includes Podfile, and then run the following command:
pod install
  1. This sample requires you to have a pair of keys from Tuya IoT Platform, and register a developer account if you don't have one. For more details, please check this tutorial: Preparation
  2. Open the TuyaAppSDKSample-iOS-Swift.xcworkspace pod generated for you.
  3. Fill in the AppKey and AppSecret in the AppKey.swift file.
struct AppKey {
    static let appKey = "Your AppKey"
    static let secretKey = "Your SecretKey"
}

Note: The bundle ID, AppKey, AppSecret, and security image must be the same as your app on the Tuya IoT Platform. Otherwise, the sample cannot request the API.

For more details, please check this tutorial Fast Integration with Smart Life App SDK for iOS.

References

For more information about Tuya iOS HomeSDK, see App SDK.