Door Lock SDK Usage
1. Overview
This document mainly introduces how to use the Door Lock SDK for onboarding and device control.
2. Prerequisites
- Complete Preparation
- Complete Environment Build
- Complete Door Lock SDK Integration
3. Usage
The Door Lock SDK supports different devices in the form of RN plugins, and each device has a separate plugin file.
3.1 Navigate to the Door Lock Onboarding Page
Use the following API to enter the door lock onboarding page.
LumiReactNativeManager.getInstance().startRNAccessPage("deviceModel","positionId")
Parameters
| Field | Type | Description | Source |
|---|---|---|---|
| deviceModel | String | Device model value | See Appendix Supported Door Lock Device List |
| positionId | String | Room location | Obtained via API; see Aqara Developer Platform for details |
3.2 Navigate to the Door Lock Device Control Page
LumiReactNativeManager.getInstance().startRNPage("deviceModel", "deviceId")
Parameters
| Field | Type | Description | Source |
|---|---|---|---|
| deviceModel | String | Device model value | See Appendix Supported Door Lock Device List |
| deviceId | String | Device ID | Cloud API; generated after the device is successfully paired |
3.3 Event Listener
During user interactions, events such as button clicks or other conditions can trigger callbacks via event listeners. For example, clicking a button may navigate to a page in the host app or trigger custom third-party events.
3.3.1 Register & Unregister
// Register
LumiReactNativeManager.getInstance().registerRNMessageCallback(object :IRNMessageCallback{
override fun onHandleMessage(jsonMessage: String, promise: Promise?) {
//To Do Something
}
})
// Unregister
LumiReactNativeManager.getInstance().unregisterRNMessageCallback()
3.3.2 Common Event List
| Event | Type | Description |
|---|---|---|
| action_access_success | Notification | Triggered when a device is successfully added. Third-party apps can perform custom business logic. |
| AddGatewway | Notification | Some door locks need to bind a gateway. If there is no gateway under the account, this event is triggered and the third-party app handles it itself. |
| OpenDeviceControlPage | Notification | Notification to open a specified device page. Third-party apps can perform custom business logic. |
3.4 Device Plugin
3.4.1 Use Local Plugin Files
The SDK supports loading local plugin files by placing the corresponding files in the project directory.
Place plugin and configuration files under the assets/lumi/ directory.
When using local plugins, no cloud updates are performed. To update, developers need to place the new version of the RN plugin in the assets directory and repackage for release.
3.4.2 Use Remote Plugin Files
The SDK supports loading remote plugin files from a server and supports hot updates. This can be used together with local plugins.
This feature involves remote plugin file management and delivery and is not publicly available. Contact business support if needed.