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.
Access Path: Asset Management - App Management - AppKey
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-cnIf 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-nativeNote:
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-nativeIf 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=androidIn 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.
Suitable for iOS 11.0 and above.
For Xcode versions, 14.0 and above are supported.
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
];
}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);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;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.
| Method | Data Type | Required | Description |
|---|---|---|---|
| enableAttribution | boolean | No | Whether 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. |
| enableAnalytics | boolean | No | Whether 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. |
It controls non-core features like the SDK's running mode, debug logs, network policy, authorization wait, and deferred deep linking.
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| enableLog | boolean | No | Whether to enable local debug logs. Disabled by default. | config.enableLog = true; |
| enableDebug | boolean | No | Whether to enable debug mode. Disabled by default. | config.enableDebug = true; |
| enable2G | boolean | No | Whether to report events over a 2G network. Disabled by default. | config.enable2G = true; |
| enableGDPR | boolean | No | Whether 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; |
| enableCoppa | boolean | No | Whether to support the Children’s Online Privacy Protection Act (COPPA). Set to true when complying with COPPA regulations. | config.enableCoppa = true; |
| enableKidsApp | boolean | No | Whether to mark the app as a Kids App. Set to true for apps directed at children. | config.enableKidsApp = true; |
| enableDeferredDeeplink | boolean | No | Whether to enable the deferred deeplink feature. Default is false (disabled). | config.enableDeferredDeeplink = true; |
| enableSeparatedAttribution | boolean | No | Whether to enable the new attribution feature to obtain attribution results faster. | config.enableSeparatedAttribution = true; |
| ios.attAuthorizationWaitingInterval | number | No | ATT authorization waiting time in seconds (maximum 120 seconds), used for the first event report. | config.ios.attAuthorizationWaitingInterval = 30; |
| android.metaAppId | string | No | Meta AppID required for overseas Meta attribution. | config.android.metaAppId = 'your_meta_appid'; |
| android.enablePersonalizedAd | boolean | No | When 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.enableUserData | boolean | No | When 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.supportMultiProcess | boolean | No | Whether to enable multi-process support (v1.2.9.4+). Default is false. | config.android.supportMultiProcess = true; |
| harmony.authorizationTimeout | number | No | The 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; |
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.
| Method | Type | Required | Description | Example |
|---|---|---|---|---|
| enableIPV6 | boolean | No | Whether to collect the IPv6 address. Set to false to disable collection. Default is true (collect). | config.enableIPV6=true; |
| enableLanguage | boolean | No | Whether to collect the device language. Set to false to disable collection. Default is true (collect). | config.enableLanguage=true; |
| enableLocale | boolean | No | Whether to collect the device’s region. Set to false to disable collection. Default is true (collect). | config.enableLocale=true; |
| enableTimeZone | boolean | No | Whether to collect the device’s time zone. Set to false to disable collection. Default is true (collect). | config.enableTimeZone=true; |
| enableScreenWH | boolean | No | Whether to collect screen width/height. Set to false to disable collection. Default is true (collect). | config.enableScreenWH=true; |
| enableDensity | boolean | No | Whether to collect screen density. Set to false to disable collection. Default is true (collect). | config.enableDensity=true; |
| enableNetworkType | boolean | No | Whether to collect network status. Set to false to disable collection. Default is true (collect). | config.enableNetworkType=true; |
| enableUA | boolean | No | Whether to collect the User Agent (UA). Set to false to disable collection. Default is true (collect). | config.enableUA=true; |
| enableOAID | boolean | No | Whether to collect OAID. Set to false to disable collection. Default is true (collect). | config.enableOAID=true; |
| harmony.enableODID | boolean | No | Whether to collect ODID. Set to false to disable collection. Default is true (collect). | config.harmony.enableODID=true; |
| harmony.enableAAID | boolean | No | Whether to collect AAID. Set to false to disable collection. Default is true (collect). | config.harmony.enableAAID=true; |
| android.isImeiEnabled | boolean | No | Whether to allow IMEI collection. Set to false to disable collection. | config.android.isImeiEnabled=true; |
| android.isAndroidIDEnabled | boolean | No | Whether to allow AndroidID collection. Set to false to disable collection. | config.android.isAndroidIDEnabled=true; |
Function
export function initialize(appKey:string,options:SolarEngineInitiateOptions,completion: (result: InitiateCompletionInfo) => void) | Parameter | Description | Type | Required |
|---|---|---|---|
| appKey | Appkey you obtained in Step 1 | string | Yes |
| options | SolarEngine SDK configuration | SolarEngineInitiateOptions | Yes |
| completion | Initialization callback info | InitiateCompletionInfo | Yes |
SolarEngineInitiateOptions description:
| Parameter | Description | Type | Required |
|---|---|---|---|
| config | SDK related config | se_initial_config | no |
| remoteConfig | A/B Testing and Remote Config related config | RemoteConfig | no |
| attribution | To receive attribution callback information | attribution | no |
| deeplink | To receive deeplink callback information | deeplink | no |
| deferredDeeplink | To receive deferred deeplink callback information | deferredDeeplink | no |
RemoteConfig description:
| Parameter | Description | Type | Required |
|---|---|---|---|
| enabled | Whether to enable Remote Config SDK (default false) | boolean | YES |
| mergeType | SDK configuration merge strategy: By default, server configurations are merged with local cached configurations. For specific definitions, please refer to the explanation below. | RemoteConfigMergeType | NO |
| customIDProperties | Custom ID, corresponding to those set on SE dashboard | Object | NO |
| customIDEventProperties | Custom ID event properties, corresponding to those set on SE dashboard | Object | NO |
| customIDUserProperties | Custom ID user properties, corresponding to those set on SE dashboard | Object | NO |
RemoteConfigMergeType description:
| Parameter | Description |
|---|---|
| User | When 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. |
| Cache | Merge 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
| Parameter | Description | Type |
|---|---|---|
| sedpLink | redirect parameters | string |
| turlId | 7-character short link | string |
| from | link type | string |
| customParams | custom parameters | Object |
To receive deferred deeplink callback information:
type deferredDeeplink = (code:number,deferredDeepLinkInfo?:DeferredDeepLinkInfo) => void;DeferredDeepLinkInfo
| Parameter | Description | Type |
|---|---|---|
| sedpLink | redirect parameters | string |
| turlId | 7-character short link | string |
| sedpUrlscheme | The URL Scheme you input when creating deep linking | string |
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:
| 101 | SDK is not pre-initialized |
| 102 | illegal appkey |
| 103 | null context(Android only) |
| 104 | distinct_id creation failed(Android only) |
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:
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.
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