Door Lock SDK Use
1. Overview
This article mainly introduces how to use the door lock SDK for network access and device control.
2. Preconditions
- Confirm completion Preparation
- Confirm the completion of Environment Build
- CompletedDoor Lock SDK Integration
3. Use
The door lock SDK supports different devices in the form of RN plug-ins, and each device has a separate plug-in file.
3.1 Jump to the door lock access page
Use the following API to enter the door lock access page.
LumiReactNativeManager.getInstance().startRNAccessPage("deviceModel","positionId")
Parameter Description
Field | Type of data | Describe | Access channel |
---|---|---|---|
deviceModel | String | Device model value | See appendix List of supported door lock devices |
positionId | String | Room location | Interface acquisition, see Aqara Developer Platform |
3.2 Jump to the door lock device control page
LumiReactNativeManager.getInstance().startRNPage("deviceModel", "deviceId")
Parameter Description
Field | Type of data | Describe | Access channel |
---|---|---|---|
deviceModel | String | Device model value | See appendix List of supported door lock devices |
deviceId | String | Device Id | Cloud interface, after the device is successfully configured, the device id will be generated |
3.3 Event listener
When the user clicks some buttons or meets other conditions during the page operation, the event callback can be obtained through the event listener. For example, click a button to jump to a page in the host App, or a third-party custom event.
3.3.1 Register and Unbind
//Register
LumiReactNativeManager.getInstance().registerRNMessageCallback(object :IRNMessageCallback{
override fun onHandleMessage(jsonMessage: String, promise: Promise?) {
//To Do Something
}
})
//Unbind
LumiReactNativeManager.getInstance().unregisterRNMessageCallback()
3.3.2 List of Common Events
Event | Type | Describe |
---|---|---|
action_access_success | Notify | After the device is successfully connected to the network, the third-party App can do some of its own business. |
AddGatewway | Notify | Some door locks need to be bound to a hub. If there is no hub under the account, this event will be triggered, and the third-party app will handle it by itself. |
3.4 RN plugin
3.4.1 Depends on local plugin files
The door lock SDK supports loading local plug-in files, just put the corresponding files in the directory.
1.Please put the plugin file in the assets/lumi/reactnative/prefab/bundle
directory.
2.Please put the configuration file in the assets/lumi/reactnative/prefab/config
directory.
In the case of relying on local plug-ins, the plug-in will not be updated from the cloud. If it needs to be updated, you need to develop and put the new version of the RN plug-in in the assets directory, and re-package and release.
3.4.2 Depends on remote plugin files
The door lock SDK supports loading remote plug-in files placed on the server, and supports hot updates, and can be used in conjunction with local plug-ins
.
This function involves the management and distribution of remote plug-in files, and is not available for external use at the moment. If you need it, please contact the business.