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

  1. Confirm completion Preparation
  2. This article defaults that you have installed Xcode 12 or above, and CocoaPods (https://cocoapods.org) 1.9.0 or above;
  3. Complete Door 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 SDK configuration *

In the place where the APP starts, such as AppDelegate.m, import the header file, and follow the steps to initialize the configuration.

 #import <LMFramework/LMFramework.h>
Initialize the SDK
+ (void)setServer:(NSString*)host appId:(NSString*)appId appKey:(NSString*)appKey iconBaseUrl:(NSString *)iconBaseUrl;
Parameter Description
host Aqara device pairing domain name (see open platform)
appId APPID applied from the open platform
appKey APPKey matched with APPID
iconBaseUrl The path of some CDN pictures in the device pairing UI layer

Example:

    [LMOpenSDK setServer:@"https://aiot.aqara.com/" appId:@"7be19xxxxxxxxxxxxx" appKey:@"JddzxxxxxxxxxxIHfW8E3" iconBaseUrl:@"https://cdn.aqara.com/cdn/common/mainland"];

Configure the server address and server area code of the device

+ (void)setCoapServer:(NSString*)coapServer;
+ (void)setCountryCode:(NSString*)countryCode;
Parameter Description
coapServer The server address of the device
countryCode Country code

Example:

   [LMOpenSDK setCoapServer:@"aiot-coap.aqara.cn"];
   [LMOpenSDK setCountryCode:@"CHN"];

Configure user information applied from the open platform

+ (void)setUserId:(NSString*)userId  token:(NSString*)token;
Parameter Description
userId User ID
token User token
[LMOpenSDK setUserId:@"431xxxxxx.xxxxxxx153527809" token:@"ad46dbxxxxxxxxx1fcee1"];

3.2 Jump door lock into the network

Where needed, import the header file of LMRnFramework, click to jump to the header file, you can view the corresponding interface description.

#import <LMRnFramework/LMBusiRnSDK.h>

API - Jump door lock network plug-in

/**
 @param deviceModel  Device model
 @param positionId   Position id
 @param navC   Navigation controller, get the topmost controller by default
 */
- (void)startRnAccessPage: (NSString *)deviceModel
               positionId:(NSString *)positionId
                     navC: (UINavigationController * _Nullable)navC;

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

Example:

  [[LMBusiRnSDK shareManager] startRnAccessPage: @"aqara.lock.agl002" positionId:@"real1.xxxxxxxxxxxxxxxxxxx512" navC:nil];

3.3 Jump door lock control plugin

Where needed, import the header file of LMRnFramework, click to jump to the header file, you can view the corresponding interface description.

#import <LMRnFramework/LMBusiRnSDK.h>

API - Jump door lock control plugin

/**
 @param deviceId    Device id
 @param deviceModel Device model
 @param navC   Navigation controller, get the topmost controller by default
 */
- (void)startRnDevicePage:(NSString *)deviceId
              deviceModel: (NSString *)deviceModel
                     navC: (UINavigationController * _Nullable)navC;
Field Type of data Describe Access channel
deviceModel String Device model value See appendix list of supported door lock devices
deviceId String Device Id After the device is configured successfully, the device id will be generated

Example:

   [[LMBusiRnSDK shareManager] startRnDevicePage:@"lumi.54efxxxxxxxxxxxxxc88b" deviceModel:@"aqara.lock.agl002" navC:nil];

3.4 Plugin News Subscription

API - Register Rn plugin message listener

/// @param callback  Message listener callback
/// @note message    NSDictionary,  Structure: { action: 'action_xxx_xxx',  param: {... ... } }
///       --action:
///         action_access_success  The door lock is connected to the network successfully
///         action_add_gateway     Add hub
///         action_open_ifttt      Turn on automation
///         action_open_scene      Open scene
- (void)registerRnPluginMessageNotification:(void(^_Nullable)(NSDictionary * _Nullable message))callback;
Field Type of data Describe Access channel
callback Block Message listener callback None
message NSDictionary Message body None

note: According to the needs of your project, subscribe and parse related actions, and handle message events by yourself.

Example:

 [[LMBusiRnSDK shareManager] registerRnPluginMessageNotification:^(NSDictionary * _Nullable message) {
        NSLog(@"messsge: %@", message);
        if (message && [message objectForKey: @"action_access_success"]) {
            NSDictionary *param = [message objectForKey: @"param"];
            /// TODO: Handle prompts for successful network access, device name modification, etc.
            NSLog(@"--- The door lock is connected to the network successfully ---");
        }
    }];

API - Remove the Rn plugin message listener

- (void)unregisterRnPluginMessageNotification;
Field Type of data Describe Access channel
None None None None

note: According to the needs of your project, if the plug-in message listener has been registered, please remove it in an appropriate place such as dealloc to avoid memory leaks.

Example:

 [[LMBusiRnSDK shareManager] unregisterRnPluginMessageNotification];
Copyright © 2023 Lumi United Technology Co., Ltd. all right reserved,powered by GitbookFile Modify: 2024-09-27 21:51:47

results matching ""

    No results matching ""