Skip to content

This sample demonstrates how to use Tuya Home SDK's Apple HomeKit capabilities in Objective-C.

Notifications You must be signed in to change notification settings

tuya/tuya-ios-apple-homekit-sample-objc

Repository files navigation

Tuya Apple HomeKit Sample for Objective-C

This sample describes how to quickly integrate HomeKit functionality by using an SDK. The TuyaSmartAppleDeviceKit module allows you to manage HomeKit data from Apple's 'Home' app and bind Apple devices directly to the Tuya Cloud. The module features faster integration with the Apple HomeKit framework. A simple interface is provided for you to bind devices to the Tuya Cloud and get device information.

To support HomeKit in your projects, perform the following steps:

  • Add an NSHomeKitUsageDescription key with a string value in the app's Info.plist that explains how the app uses this data.
  • Add the HomeKit capability. HomeKit can be used to connect your app to HomeKit accessories and create home configurations.

A HomeKit-enabled Tuya device is required.

Prerequisites

  • Xcode 12.0 and later
  • iOS 12 and later

Use the sample

  1. The Tuya iOS HomeSDK 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 and a security image from Tuya IoT Platform, and register a developer account if you don't have one. Then, perform the following steps:

    1. Log in to the Tuya IoT platform. In the left-side navigation pane, choose App > SDK Development.
    2. Click Create to create an app.
    3. Fill in the required information. Make sure that you enter the valid Bundle ID. It cannot be changed afterward.
    4. You can find the AppKey, AppSecret, and security image under the Obtain Key tag.
  2. Open the TuyaAppSDKSample-iOS-ObjC.xcworkspace pod generated for you.

  3. Fill in the AppKey and AppSecret in the AppKey.h file.

#define APP_KEY @"<#AppKey#>"
#define APP_SECRET_KEY @"<#SecretKey#>"
  1. Download the security image, rename it to t_s.bmp, and then drag it to the workspace to be at the same level as Info.plist.

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.

References

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

About

This sample demonstrates how to use Tuya Home SDK's Apple HomeKit capabilities in Objective-C.

Topics

Resources

Stars

Watchers

Forks