Environment Build
1. Overview
This article mainly introduces some configurations that need to be added to your project before integrating Lumi SDK, and obtains the necessary parameters for SDK initialization.
2. Preconditions
- Confirm completion Preparation.
3. Add Dependencies
3.1 Compilation environment requirements
Supported version
| System | Version |
|---|---|
| iOS | 13.0 |
| iPad OS | 13.0 |
Swift Version 5.0+
3.2 Permission Statement
3.2.1 The SDK needs to add the following privacy permissions in Xcode:
| Permission | Info.plist | Key |
|---|---|---|
| Bluetooth | Privacy - Bluetooth Always Usage Description | NSBluetoothAlwaysUsageDescription |
| Camera | Privacy - Camera Usage Description | NSCameraUsageDescription |
| Microphone | Privacy - Microphone Usage Description | NSMicrophoneUsageDescription |
| Photo Library | Privacy - Photo Library Usage Description | NSPhotoLibraryUsageDescription |
| Location | Privacy - Location When In Use Usage Description | NSLocationWhenInUseUsageDescription |
| Location | Privacy - Location Always and When In Use Usage Description | NSLocationAlwaysAndWhenInUseUsageDescription |
| Local Network | Privacy - Local Network Usage Description | NSLocalNetworkUsageDescription |
| HomeKit | Privacy - HomeKit Usage Description | NSHomeKitUsageDescription |
3.2.2 The Access Network SDK needs to add the following additional capabilities in Xcode:
| Capability | Entitlements Key |
|---|---|
| Hotspot | com.apple.developer.networking.HotspotConfiguration |
| Access WiFi Information | com.apple.developer.networking.wifi-info |
| Wireless Accessory Configuration | com.apple.external-accessory.wireless-configuration |
3.2.3 If the connected device is under the Matter protocol, Xcode needs to add the Matter Extension Target

3.2.4 The host app also needs to apply for the following capabilities in Xcode:

| Permission | Entitlements Key |
|---|---|
| HomeKit AllowSetUpPayload | com.apple.developer.homekit.allow-setup-payload |
| Matter Allow Setup Payload | ccom.apple.developer.matter.allow-setup-payload |
| Manager Thread Network Credentials | com.apple.developer.networking.manage-thread-network-credentials |
| App Groups | com.apple.security.application-groups |
3.2.5 The Matter Extension also needs to apply for the following capabilities in Xcode:

| Permission | Entitlements Key |
|---|---|
| App Groups | com.apple.security.application-groups |
3.2.6 At the same time, the following key value pairs need to be added to the Info.plist of the host app:

| Key | Values |
| NSBonjourServices | _meshcop._udp |
| _matter._tcp | |
| _matterc._udp | |
| _matterd._udp | |
| _aqara._tcp. |
3.2.3.4 Add the following key value pairs in Info.plist of Matter Extension:

