integrationlatestIntegration / Native support
Native support
1. iOS Native support
Build the iOS app and configure the iOS project
-
Add the iOS project dependency files
EgretProxyApi.hEgretProxyApi.mmThinkingSDK.framework
-
Configure Build Settings
- In
Other Linker Flags, add-ObjC
- In
-
Register the Native proxy
- In the
application:didFinishLaunchingWithOptions:method ofAppDelegate.mm, register the Native proxy by calling[EgretProxyApi registExternalInterface:_native]
- In the
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.gradlefile at theProjectlevel
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
- Add the dependencies to the
build.gradlefile underModule
dependencies {
implementation 'cn.thinkingdata.android:ThinkingAnalyticsSDK:2.7.6.1'
}
- Register the Native proxy
- In the
onCreatemethod ofMainActivity, register the Native proxy by callingEgretProxyApi.registExternalInterface(nativeAndroid,this)
- In the
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?

