- Introduction
- Getting Started
- Installation
- Configuration
- Environment Requirements
- Operation Result
- License
HmsAnalyticsKitDemo provides an example of integrating Analytics Kit into an HAP
. It illustrates how to collect predefined events and custom events to improve user engagement and user preference.
Learn more about Analytics Kit.
For details, please refer to the links below:
In this example, we'll demonstrate how to use the Analytics SDK for HarmonyOS by using the Gradle build system.
First, download HmsAnalyticsKitDemo by cloning this repository or downloading the compressed package.
In HUAWEI DevEco Studio, click Open... and select HmsAnalyticsKitDemo.
You can use the gradlew build command to build the project.
Create an app in AppGallery Connect, obtain the agconnect-services.json file, and add the file to your project. In addition, you need to generate the signing certificate fingerprint, add the certificate file to the project, and add the configuration to the build.gradle file. Click here to learn more.
- Use HUAWEI DevEco Studio to open the decompressed project.
- Run the following command in the entry directory:
npm install
- Create an app in AppGallery Connect and obtain the app configuration file agconnect-services.json. In HUAWEI DevEco Studio, switch to the Project view and move the agconnect-services.json file to the entry directory.
- Change bundleName in the config.json file in the entry directory to the HAP name obtained in the first step. In the abilities element, declare the AppGallery Connect provider and replace com.example.myapplication with your app package name.
- Change bundlename in the app.js file in the js directory to the HAP name obtained in the first step.
Hardware:
- A computer (desktop or laptop)
- A Huawei phone used for app debugging
Software:
- Analytics Kit 6.3.0
- HarmonyOS 2.0.0 (API level 4) or later
- HUAWEI DevEco Studio
- JDK version: 1.8 or later
After running the app, you will see the following screen.
Tap TRUE or FALSE to answer the question; tap NEXT to go to the next question; tap POST SCORE to record the obtained score. All information will be uploaded to the console of Analytics Kit. You can use DebugView to view the information in real time.
Tap SETTINGS, and you will see the following screen.
On the screen displayed, you can set your favorite sport. Your configuration will be recorded in the Analytics SDK as a user attribute.
HmsAnalyticsKitDemo is licensed under Apache 2.0.