| Key | Values |
| NSBonjourServices | _matter._tcp |
| _matterc._udp | |
| _matterd._udp |
Important
Manager Thread Network CredentialsCapability needs to be applied separately on the apple developer website: https://developer.apple.com/contact/request/threadnetwork The above privacy permission instructions must be provided, otherwise the application will crash when using the corresponding permissions for the first time.
4. Integration
4.1 Install CocoaPods
We recommend using Homebrew to install CocoaPods.
4.1.1 Podfile integration
platform :ios, '13.0'
inhibit_all_warnings!
use_modular_headers!
target 'CameraOpenSDKDemo' do
# Basic SDK, including access network, device control, and camera related functions, all require integration with the basic SDK
pod 'LMBaseEncryption', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMBaseEncryption'
pod 'LMFramework', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMFramework'
pod 'LMSwiftCore', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMSwiftCore'
# UI Component Library
pod 'LMCommonUI', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMCommonUI'
pod 'LMCommonUISwift', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMCommonUISwift'
# Access network SDK, needs to integrate UI Component Library
pod 'LMExtensionNetwork', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMExtensionNetwork'
pod 'LMMatter', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMMatter'
pod 'LMMatterCore', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMMatterCore'
pod 'LMMatterUI', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMMatterUI'
pod 'LMAccessNetSDK', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMAccessNetSDK'
# Device control SDK, requires integration of UI Component Library
pod 'LMFirmwareUpgradeFramework', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMFirmwareUpgradeFramework'
pod 'LMMeshDriverFramework', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMMeshDriverFramework'
pod 'LMMeshDriver_UI', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMMeshDriver_UI'
# Camera SDK,requires integration of UI Component Library
pod 'LMCameraFramework', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMCameraFramework'
pod 'EMPageViewController', :git => 'https://github.com/MrLittleWhite/EMPageViewController.git', :tag => '4.0.8'
# Some of the dependency libraries in the above SDK require specifying a git address or CommitID
pod 'RealReachability', :git => 'https://github.com/OHeroJ/RealReachability.git'
pod 'SGQRCode', :git=>'https://github.com/acodeworker/SGQRCode.git', :commit => 'a3054dd68f94e46902a82291b897f50a31ed836a'
end
# When the connected device is a Matter protocol, Matter Extension integrates SDK
target 'MatterExtension' do
pod 'LMMatter', :path => './CameraOpenSDKDemo/AqaraFrameworks/LMMatter'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Temporarily disable concurrent security check for ActiveLabel
if target.name == 'ActiveLabel'
config.build_settings['SWIFT_STRICT_CONCURRENCY'] = 'minimal'
end
end
end
end
5. Initialization
5.1 Get the necessary parameters for SDK initialization
5.1.1 Get AppId、AppKey
Refer to the document Preparation.
5.1.2 Get other necessary parameters
According to different account authorization methods, the acquisition methods are also inconsistent. For details, please refer to Authorization Management.
Generally speaking, the virtual account authorization mode is used most of the time, that is, the third-party app needs to request its own cloud platform to obtain relevant parameters:

