Door Lock SDK Integration
1. Overview
This article mainly introduces how iOS integrates the door lock SDK.
2. Preconditions
- Confirm completion Preparation
- This article defaults that you have installed Xcode 12 or above, and CocoaPods (https://cocoapods.org) 1.9.0 or above;
3. Features
3.1 Main function
- Support Aqara door lock network access.
- Support Aqara door lock control.
3.2 SDK Size
Dependent library | Description | Size |
---|---|---|
React Native(0.63.4) | React Native framework | 12MB |
Aqara bridge layer | Components necessary for the SDK to run | 共26MB |
Other | Components necessary for the SDK to run | 13MB |
Total | - | 51MB |
The above are the maximum increments after the executable file is compiled with the integrated SDK, and the size of the SDK code package is not provided. Usually, when the dependencies of the App overlap with the third-party dependencies of the SDK, the compilation increment will be less than 51MB.
3.3 Support equipment category
See Equipment List
4. Integration
4.1 iOS SDK Directory Structure
.
├── LMRFramworks
│ ├── LMFramework.framework
│ └── LMRnFramework.framework
├── LMRnFramework.podspec
├── PKGResource
│ ├── aqara.lock.agl002
│ ├── ios_base
│ └── lumi.lock.netAccess
└── RN
├── app.json
├── bundle
├── index.android.js
├── index.ios.js
├── index.ios.jsbundle
├── index.ios.jsbundle.meta
├── ios
├── node_modules
├── package-lock.json
├── package.json
├── src
└── yarn.lock
Contents include:
1).Aqara bridging layer Framework: LMFramework.framework、LMRnFramework.framework.
2).Rn plugin package: PKGResource folder.
3).React Native (0.63.4) framework code: Rn folder
4.2 How to use
Since the sdk relies on many system libraries, such as 'AudioToolbox', 'SystemConfiguration', 'CoreLocation', etc., we have established the LMRnFramework.podspec under the LMBusiSDK folder to manage dependencies. It is recommended that you use CocoaPods for local dependencies to reduce your configuration steps.
1.Permission Profile
The SDK needs to apply to iOS for the following system permissions:
1.
NSLocalNetworkUsageDescription
Local Network Lookup Permissions 2.NSLocationWhenInUseUsageDescription
Use geographic location permission (mobile phone obtains WiFi name, iOS 13 needs to confirm that the App has enabled the location permission. iOS 14 needs to confirm that the App has enabled the precise location permission. If the WiFi name is still not obtained after the above configuration, the developer needs to deal with it separately, such as Manually enter the WiFi name)
NSBluetoothAlwaysUsageDescription
Get bluetooth permission
You can quickly add the following configuration in the info.plist file of the host project:
<plist version="1.0">
<key>NSBonjourServices</key>
<array>
<string>_aqara._tcp.</string>
</array>
<key>NSLocalNetworkUsageDescription</key>
<string>Need to use local network to discover device information on LAN</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Allow this app to use bluetooth connection</string>
</dict>
</plist>
2. Copy SDK
Copy the LMBusiSDK folder as a whole to your project directory, at the same level as your Podfile.
3. Configure Podfile
1). Since the React Native source code is managed by a local pod, and some libraries are static library dependencies, in order to reduce unnecessary compilation errors, please configure the following code in the header of your Podfile.
platform :ios, '11.0'
inhibit_all_warnings!
use_modular_headers!
# It is recommended that you comment out use_frameworks. If you must use it in your project, please use use_frameworks! :linkage => :static to specify it as a static reference, so as to avoid rn source code compilation errors
# use_frameworks
use_frameworks! :linkage => :static
2). Add the third-party library that LMRnFramework depends on. If you already have related dependencies, and the versions are different, use the version required by the sdk if it can maintain compatibility
pod 'SSZipArchive', '2.4.3'
pod 'Masonry', '1.1.0'
pod 'AFNetworking', '3.2.0'
pod 'YYModel', '1.0.4'
pod 'MMKV', '1.2.10'
pod 'MMKVCore', '1.2.10'
pod 'SVProgressHUD', '2.2.5'
pod 'SDWebImage','5.9.1'
3).Add pod local dependencies, as told above, the local dependency path defaults that you have copied the LMBusiSDK folder to the directory where the Podfile is located. If you have other placement paths, you can manually modify the local dependency path:
pod 'LMRnFramework', :path => './LMBusiSDK'
# RN
pod 'FBLazyVector', :path => "./LMBusiSDK/RN/node_modules/react-native/Libraries/FBLazyVector",:modular_headers =>false
pod 'FBReactNativeSpec', :path => "./LMBusiSDK/RN/node_modules/react-native/Libraries/FBReactNativeSpec",:modular_headers =>false
pod 'RCTRequired', :path => "./LMBusiSDK/RN/node_modules/react-native/Libraries/RCTRequired",:modular_headers =>false
pod 'RCTTypeSafety', :path => "./LMBusiSDK/RN/node_modules/react-native/Libraries/TypeSafety",:modular_headers =>false
pod 'React', :path => './LMBusiSDK/RN/node_modules/react-native/',:modular_headers =>false
pod 'React-Core', :path => './LMBusiSDK/RN/node_modules/react-native/',:modular_headers =>false
pod 'React-CoreModules', :path => './LMBusiSDK/RN/node_modules/react-native/React/CoreModules',:modular_headers =>false
pod 'React-Core/DevSupport', :path => './LMBusiSDK/RN/node_modules/react-native/',:modular_headers =>false
pod 'React-RCTActionSheet', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/ActionSheetIOS',:modular_headers =>false
pod 'React-RCTAnimation', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/NativeAnimation',:modular_headers =>false
pod 'React-RCTBlob', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/Blob',:modular_headers =>false
pod 'React-RCTImage', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/Image',:modular_headers =>false
pod 'React-RCTLinking', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/LinkingIOS',:modular_headers =>false
pod 'React-RCTNetwork', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/Network',:modular_headers =>false
pod 'React-RCTSettings', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/Settings',:modular_headers =>false
pod 'React-RCTText', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/Text',:modular_headers =>false
pod 'React-RCTVibration', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/Vibration',:modular_headers =>false
pod 'React-Core/RCTWebSocket', :path => './LMBusiSDK/RN/node_modules/react-native/',:modular_headers =>false
pod 'React-cxxreact', :path => './LMBusiSDK/RN/node_modules/react-native/ReactCommon/cxxreact',:modular_headers =>false
pod 'React-jsi', :path => './LMBusiSDK/RN/node_modules/react-native/ReactCommon/jsi',:modular_headers =>false
pod 'React-jsiexecutor', :path => './LMBusiSDK/RN/node_modules/react-native/ReactCommon/jsiexecutor',:modular_headers =>false
pod 'React-jsinspector', :path => './LMBusiSDK/RN/node_modules/react-native/ReactCommon/jsinspector',:modular_headers =>false
pod 'React-callinvoker', :path => "./LMBusiSDK/RN/node_modules/react-native/ReactCommon/callinvoker",:modular_headers =>false
pod 'ReactCommon/turbomodule/core', :path => "./LMBusiSDK/RN/node_modules/react-native/ReactCommon",:modular_headers =>false
pod 'Yoga', :path => './LMBusiSDK/RN/node_modules/react-native/ReactCommon/yoga',:modular_headers =>false
pod 'DoubleConversion', :podspec => './LMBusiSDK/RN/node_modules/react-native/third-party-podspecs/DoubleConversion.podspec',:modular_headers =>false
pod 'glog', :podspec => './LMBusiSDK/RN/node_modules/react-native/third-party-podspecs/glog.podspec',:modular_headers =>false
pod 'Folly', :podspec => './LMBusiSDK/RN/node_modules/react-native/third-party-podspecs/Folly.podspec',:modular_headers =>false
pod 'RNGestureHandler', :path => './LMBusiSDK/RN/node_modules/react-native-gesture-handler',:modular_headers =>false
pod 'RNReanimated', :path => './LMBusiSDK/RN/node_modules/react-native-reanimated',:modular_headers =>false
pod 'React-RCTPushNotification', :path => './LMBusiSDK/RN/node_modules/react-native/Libraries/PushNotificationIOS',:modular_headers =>false
pod 'BVLinearGradient', :path => './LMBusiSDK/RN/node_modules/react-native-linear-gradient',:modular_headers =>false
pod 'react-native-webview', :path => './LMBusiSDK/RN/node_modules/react-native-webview',:modular_headers =>false
pod 'react-native-view-shot', :path => './LMBusiSDK/RN/node_modules/react-native-view-shot',:modular_headers =>false
pod 'react-native-viewpager', :path => './LMBusiSDK/RN/node_modules/@react-native-community/viewpager',:modular_headers =>false
pod 'react-native-background-timer', :path => './LMBusiSDK/RN/node_modules/react-native-background-timer',:modular_headers =>false
pod 'react-native-netinfo', :path => './LMBusiSDK/RN/node_modules/@react-native-community/netinfo',:modular_headers =>false
pod 'react-native-video', :path => './LMBusiSDK/RN/node_modules/react-native-video',:modular_headers =>false
#Permissions
permissions_path = './LMBusiSDK/RN/node_modules/react-native-permissions/ios'
pod 'RNPermissions', :path => './LMBusiSDK/RN/node_modules/react-native-permissions',:modular_headers =>false
pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral.podspec",:modular_headers =>false
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec",:modular_headers =>false
Please refer to the complete copy of the above pod into your Podfile, and execute pod install to install it. So far, you have completed the door lock SDK integration. If there are compilation problems or conflicts, please contact Lumi developer chuancun.cheng- a1147@aqara.com.
5. SDK Usage
For how to use the sdk, please refer to the next document: Door lock SDK usage (iOS)