菜单

快速集成

基本信息

名称:热力引擎 ReactNative 插件

开发者名称:汇量云(北京)科技有限公司

ReactNative插件版本号: V1.6.7

所使用SDK版本号:默认使用  最新版本(Android V1.2.9.8,  iOS  v1.3.0.3)   具体SDK的版本 请见Changelog

主要功能:热力引擎是一站式增长分析与发行决策平台,致力于帮助开发者搭建便捷、高效的数据管理中台,洞察业务运营全链路数据,制定更优增长决策。热力引擎支持全球全渠道数据管理,帮助开发者实现归因分析、用户粒度 ROI 分析,能有效衡量渠道价值,为投放和变现策略调优提供全方位数据支持。同时,提供应用内埋点及参数管理,配合多种分析模型与 AB 测试功能,全面还原用户全生命周期旅程,挖掘用户需求及业务增长点,快速验证并推行产品迭代优化,为开发者提升业务运营效率,实现规模化增长赋能。

适用范围:适用于Android 5.0(APILevel 21)及以上的操作系统。

隐私政策链接: https://www.solar-engine.com/privacyPolicy.html

合规指南:详见本页面底部合规指南内容。

 

第一步:获取 Appkey

Appkey 查询路径:资产管理  -  应用管理  -  16位 Appkey(即应用 ID)。

文章图片

第二步:集成 热力引擎 SDK ReactNative模块

对于 React Native 开发的应用,推荐使用 npm 或 yarn 方式集成热力引擎 SDK ReactNative 模块,在您项目的根目录下执行以下命令:  ( 请在您项目的根目录执行下述命令, 且命令完成后, 记得需要在原生项目里更新对远程库的依赖)

 

如果您创建的产品数据存储区域是中国大陆

//使用npm
npm install solarengine-analysis-react-native-cn

//使用yarn
yarn add    solarengine-analysis-react-native-cn

 

 如果您创建的产品数据存储区域是非中国大陆

//使用npm
npm install solarengine-analysis-react-native

//使用yarn
yarn add    solarengine-analysis-react-native

 

注意:React Native 0.60 及以上版本会 autolinking,不需要执行下边的 react-native link 命令。

react-native link solarengine-analysis-react-native

 

 

 若需要使用指定版本的原生SDK

(示例为海外版; 国内版本请将路径中的solarengine-analysis-react-native 改为solarengine-analysis-react-native-cn)

//未指定platform时,同时修改iOS & Android 的SDK版本
node node_modules/solarengine-analysis-react-native/cli.js   set-config  --sdkVersion=1.2.9.8

//指定修改iOS SDK版本
node node_modules/solarengine-analysis-react-native/cli.js   set-config  --sdkVersion=1.3.0.3   --platform=ios

//指定修改Android SDK的版本
node node_modules/solarengine-analysis-react-native/cli.js   set-config  --sdkVersion=1.2.9.8   --platform=android

 

 

 

若要移除"在线参数&AB Test 模块" 插件

node node_modules/solarengine-analysis-react-native/cli.js   set-config  -d

 

 

 若要恢复使用"在线参数&AB Test 模块" 

node node_modules/solarengine-analysis-react-native/cli.js   set-config   -e

 

 

 

Android 配置

添加 maven 仓库配置,具体配置如下:

maven {
       url "https://maven-android.solar-engine.com/repository/se_sdk_for_android/"
 }
maven {
       url "https://developer.huawei.com/repo/"
}
maven { 
        url "https://developer.hihonor.com/repo"
}

 

 

Android 

在项目 AndroidManifest.xml 文件中,加入如下权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

注:android.permission.READ_PHONE_STATE 为非必要权限。如果开发者使用了数据存储区域是中国大陆的 SDK,热力引擎 SDK 并不会要求开发者强制获取此权限。如果开发者获取了此权限且 Android 系统在 6.0 以上,需要动态申请此权限。

 

iOS 

支持Xcode版本:14.0或更高

适用范围:适用于 iOS 11.0 及以上的操作系统

 

Example

Example in Github

 

第四步:预初始化

在应用安装后首次冷启动时,需要先预初始化 SDK,预初始化时 SDK 不采集任何个人信息也不会向热力引擎上报数据

方法示例

export function preInit(appKey: string)

调用示例

import SolarEngine from 'solarengine-analysis-react-native'; //如果您创建的产品数据存储区域不是中国大陆
//import SolarEngine from 'solarengine-analysis-react-native-cn'; //如果您创建的产品数据存储区域是中国大陆

let appKey = ""; 
if (Platform.OS === 'ios') {
   appKey = "your_iOS_appkey";// 替换为您为iOS App申请的appkey
} else if (Platform.OS === 'android') {
   appKey = "your_Android_appkey";// 替换为您为Android App申请的appkey
}    
SolarEngine.preInit(appKey);

第五步:初始化

方法示例

export function initialize(appKey:string,options:SolarEngineInitiateOptions,completion: (result: InitiateCompletionInfo) => void) 

参数说明

参数名 参数含义 参数类型 是否必传
appKey 第一步获取的 appkey string
options SDK 配置项
SolarEngineInitiateOptions
completion
初始化回调函数
InitiateCompletionInfo

 

SolarEngineInitiateOptions 说明 

属性名 属性含义 属性类型 是否必传
config SDK相关相关的配置信息 se_initial_config
remoteConfig "在线参数和A/B 测试模块" 相关的配置信息 RemoteConfig
attribution 接收归因信息的回调函数 attribution
deeplink 接收deeplink信息的回调函数 deeplink
deferredDeeplink
接收延迟deeplink信息的回调函数
deferredDeeplink

 

se_initial_config 说明
属性名 属性含义 属性类型 是否必传
enableLog 是否开启日志打印,默认为关闭状态 boolean
enableDebug 是否开启Debug调试模式,默认为关闭状态 boolean
enable2G 是否允许2G上报数据。默认为false boolean
enableGDPR 是否为GDPR区域,默认为false boolean
enablePersonalizedAd 用户是否允许Google将其数据用于个性化广告,开发者自定义,不设置则默认不上报该字段,只有Android调用有效,iOS没有此字段,无需设置此字段 boolean
enableUserData 用户是否同意将其数据发送到Google,开发者自定义,不设置则默认不上报该字段,只有Android调用有效,iOS没有此字段,无需设置此字段 boolean
enableCoppa 是否支持coppa合规。默认为false boolean
enableKidsApp 是否支持Kids App。默认为false boolean
enableDeferredDeeplink
是否开启延迟Deeplink, 默认false关闭 boolean
android.metaAppId 如果海外开发者需要用到meta归因,此处设置meta appid string
ios.attAuthorizationWaitingInterval iOS首次上报事件支持设置ATT授权等待,最多支持等待120秒. 设置等待后SDK会等用户ATT授权或等待超时才上报Install等事件。
单位:秒
number
ios.caid

仅国内版本SDK使用

string
 
 

RemoteConfig 说明

参数名称 参数含义 参数类型 是否必传
enabled 是否启用在线参数SDK,默认为关闭状态 boolean
mergeType SDK配置合并策略,默认情况下服务端配置跟本地缓存配置合并,具体释义参考下方参数解释,可选字段 RemoteConfigMergeType
customIDProperties 自定义ID,跟用户在后台设置的使用自定义ID匹配对应 Object
customIDEventProperties 自定义ID事件属性值,跟用户在后台设置的使用自定义ID事件属性值匹配对应 Object
customIDUserProperties 自定义ID用户属性值,跟用户在后台设置的使用自定义ID用户属性值匹配对应 Object

RemoteConfigMergeType (参数合并策略) 介绍

参数名称 参数含义
User
app首次启动或版本更新时, 使用服务端配置跟用户默认配置合并,此方法可以清除本地缓存配置
Cache 使用服务端配置跟用户本地已有缓存配置合并,在线参数SDK默认合并策略

 

接收归因信息的回调函数
type attribution = (code:number,attribution?:Object) => void;
 
 
接收deeplink信息的回调函数
type deeplink = (code:number,deepLinkInfo?:DeepLinkInfo) => void;
 
DeepLinkInfo 介绍
参数名称 参数含义 参数类型
sedpLink
跳转参数 string
turlId 7位短链 string
from 链接类型 string
customParams 自定义参数 Object

  

接收延迟deeplink信息的回调函数
 
type deferredDeeplink = (code:number,deferredDeepLinkInfo?:DeferredDeepLinkInfo) => void;
 
DelayDeepLinkInfo 介绍
参数名称 参数含义 参数类型
sedpLink
跳转参数 string
turlId 7位短链 string
sedpUrlscheme 用户在创建deeplink链接时填写的 string
 

 

 

调用示例

async function Initiate(){
  log("Initiate" );

  let appKey = "";
  if (Platform.OS === 'ios') {
     appKey = "your_iOS_appKey";
  } else if (Platform.OS === 'android') {
     appKey = "your_Android_appKey";
  }    
  let config:se_initial_config = buildInitialConfig();
  let remoteConfig:RemoteConfig = buildRemoteConfig();
  let attribution:attribution = buildAttribution();
  let deeplink:deeplink = buildDeeplinkResponse();
  let deferredDeeplink:deferredDeeplink = buildDeferredDeeplinkResponse();

  let initiateOptions:SolarEngineInitiateOptions = {
    config:config,
    remoteConfig:remoteConfig,
    attribution:attribution,
    deeplink:deeplink,
    deferredDeeplink:deferredDeeplink
  }
  SolarEngine.initialize(appKey,initiateOptions,(result:InitiateCompletionInfo) => {
    if (result.success) {
      Alert.alert('SolarEngine SDK Initiate Complete!')
    }
  });

}

 SDK相关相关的配置信息

function buildInitialConfig():se_initial_config{
  let config:se_initial_config = {
    enableLog: true,
    enableDebug: false,
...
  };
  return config;
}

 

"在线参数和A/B 测试模块" 相关的配置信息

function buildRemoteConfig():RemoteConfig{
  let remoteConfig:RemoteConfig = {
    enabled:true,
    mergeType:RemoteConfigMergeType.Cache, 
    customIDProperties:{"name":"name_value"},
    customIDEventProperties:{"age":28},
    customIDUserProperties:{"key":"value"},
  }
  return remoteConfig;
}

 

接收归因信息的回调函数

function buildAttribution():attribution{

  const handleAttribution:attribution = (code:number,attributionInfo?:Object) => {
    console.log("attribution code: " + code);
    if (code === 0){
        console.log("attributionInfo: " + JSON.stringify(attributionInfo));
        const typedValue = attributionInfo as {channel_name : string,
        attribution_time:string, 
        re_data: object};
        console.log("channel_name: " + typedValue.channel_name)
        console.log("attribution_time: " + typedValue.attribution_time)
        const re_dataValue = typedValue.re_data as {install_time:string,
        report_time:string
      }
      if(typedValue.re_data != null){
        console.log("re_data.install_time: " + re_dataValue.install_time)
        console.log("re_data.report_time: " + re_dataValue.report_time)
      }else{
        console.log("re_data: is null" )
      }
    }
  }
  return handleAttribution;
}

 

接收deeplink信息的回调函数

function buildDeeplinkResponse():deeplink{
  const handleDeepLink: deeplink = (code:number,deepLinkInfo?: DeepLinkInfo) => {
    if(code === 0){
      if(deepLinkInfo){
        console.log("deepLinkInfo.sedpLink: " + deepLinkInfo.sedpLink);
      }
    }else{
      console.log("code: " + code);
    }
  };
  return handleDeepLink;
}

 

接收延迟deeplink信息的回调函数

function buildDeferredDeeplinkResponse(): deferredDeeplink {
  const handleDeferredDeeplink: deferredDeeplink = (
    code: number,
    deferreddeeplink?: DeferredDeepLinkInfo
  ) => {
    if (code === 0) {
      if (deferreddeeplink) {
        log('deferreddeeplink.sedpLink: ' + deferreddeeplink.sedpLink);
      }
    } else {
      log('code: ' + code);
    }
  };
  return handleDeferredDeeplink;
}

 

初始化回调  InitiateCompletionInfo  errorCode 码:

101 SDK未预初始化
102 appkey非法
103 context为null(仅Android生效)
104 distinct_id生成失败(仅Android生效)

 

第六步:获取归因回调信息

SDK提供获取归因结果信息接口,开发者可使用归因信息做埋点等逻辑处理

SDK提供两种方式获取归因结果信息

  • 设置归因结果回调:当SDK获取归因结果成功或者失败时会给出回调(此接口为异步回调)
  • 直接获取归因结果:直接从SDK缓存中获取归因结果,SDK还没归因结果时直接返回null(此接口为同步返回)

 

设置归因结果回调

请见上述 接收归因信息的回调函数 部分

 

直接获取归因结果回调

方法示例

export function retrieveAttribution(): Object|null;

示例代码

function retrieveAttribution(){

  let attribution:Object|null = SolarEngine.retrieveAttribution();
  if (attribution != null) {
    log('attribution: ' + JSON.stringify(attribution));

    const object = attribution as { channel_name: string; attribution_time: string};
    log("channel_name:" + object.channel_name);  
    log("attribution_time:" + object.attribution_time);  
  }else{
    log("attribution is null");
  }
}

 

归因code 描述及 归因结果详情见:归因结果详情

最近修改: 2025-08-07Powered by