Quick Start

Last Updated on : 2024-06-18 08:09:18download

Smart locks use different protocols, such as Bluetooth, Wi-Fi, Wi-Fi with camera, and Zigbee. The Smart Lock SDK is built on top of the Smart Life App SDK. This tutorial walks you through a few steps to develop a mobile app with the SDK in an hour. You will learn how to implement the following features:

  • Connect a smart lock through the app.
  • Connect to and disconnect from a lock over Bluetooth.
  • Unlock and lock the door.

You can go to GitHub and download the sample code. This tutorial is broken down into sections based on features, making it easy for you to quickly locate the code.

App SDK Development GitHub Sample

Preview

With this tutorial and some knowledge of panel development, you will be able to create an iOS app like this.

Preparation

Before starting, ensure you have the following prepared.

  1. Create a Tuya Developer Platform account and an app, with the AppKey and AppSecret ready. For more information, see Preparation.

    The Smart Lock SDK depends on the Smart Life App SDK. Implement creating an account and adding a home before incorporating lock-specific features. For more information, see Quick Start with Smart Life App SDK.

  2. Prepare a Tuya-enabled lock. This tutorial demonstrates the process using a lock. Visit TuyaGo to explore Tuya-enabled products.

  3. Integrate the Smart Life App SDK and Smart Lock SDK into your project using CocoaPods. For more information, see SDK Integration.

Device pairing

Tuya-enabled smart locks support all pairing modes available in the Smart Life App SDK, including Wi-Fi access point (AP) mode and Bluetooth pairing. For more information, see Device Pairing.

Connect to a Bluetooth lock

Before connecting, unlocking, or locking the Bluetooth lock, check the lock’s Bluetooth connection status.

Query Bluetooth connection status

- (BOOL)isBLEConnected;

- (BOOL)isOnline;

Connect to a Bluetooth lock

- (void)autoConnect;

Unlock and lock a Bluetooth lock

Unlock a Bluetooth lock

- (void)bleUnlock:(NSString *)lockUserId
          success:(ThingSuccessHandler)success
          failure:(ThingFailureError)failure;

Lock a Bluetooth lock

- (void)bleManualLock:(ThingSuccessHandler)success
              failure:(ThingFailureError)failure;

Unlock a Wi-Fi lock

Unlock a Wi-Fi lock remotely

- (void)replyRemoteUnlock:(BOOL)open
                  success:(nullable ThingSuccessHandler)success
                  failure:(nullable ThingFailureError)failure;

Next step

Review the lock SDK documentation to explore more features.