安装
安装包
1. 配置 npm registry
在项目根目录创建 .npmrc 文件:
@qitech:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=NPM_TOKEN_SENT_BY_QI_TECH
请将 NPM_TOKEN_SENT_BY_QI_TECH 替换为支持团队提供的 token。如果您尚未收到 token,请联系 suporte.caas@qitech.com.br。
2. 安装依赖
yarn add @qitech/react-native-caas
3. 导入
import {
CAAS_ENVIRONMENT,
CAAS_FONT_FAMILY,
CAAS_LOG_LEVEL,
FACE_RECON_AUDIO_CONFIGURATION,
FACE_RECON_ERROR,
startFaceRecon,
} from '@qitech/react-native-caas';
Android 配置
1. QI Tech Maven 仓库
在项目级 build.gradle 中添加 QI Tech 的 Maven 仓库:
allprojects {
repositories {
maven { url 'https://sdks.qitech.com.br/' }
...
}
}
2. AdMob
在 AndroidManifest.xml 中添加以下代码以初始化 AdMob 服务:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="<ADMOB_APP_ID>"/>
如果您还没有 ADMOB_APP_ID,请联系 suporte.caas@qitech.com.br。
iOS 配置
1. 相机权限
在应用的 Info.plist 中添加 NSCameraUsageDescription 条目,说明应用需要访问相机的原因:
<key>NSCameraUsageDescription</key>
<string>我们需要使用相机拍摄您的自拍照</string>
2. QI Tech iOS 仓库 source
在 Podfile 顶部添加以下 source:
source 'https://cdn.cocoapods.org/'
source 'https://github.com/QITechSDKs/iOS.git'
3. 静态 framework
仅在使用 低于 26 版本 的 Xcode 时需要:
use_frameworks! :linkage => :static
注意
Flipper 无法与 use_frameworks! 共存。如果 Podfile 中存在 use_flipper() 调用,请将其移除。
4. 模块稳定性
Datadog 依赖要求启用 BUILD_LIBRARY_FOR_DISTRIBUTION。请添加下面的 post_install 代码块(或合并到已有的 post_install 中):
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['DatadogCore', 'DatadogInternal', 'DatadogCrashReporting', 'DatadogLogs'].include?(target.name)
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.5'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
end
5. 安装 pod
cd ios && pod install
注意
如果您的应用已使用 Datadog,请使用 3.x 主版本中的最新版本。如果使用 MLKit 的 FaceDetection,请使用 8.x 主版本中的最新版本。
Expo 配置
该包内置了 Expo config plugin,可自动应用上述所有 iOS 和 Android 原生配置。在 app.json 中:
{
"expo": {
"plugins": ["@qitech/react-native-caas"]
}
}
然后执行 prebuild 以应用原生改动:
npx expo prebuild