门锁SDK集成

一、概述

本文主要介绍如何iOS如何集成门锁SDK

二、前提条件

  1. 确认完成准备工作
  2. 本文默认您已安装Xcode 12 以上版本,CocoaPods(https://cocoapods.org) 1.9.0 以上版本;

三、功能特性

3.1 主体功能

  1. 支持Aqara门锁入网
  2. 支持Aqara门锁控制

3.2 SDK大小

依赖库 说明 大小
React Native(0.63.4) React Native框架 12MB
Aqara桥接层 SDK运行所必须的组件 共26MB
其他 SDK运行所必须的组件 13MB
合计 - 51MB

注意:以上均为计算集成SDK编译可执行文件后最大增量,非提供sdk代码包大小,通常情况下,当App的依赖和SDK的第三方依赖有交集时,编译增量会小于51MB。

3.3 支持设备品类

详情查看设备清单

四.集成

4.1 iOS SDK 目录结构

.
├── 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

 内容包含:
 1).Aqara 桥接层 Framework: LMFramework.framework、LMRnFramework.framework
 2).rn 插件包:PKGResource 文件夹
 3).React Native(0.63.4)框架代码:RN 文件夹

4.2 使用方式

由于sdk 依赖了较多的系统库,如'AudioToolbox', 'SystemConfiguration', 'CoreLocation' 等,我们在 LMBusiSDK 文件夹下建立了 LMRnFramework.podspec 管理依赖关系,推荐您使用CocoaPods来进行本地依赖,以便减少您的配置步骤。

1.权限配置

SDK需要向iOS申请以下系统权限:

1.NSLocalNetworkUsageDescription 本地网络查找权限 2.NSLocationWhenInUseUsageDescription 使用地理位置权限(手机获取WiFi名称,iOS 13 需要确认App已开启地理位置权限。 iOS 14 需要确认App开启精确位置权限。 如果上述配置后仍然获取不到WiFi名称,则需要开发者另外处理,比如手动输入WiFi名称)

  1. NSBluetoothAlwaysUsageDescription 获取蓝牙权限

可以在宿主项目的info.plist文件中快捷添加如下配置:

<plist version="1.0">
   <key>NSBonjourServices</key>
   <array>
          <string>_aqara._tcp.</string>
   </array>
   <key>NSLocalNetworkUsageDescription</key>
   <string>需要使用本地网络以发现局域网上的设备信息</string>
   <key>NSBluetoothAlwaysUsageDescription</key>
   <string>允许本App使用蓝牙连接</string>
</dict>
</plist>

2. 拷贝 SDK

将 LMBusiSDK 文件夹,整体复制到您的工程目录下,和您的 Podfile 文件同级

3. 配置 Podfile

1). 由于 React Native 源码使用本地 pod 进行管理,且部分库是静态库依赖,为减少不必要编译报错,请将如下代码配置到您的 Podfile 文件头部

  platform :ios, '11.0'
  inhibit_all_warnings!
  use_modular_headers!

 # 建议您将 use_frameworks 注释掉,如您项目中必须要使用,请用 use_frameworks! :linkage => :static 来指明为静态引用,以免 rn 源码编译报错
 # use_frameworks
 use_frameworks! :linkage => :static

2). 添加 LMRnFramework 依赖的第三方库,如您已有相关的依赖,且版本不同,在能够保持兼容的情况下使用 sdk 所需版本

  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).添加 pod 本地依赖,如上告知,本地依赖路径默认您已经将 LMBusiSDK 文件夹 copy 到 Podfile 文件所在目录,如你有其他放置路径,可手动修改本地依赖路径:

  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_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

请将上述 pod 引用完整的 copy 到你的 Podfile 文件中,执行 pod install 安装即可,至此,您已完成门锁SDK集成,如有编译问题,冲突问题,请联系绿米开发人员 chuancun.cheng-a1147@aqara.com

五、SDK 使用

sdk 使用方式,请参见下篇文档 门锁SDK使用(iOS)

Copyright © 2023 深圳绿米联创科技有限公司 all right reserved,powered by Gitbook文档修改时间: 2024-06-05 16:27:09

results matching ""

    No results matching ""