Skip to main content

Native support

Last updated 10/03/2026

1. iOS Native support​

Build the iOS app and configure the iOS project

  • Add the iOS project dependency files

    • EgretProxyApi.h
    • EgretProxyApi.mm
    • ThinkingSDK.framework
  • Configure Build Settings

    • In Other Linker Flags, add -ObjC
  • Register the Native proxy

    • In the application:didFinishLaunchingWithOptions: method of AppDelegate.mm, register the Native proxy by calling [EgretProxyApi registExternalInterface:_native]

2. Android Native support​

Build the Android app and configure the Android project

  • Add the Android project dependency files
    • EgretProxyApi.java
  • Add the following dependency configuration to the build.gradle file at the Project level
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
  • Add the dependencies to the build.gradle file under Module
dependencies {
implementation 'cn.thinkingdata.android:ThinkingAnalyticsSDK:2.7.6.1'
}
  • Register the Native proxy
    • In the onCreate method of MainActivity, register the Native proxy by calling EgretProxyApi.registExternalInterface(nativeAndroid,this)

3. Enable Native support​

When you initialize the SDK, add enableNative: true to config to enable Native support.

// TA SDK configuration object
var config = {
appId: "YOUR_APPID", // Project APP ID
serverUrl: "YOUR_SERVER_URL", // Reporting URL
enableNative: true, // Allow calling Native code
autoTrack: {
appShow: true, // Auto-track the start event
appHide: true, // Auto-track the close event
appClick: true, // Auto-track the click event (native only)
appView: true, // Auto-track the page view event (native only)
appCrash: true, // Auto-track the crash event (native only)
appInstall: true // Auto-track the install event (native only)
}
};

// Initialize
TDAnalytics.init(config);
// Report a simple event named test_event
TDAnalytics.track({
eventName: 'test_event'
});
Was this page helpful?