
Security News
Risky Biz Podcast: AI Agents Are Raising the Stakes for Software Supply Chain Security
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.
openinstall-react-native
Advanced tools
openinstall-react-native 是openinstall官方开发的 React Native 插件,使用该插件可以方便快速地集成openinstall相关功能。
针对使用了 渠道统计 功能中的 广告渠道 效果监测功能的集成,需要参考 补充文档
从1.3.0开始,插件将不再自动初始化,需要用户手动调用初始化接口
在您的项目根目录下执行
npm install openinstall-react-native --save
React Native 0.60 之前
react-native link
Error: Cannot find module 'asap/raw' 则先执行 npm install 再 react-native link 就好了React Native 0.60 之后
如果你的iOS项目是通过Cocoapods来集成React Native(即原生应用集成react-native),可通过如下步骤安装本插件。(注意:使用 pod 就无须执行 react-native link 了,否则会有冲突。)
pod 'openinstall-react-native', :path => '../node_modules/openinstall-react-native'
pod install
(1)使用自动集成脚本集成代码和部分配置
npm run openinstall <yourAppKey> <yourScheme>
举例:
npm run openinstall e7iomw rc8tey
(2)xcode配置(只对iOS)
在 iOS 工程中,如果要使用universal links(通用链接)的拉起功能,需要开启 Associated Domains功能,请到苹果开发者网站,选择Certificate, Identifiers & Profiles,选择相应的AppID,开启Associated Domains。注意:当AppID重新编辑过之后,需要更新相应的mobileprovision证书。(详细配置步骤请看React-Native接入指南),如果已经开启过Associated Domains功能,进行下面操作:
Capabilities 标签Associated Domains 开关$(SRCROOT)/../node_modules/openinstall-react-native/ios/RCTOpenInstall
请在 react native 端入口 js 文件中(例如 App.js 文件)导入:
import OpeninstallModule from 'openinstall-react-native'
确保用户同意《隐私政策》之后,再初始化 openinstall。参考 应用合规指南
OpeninstallModule.init()
iOS用户使用插件1.3.0之前的版本升级到新版本,需要参考新的手动集成文档修改
如果只需要快速下载功能,无需其它功能(携带参数安装、渠道统计、一键拉起),完成sdk初始化即可(自动集成方式或手动集成方式)
通常在 componentDidMount 中注册唤醒回调监听
componentDidMount() {
//该方法用于监听app通过univeral link或scheme拉起后获取唤醒参数
this.receiveWakeupListener = map => {
if (map) {
//do your work here
}
Alert.alert('唤醒参数', JSON.stringify(map))
}
OpeninstallModule.addWakeUpListener(this.receiveWakeupListener)
}
componentWillUnMount() {
OpeninstallModule.removeWakeUpListener(this.receiveWakeupListener)//移除监听
}
在需要获取安装参数的位置,导入插件:
import OpeninstallModule from 'openinstall-react-native'
调用如下方法,可重复获取(理论上可在任意位置获取安装参数):
OpeninstallModule.getInstall(10, map => {
if (map) {
//do your work here
}
Alert.alert('安装参数', JSON.stringify(map))
})
SDK 会自动完成访问量、点击量、安装量、活跃量、留存率等统计工作。
在用户注册成功时,可调用该方法上报注册事件,需要导入'openinstall-react-native'
OpeninstallModule.reportRegister()
两个参数分别为 效果点的ID,string类型,以及 效果点的值,为整型,示例:
OpeninstallModule.reportEffectPoint('effect_test',1)
Android 平台
(1)针对广告平台接入,新增配置接口,在调用 init 之前调用。参考 广告平台对接Android集成指引
/**
* adEnabled 为 true 表示 openinstall 需要获取广告追踪相关参数,默认为 false
* oaid 为 null 时,表示交由 openinstall 获取 oaid, 默认为 null
* gaid 为 null 时,表示交由 openinstall 获取 gaid, 默认为 null
*/
OpeninstallModule.config(true, "通过移动安全联盟获取到的 oaid", "通过 google api 获取到的 advertisingId");
例如: 开发者自己获取到了 oaid,但是需要 openinstall 获取 gaid,则调用代码为
// f32a09dc-3312-d43e-6583-62fac13f33ae 是通过移动安全联盟获取到的 oaid
OpeninstallModule.config(true, "f32a09dc-3312-d43e-6583-62fac13f33ae", null);
(2)为了精准地匹配到渠道,需要获取设备唯一标识码(IMEI),因此需要做额外的权限申请
在 AndroidMainfest.xml 配置文件中添加需要申请的权限 <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
(3)申请权限并初始化
导入包
import { PermissionsAndroid } from 'react-native'
在 App.js 的 componentDidMount 方法中初始化,并且在初始化之前申请权限
this.receiveWakeupListener = map => {
Alert.alert('唤醒参数', JSON.stringify(map))
}
var permission = PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE;
PermissionsAndroid.request(permission)
.then(granted => {
if (granted === PermissionsAndroid.RESULTS.GRANTED){
//权限获取成功
}else{
//权限获取失败
}
OpeninstallModule.config(true, null, null);
OpeninstallModule.init();
OpeninstallModule.addWakeUpListener(this.receiveWakeupListener)
})
iOS 平台
使用第三方插件获取iOS idfa 并传给 openinstall 插件进行初始化
var options = {adid: "通过第三方插件获取的 iOS idfa"}
OpeninstallModule.init(options);
FAQs
openinstall sdk plugin for react-native
The npm package openinstall-react-native receives a total of 130 weekly downloads. As such, openinstall-react-native popularity was classified as not popular.
We found that openinstall-react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.