1. iOS Native Support

1.1. Export Xcode Project

  • In LayaAir IDE, select File-> Build and Release, then choose "Target Platform" as iOS, and click "Publish Version" to export the Xcode project.

After exporting the Xcode project, click "Open Output Directory" to open the directory where the exported project is located.

1.2. Build iOS Project

  • Open menu -> Tools -> app build interface.
  • Select iOS for project type, and check Single Edition.
  • Publish Version.

1.3. Configure iOS Project

  • Open the iOS project generated by the build and release with Xcode.

  • Open the LayaAir SDK and add all the files in the iOS plugin directory of the SDK to the exported project to complete the integration of the iOS project.

 

2. Android Native Support

2.1. Build Android Project

  • Open menu -> File -> Build and Release
  • Choose target platform  Android
  • checkstand-alone
  • Version Release

2.2. Configure Android Project

  • Open the generated android_studio project with Android Studio
  • Put the dependency file "SensorsAnalyticsLayaModule.java" into the demo directory

  • Add Android SDK dependencies in the  Module under the  build.gradle file
implementation('com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.7.0')
CODE

3. Enable Native Support

When initializing the SDK, configure Native related parameters in  config > app:

From  GitHub dist directory get LayaAir SDK source code, Refer to the integration documentation.

//引入 SDK import sensorsData from "./sensors-laya.min.esm.js"; //配置对象 var config = { server_url: '数据上报地址', show_log: true, super_properties: { superKey: 'value' }, app: { app_start: true,// 自动采集 $AppStart app_end: true // 自动采集 $AppEnd } } //初始化 sensorsData.init(config); // 上报一个事件,事件名为 test sensorsData.track( 	'test', //事件名称 	{demo:'举个例子'} //事件属性 );
JS