Contact Us
Log In

Lighting SDK

Last Updated on : 2022-03-01 08:33:08download

The development of lighting devices is complex due to two coexisting versions of light firmware, v1 and v2. You must develop two sets of control logic even though standard commands are used. The packaged lighting functions include on/off, working mode, brightness, color temperature, multi-color, and four scenes.

Demo app

For more information about the Lighting SDK on GitHub, see Lighting SDK. Follow the instructions in the Smart Life App SDK demo app, and configure the values of BundleId, AppKey, AppSecret, and security image.

Based on the features of the Smart Life App SDK demo app, the Lighting SDK demo app is added with the capabilities to connect lighting devices. You can call the encapsulated APIs to implement these capabilities and accelerate the app development process. The following features are supported:

  • Get the light type
  • Get all DP values
  • Turn a light on or off
  • Switch between working modes
  • Adjust light brightness
  • Adjust color temperature
  • Switch between scenes
  • Adjust light colors

Fast integration

Use CocoaPods for fast integration

  1. Add the following code block to the Podfile:

    platform :ios, '9.0'
    target 'your_target_name' do
    	pod 'TuyaSmartLightKit', :git => 'https://github.com/tuya/tuya-lighting-ios-sdk.git'
  2. In the root directory of your project, run pod update to integrate with a third-party library. For more information about CocoaPods, see CocoaPods Guides.

Initialize the SDK

  1. Open the project settings, click Target > General, and then modify Bundle Identifier to the iOS Bundle ID set on the Tuya IoT Development Platform.

  2. Import the security image to the root directory of the project, and rename it as t_s.bmp. Go to Project Settings > Target > Build Phases, and add this image to Copy Bundle Resources.

  3. Configure the header file that matches the target project type.

    • Objective-C project: Add the following content to the project file PrefixHeader.pch:

      #import <TuyaSmartLightKit/TuyaSmartLightKit.h>
    • Swift project: Add the following content to the bridging header file xxx_Bridging-Header.h:

      #import <TuyaSmartLightKit/TuyaSmartLightKit.h>
  4. Open the AppDelegate.m file and initialize the SDK in [AppDelegate application:didFinishLaunchingWithOptions:].

    • ObjC:

      [[TuyaSmartSDK sharedInstance] startWithAppKey:<#your_app_key#> secretKey:<#your_secret_key#>];
    • Swift:

      TuyaSmartSDK.sharedInstance()?.start(withAppKey: <#your_app_key#>, secretKey: <#your_secret_key#>)

Now, you are ready for app development.

This section contains the following topics to help you quickly understand related concepts and how-to guides: