Menu

Quick Access

Basic Information

Plugin Name: SolarEngine React Native Plugin

Developer: Huiliang Cloud (Beijing) Technology Co., Ltd.

Plugin Version:  V1.7.2

Please check Changelog to see the lastest SDK versions supported (Default iOS 1.3.0.3, Android  1.3.1.0).

Description: SolarEngine (SE) is an all-in-one mobile app growth analytics and data intelligence platform. It supports data management across global channels, assisting developers to monitor every stage of business development. With our attribution tracking and user-granular ROI analysis, you'll be able to measure the true value every channel creates and optimize future growth strategies. SE also offers various analysis models and A/B testing feature to help fully visualize the user journey, identify potential pain points, implement targeted product enhancements and ultimately drive large-scale app growth.

Privacy Policy: https://www.solar-engine.com/privacyPolicyEN.html

Note:

The SolarEngine SDK supports Android 5.0(APILevel 21) and above.

Step 1: Get AppKey

Access Path:   Asset Management - App Management - AppKey

Step 2: Start Integration

       For applications developed with React Native, it is recommended to integrate SolarEngine SDK React Native plugin using either npm or yarn. Please execute the following command in your project's root directory.

       After the commands are completed, don't forget to update the dependencies for the remote library in the native project.

       If your product data is stored in China Mainland,

// If you use npm
npm install solarengine-analysis-react-native-cn

// If you use yarn
yarn add    solarengine-analysis-react-native-cn

       If your product data is stored in Non China Mainland,

// If you use npm
npm install solarengine-analysis-react-native

// If you use yarn
yarn add    solarengine-analysis-react-native

Note:

       React Native version 0.60 and above supports autolinking, so you do not need to execute the following react-native link command.

react-native link solarengine-analysis-react-native


If you need to specify the version of native SDK,

(Example is for Non China Mainland version; for China Mainland, please replace solarengine-analysis-react-native with solarengine-analysis-react-native-cn in the path.)

// Modify both Android and iOS versions if platform not specified
node node_modules/solarengine-analysis-react-native/cli.js   set-config  --sdkVersion=1.3.1.0

// Modify the iOS SDK version
node node_modules/solarengine-analysis-react-native/cli.js   set-config  --sdkVersion=1.3.1.2   --platform=ios

// Modify the Android SDK version
node node_modules/solarengine-analysis-react-native/cli.js   set-config  --sdkVersion=1.3.1.4   --platform=android


Android Configuration

       In the build.gradle file at the root directory of your project, add the Maven repository configuration. The specific configuration is as follows:

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"
}

Add the following permissions in the project's AndroidManifest.xml file:

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

      Note:

       The permission android.permission.READ_PHONE_STATE is not necessary. If you're using China Mainland SDK, it's not required to forcibly obtain this permission. If you do acquire this permission and the Android system is above 6.0, please request this permission dynamically.


iOS Configuration

       Suitable for iOS 11.0 and above.

       For Xcode versions, 14.0 and above are supported.


HarmonyOS Configuration

Integrate SolarEngine HarmonyOS SDK via: SolarEngine HarmonyOS SDK Quick Access
SolarEngine React Native Plugin v1.7.1 and above supports HarmonyOS event tracking.

       Drag the solarengine folder located under the cpp and ets directories within the harmony directory of the solarengine-analysis-react-native-cn component.

       Drop them into the src/main/cpp and src/main/ets directories of the HarmonyOS project generated by React Native respectively.

【Configuration Modifications】

1.  Add the newly added glue code in CMakeLists.txt

   Define the solarengine cpp path in entry/src/main/cpp/CMakeLists.txt and add it to the compilation build:

cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")

set(RNOH_CPP_DIR "${OH_MODULE_DIR}/@rnoh/react-native-openharmony/src/main/cpp")
set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
add_compile_definitions(WITH_HITRACE_SYSTRACE)
set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use

add_subdirectory("${RNOH_CPP_DIR}" ./rn)

add_library(rnoh_app SHARED
    "./PackageProvider.cpp"
    "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
    "./solarengine/SolarengineAnalysisReactNative.cpp" # add manually
)

target_link_libraries(rnoh_app PUBLIC rnoh)

2. Create the cpp side package object: SolarEnginePackage in entry/src/main/cpp/PackageProvider.cpp

#include "RNOH/PackageProvider.h"
#include "solarengine/SolarEnginePackage.h" // add manually

using namespace rnoh;

std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
    return {
        std::make_shared<SolarEnginePackage>(ctx) // add manually
    };
}

3. Add the method to create SolarEnginePackage in entry/src/main/ets/RNPackagesFactory.ets

import { RNPackageContext, RNPackage } from '@rnoh/react-native-openharmony/ts';
import { SolarEnginePackage } from './solarengine/SolarEnginePackage'; // add manually

export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
  return [
    new SolarEnginePackage(ctx) // add manually
  ];
}

Examples

Example in Github


Step 3: Pre-Initialize SDK

       When the application is first launched after install, the SDK is pre-initialized. During pre-initialization, the SDK does not collect any personal information or report data to SolarEngine.

Function

export function preInit(appKey: string)

Sample Code

import SolarEngine from 'solarengine-analysis-react-native'; // If your app is published globally
import SolarEngine from 'solarengine-analysis-react-native-cn'; // If your app is published only in China Mainland

let appKey = ""; 
if (Platform.OS === 'ios') {
   appKey = "your_iOS_appkey";// Input your own iOS appkey
} else if (Platform.OS === 'android') {
   appKey = "your_Android_appkey";//  Input your own Android appkey
}    
SolarEngine.preInit(appKey);


Step 4: se_initial_config (optional)

se_initial_config parameter description

   This configuration class is used to fine‑tune service capabilities and data‑collection behaviors during SDK initialization. Its parameters fall into three categories: core‑feature switches, auxiliary feature switches, and data collection switches.

   The config returned by this method is optional. If not set, the default values will be applied.

import SolarEngine from 'solarengine-analysis-react-native';
let config = {};
config.enableLog = true;

1. Core Feature Switches

   It controls the enablement or disablement of core SDK capabilities, directly determining whether core services such as attribution and analytics take effect.

   Note: Disabling relevant core feature switches will disrupt the data reporting. You will no longer be able to fully utilise all functions within SolarEngine dashboard.

MethodData TypeRequiredDescription
enableAttributionbooleanNoWhether to enable SolarEngine attribution service. Enabled by default. Disabling it will turn off all attribution relevant capabilities, including attribution results, deferred deeplinks and deeplinks, etc. If the analytics service is disabled at the same time, the SDK will stop reporting all data.
enableAnalyticsbooleanNoWhether to enable SolarEngine analytics service. Enabled by default. Disabling it can make all analytics features unavailable, such as A/B testing and online parameter. If the attribution service is disabled at the same time, the SDK will stop reporting all data.

2. Auxiliary Feature Switches

   It controls non-core features like the SDK's running mode, debug logs, network policy, authorization wait, and deferred deep linking.

ParameterTypeRequiredDescriptionExample
enableLogbooleanNoWhether to enable local debug logs. Disabled by default.config.enableLog = true;
enableDebugbooleanNoWhether to enable debug mode. Disabled by default.config.enableDebug = true;
enable2GbooleanNoWhether to report events over a 2G network. Disabled by default.config.enable2G = true;
enableGDPRbooleanNoWhether to set the region to GDPR. Operations in the EU must comply with GDPR. Set to true when users refuse to collect sensitive information. Disabled by default (to collect).config.enableGDPR = true;
enableCoppabooleanNoWhether to support the Children’s Online Privacy Protection Act (COPPA). Set to true when complying with COPPA regulations.config.enableCoppa = true;
enableKidsAppbooleanNoWhether to mark the app as a Kids App. Set to true for apps directed at children.config.enableKidsApp = true;
enableDeferredDeeplinkbooleanNoWhether to enable the deferred deeplink feature. Default is false (disabled).config.enableDeferredDeeplink = true;
enableSeparatedAttributionbooleanNoWhether to enable the new attribution feature to obtain attribution results faster.config.enableSeparatedAttribution = true;
ios.attAuthorizationWaitingIntervalnumberNoATT authorization waiting time in seconds (maximum 120 seconds), used for the first event report.config.ios.attAuthorizationWaitingInterval = 30;
android.metaAppIdstringNoMeta AppID required for overseas Meta attribution.config.android.metaAppId = 'your_meta_appid';
android.enablePersonalizedAdbooleanNoWhen running Google ads in the EU, pass in the user’s consent result regarding whether Google can use their data for personalized advertising.config.android.enablePersonalizedAd = true;
android.enableUserDatabooleanNoWhen running Google ads in the EU, pass in the user’s consent result regarding whether they agree to send their data to Google.config.android.enableUserData = true;
android.supportMultiProcessbooleanNoWhether to enable multi-process support (v1.2.9.4+). Default is false.config.android.supportMultiProcess = true;
harmony.authorizationTimeoutnumberNoThe maximum duration to wait for the user’s authorization result, in milliseconds. Uses the SDK’s internal wait time by default.config.harmony.authorizationTimeout = 120;

3. Data Collection Switches

    It controls whether data such as IPv6, OAID and UA is collected.

    Note: Disabling corresponding data collection parameters will impair attribution and analytics services, and you will not be able to use relevant functions normally on SolarEngine dashboard.

MethodTypeRequiredDescriptionExample
enableIPV6booleanNoWhether to collect the IPv6 address. Set to false to disable collection. Default is true (collect).config.enableIPV6=true;
enableLanguage booleanNoWhether to collect the device language. Set to false to disable collection. Default is true (collect).config.enableLanguage=true;
enableLocalebooleanNoWhether to collect the device’s region. Set to false to disable collection. Default is true (collect).config.enableLocale=true;
enableTimeZonebooleanNoWhether to collect the device’s time zone. Set to false to disable collection. Default is true (collect).config.enableTimeZone=true;
enableScreenWHbooleanNoWhether to collect screen width/height. Set to false to disable collection. Default is true (collect).config.enableScreenWH=true;
enableDensitybooleanNoWhether to collect screen density. Set to false to disable collection. Default is true (collect).config.enableDensity=true;
enableNetworkTypebooleanNoWhether to collect network status. Set to false to disable collection. Default is true (collect).config.enableNetworkType=true;
enableUAbooleanNoWhether to collect the User Agent (UA). Set to false to disable collection. Default is true (collect).config.enableUA=true;
enableOAIDbooleanNoWhether to collect OAID. Set to false to disable collection. Default is true (collect).config.enableOAID=true;
harmony.enableODIDbooleanNoWhether to collect ODID. Set to false to disable collection. Default is true (collect).config.harmony.enableODID=true;
harmony.enableAAIDbooleanNoWhether to collect AAID. Set to false to disable collection. Default is true (collect).config.harmony.enableAAID=true;
android.isImeiEnabledbooleanNoWhether to allow IMEI collection. Set to false to disable collection.config.android.isImeiEnabled=true;
android.isAndroidIDEnabledbooleanNoWhether to allow AndroidID collection. Set to false to disable collection.config.android.isAndroidIDEnabled=true;


Step 5: Initialize SDK

Function

export function initialize(appKey:string,options:SolarEngineInitiateOptions,completion: (result: InitiateCompletionInfo) => void) 
ParameterDescriptionTypeRequired
appKeyAppkey you obtained in Step 1stringYes
optionsSolarEngine SDK configurationSolarEngineInitiateOptionsYes
completionInitialization callback infoInitiateCompletionInfoYes


SolarEngineInitiateOptions description:

ParameterDescriptionTypeRequired
configSDK related configse_initial_config no
remoteConfigA/B Testing and Remote Config related configRemoteConfigno
attributionTo receive attribution callback informationattributionno
deeplinkTo receive deeplink callback informationdeeplinkno
deferredDeeplinkTo receive deferred deeplink callback informationdeferredDeeplinkno


RemoteConfig description:

ParameterDescriptionTypeRequired
enabledWhether to enable Remote Config SDK (default false)booleanYES
mergeTypeSDK configuration merge strategy:
By default, server configurations are merged with local cached configurations. For specific definitions, please refer to the explanation below.
RemoteConfigMergeTypeNO
customIDPropertiesCustom ID, corresponding to those set on SE dashboardObjectNO
customIDEventPropertiesCustom ID event properties, corresponding to those set on SE dashboardObjectNO
customIDUserPropertiesCustom ID user properties, corresponding to those set on SE dashboardObjectNO


RemoteConfigMergeType description:

ParameterDescription
UserWhen the app is first launched or updated, the server configuration is merged with the user's default configuration. This method can clear the local cached configuration.
CacheMerge the server configuration with the user's existing local cached configuration; this is the default merge strategy for the Remote Config SDK.


To receive attribution callback information:

type attribution = (code:number,attribution?:Object) => void;

To receive deeplink callback information:

type deeplink = (code:number,deepLinkInfo?:DeepLinkInfo) => void;

DeepLinkInfo

ParameterDescriptionType
sedpLinkredirect parametersstring
turlId7-character short linkstring
fromlink typestring
customParamscustom parametersObject


To receive deferred deeplink callback information:

type deferredDeeplink = (code:number,deferredDeepLinkInfo?:DeferredDeepLinkInfo) => void;


DeferredDeepLinkInfo

ParameterDescriptionType
sedpLinkredirect parametersstring
turlId7-character short linkstring
sedpUrlschemeThe URL Scheme you input when creating deep linkingstring


Sample Code

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 related config

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


Remote Config & A/B Testing related config

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


To receive attribution callback information:

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;
}


To receive deeplink callback information:

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;
}


To receive deferred deeplink callback information:

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 error codes:

101SDK is not pre-initialized
102illegal appkey
103null context(Android only)
104distinct_id creation failed(Android only)


Step 5: Get Attribution Results

       The SDK provides an interface to obtain attribution result information, which developers can use for tracking and other logical processing.

       The SDK offers two methods to retrieve attribution result information:

  1. Set Attribution Result Callback: When the SDK successfully retrieves the attribution result or fails to do so, it will provide a callback (this is an asynchronous callback).
  2. Directly Get Attribution Result: Retrieve the attribution result directly from the SDK's cache. If the SDK does not yet have an attribution result, it will return null (this is a synchronous return).

[New] Set Attribution Result Callback

Sample Code

SolarEngine.initialize(
  APP_KEY,
  {
    config: {
      enableSeparatedAttribution: true,
    },

    uaAttribution: (code, data) => {
      if (code === 0) {
        console.log('UA attribution successful:', data);
      } else {
        console.log('UA attribution failed:', code);
      }
    },

    reAttribution: (code, data) => {
      if (code === 0) {
        console.log('RE attribution successful:', data);
      } else {
        console.log('RE attribution failed:', code);
      }
    },
  },
  result => {
    console.log('Initialization Result:', result);
  }
);
Note: When using the callback mode to receive attribution results, the attribution listener must be configured before the initialize phase is completed. Setting the listener after initialization will result in inaccurate attribution results. Please refer to the code example above.

[New] Get Attribution Data Directly

Note: The method to directly retrieve attribution results returns local cache. If the local cache has not yet been generated, the attribution result will be {}.

Sample Code

// Get UA Attribution Result
const uaAttribution = SolarEngine.getUAAttributionData();
// Get Re-engagement Attribution Result
const reAttribution = SolarEngine.getREAttributionData();


Attribution error code descriptions and detailed attribution results can be found in:

https://help.solar-engine.com/en/docs/SDK-Attribution-Result-Details



Previous
React Native
Next
Optional Features
Last modified: 2026-09-20Powered by