5.2 SDK Initialization
Integrate various business SDKs on the Aqara Android side, usually only need to be initialized uniformly through LMOpenSDK, other business SDKs usually do not need to be initialized separately.
5.2.1 Perform Unified Initialization
Call initialize interfac
/**
appId: APPID applied from open platform
appKey: The APPKey that matches the APPID
supportDeviceArea:
serverCode: Aqara Server Code
countryCode: Aqara Server Code
server: Aqara distribution network domain name
coapServer: Configure the server address and server area code of the device
appImgPrefix: Path of CDN images in the UI
staticsResPrefix: Path of Static Resource
*/
LMRegionModel *regionModel = [[LMRegionModel alloc] init];
regionModel.appId = @"Your appId";
regionModel.appKey = @"Your appKey";
regionModel.supportDeviceArea = @"Your SupportDeviceArea";
regionModel.serverCode = @"Your ServerCode";
regionModel.countryCode = @"Your CountryCode";
regionModel.server = @"Your Server";
regionModel.coapServer = @"Your CoapServer";
regionModel.staticsResPrefix = @"Your StaticsResPrefix";
regionModel.appImgPrefix = [@"Your AppImgPrefix" stringByAppendingString:@"/default"];
[LMOpenSDK setRegionModel:regionModel];
/**
Set H5 resource path within SDK
*/
[LMOpenSDK setH5UrlPrefix:@"Your H5UrlPrefix"];
/**
setLanguage:
"en" English
"ru" Russia
"ko" Korea
"zh-Hans" China
"zh-HK" Hong Kong, China
"zh-Hant-TW" Taiwan, China
*/
[LMOpenSDK setLanguage:@"Your Language"];
/**
Configure useid token obtained from open platform applications
*/
[LMOpenSDK setUserId:@"Your UserId" token:@"Your AccessToken"];
/**
If your application does not use device control, device settings, and other functions (i.e. does not use the `LMMeshDriverFramework` library), the following configuration can be ignored.
The function of the following configuration is: the SDK will read the local plug-in
local file path: localjs
*/
[LMDriverConfig sharedInstance].isLocalResource(YES);
/**
English:
appId: APPID applied from open platform
appKey: The APPKey that matches the APPID
supportDeviceArea:
serverCode: Aqara Server Code
countryCode: Aqara Server Code
server: Aqara distribution network domain name
coapServer: Configure the server address of the device
appImgPrefix: Path of CDN images in the UI
staticsResPrefix: Path of Static Resource
*/
let regionModel = LMRegionModel<AnyObject, AnyObject>()
regionModel.appId = "Your appId"
regionModel.appKey = "Your appKey"
regionModel.supportDeviceArea = "Your SupportDeviceArea"
regionModel.serverCode = "Your ServerCode"
regionModel.countryCode = "Your CountryCode"
regionModel.server = "Your Server"
regionModel.coapServer = "Your CoapServer"
regionModel.staticsResPrefix = "Your StaticsResPrefix"
regionModel.appImgPrefix = "Your AppImgPrefix" + "/default"
LMOpenSDK.setRegionModel(regionModel)
/**
Set H5 resource path within SDK
*/
LMOpenSDK.setH5UrlPrefix("Your H5UrlPrefix")
/**
setLanguage:
"en" English
"ru" Russia
"ko" Korea
"zh-Hans" China
"zh-HK" Hong Kong, China
"zh-Hant-TW" Taiwan, China
*/
LMOpenSDK.setLanguage("Your Language")
/**
Configure useid token obtained from open platform applications
*/
LMOpenSDK.setUserId("Your UserId", token: "Your AccessToken")
/**
If your application does not use device control, device settings, and other functions (i.e. does not use the `LMMeshDriverFramework` library), the following configuration can be ignored.
The function of the following configuration is: the SDK will read the local plug-in
local file path: localjs
*/
LMDriverConfig.sharedInstance().isLocalResource()(true)
Parameter Description
| Field | Type | Description | Access channel |
|---|---|---|---|
| appId | String | App unique identification | Aqara Developer Platform |
| appKey | String | App unique identification | Aqara Developer Platform |
| server | String | The domain name requested by the SDK | Interface acquisition, please refer to Aqara Developer Platform |
| h5UrlPrefix | String | The H5 link requested by the SDK | Interface acquisition, please refer to Aqara Developer Platform |
| staticsResPrefix | String | Image cdn address requested by the SDK | Interface acquisition, please refer to Aqara Developer Platform |
| userId | String | Unique user ID | Interface acquisition, please refer to Aqara Developer Platform |
| accessToken | String | User access token | Interface acquisition, please refer to Aqara Developer Platform |
| area | String | App Location | The default value is CN |
| language | String | App current language | The default value is zh |
| supportDeviceArea | String | The area where the device is connected to the network | The default value is CHN |
Note: area and supportDeviceArea, some area codes are different
language value
The language parameter will affect the SDK and the cloud to return to the multi-language type.
| Value | Describe | Description |
|---|---|---|
| zh | Simplified Chinese | Default Value |
| zh_TW | Taiwan Traditional | / |
| zh_HK | Hong Kong Traditional | / |
| en | English | / |
| ko | Korean | / |
| ru | Russian | / |
| de | German | / |
| it | Italian | / |
| fr | French | / |
| es | Spanish | / |
Note: This value only affects the multilingual information dynamically obtained, such as cloud interfaces, configuration files, etc. The multilingual used by the SDK itself (stored in Localizable.strings) follows the multilingual of the host App.
area value
The area parameter will affect the business logic of the cloud interface, and some services may be unavailable in some areas.
| Value | Describe | Description |
|---|---|---|
| CN | China mainland | Default Value |
| HMT | Hong Kong, Macau, Taiwan of China | / |
| US | America | / |
| EU | Europe | / |
| RU | Russia | / |
| SEA | Southeast Asia | / |
| KR | Korea | / |
| JP | Japan | / |
| AU | Australia | / |
| ME | Middle East | / |
| AF | Africa | / |
| OTHER | Other areas | / |
supportDeviceArea Value
The supportDeviceArea parameter will affect the device network configuration. (Some devices can only be activated and used in specific regions)
| Value | Describe | Description |
|---|---|---|
| CHN | China mainland | Default Value |
| HMT | Hong Kong, Macau, Taiwan of China | / |
| US | America | / |
| EU | Europe | / |
| RUS | Russia | / |
| SEA | Southeast Asia | / |
| KR | Korea | / |
| JP | Japan | / |
| AU | Australia | / |
| ME | Middle East | / |
| AF | Africa | / |
| OTHER | Other areas | / |