👨🏼‍💻Android | Audience Based Notifications using HMS Core Analytics Kit

Besir Karaoglu
Huawei Developers
Published in
4 min readAug 2, 2022
Audience Based Notifications

Introduction

Hi,

In this article, we will develop an Android app and send audience based notification to it using HMS Core kits developed by Huawei.

Libraries

  1. Push Kit
  2. Analytics Kit

About HMS Core

HMS Core, based on Huawei devices and the Android platform, is a mobile service framework that opens up a variety of service capabilities to app developers. It provides basic services, such as HUAWEI ID, payments, and Notifications for Huawei end users.

We need to integrate HMS Core to use Analytics Kit and Push Kit in our app.

About Push Kit

Push Kit is a messaging service provided for you. It establishes a messaging channel from the cloud to devices. By integrating Push Kit, you can send messages to your apps on users’ devices in real time. This helps you maintain closer ties with users and increases user awareness of and engagement with your apps. The following figure shows the process of sending messages from the cloud to devices.

Push Service

About Analytics Kit

Analytics Kit is a one-stop user behaviour analysis platform for products such as mobile apps, web apps, quick apps, quick games, and mini-programs. It offers scenario-specific data collection, management, analysis, and usage, helping enterprises achieve effective user acquisition, product optimization, precise operations, and business growth.

Analytics Kit

Integration Process

  1. Integrating HMS Core
  2. Integrating Push Kit
  3. Integrating Analytics Kit
  4. Sending a Notification
  5. Conclusion
  6. References

1.Integrating HMS Core

You can follow the following documentation to integrate HMS Core:

2.Integrating Push Kit

Add the following code to App level build.gradle file to integrate Push Kit. After this, sync project.

Add Service to inside of Application tag on AndroidManifest.xml

Then create Service class.

Add following code to MainActivity. This code needed for getting push token.

Last of it, call this function in onCreate().

3.Integrating Analytics Kit

Add the following code to App level build.gradle file to integrate Analytics Kit.

Sync project and add following code to Main Activity.

Run the app and wait for 1 day. Audiences will be generated in console.

AGC Console Audience Analysis

4.Sending a Notification

Select your project and app from AppGallery Console>My Projects to push a notification. After that, click Push Kit on the left panel under the Grow title.

AGC Console Push Kit

You can see your app’s pushed notifications’ details and reports in this page. Click “Add Notification” to create a notification.

AGC Console Push Kit Add Notification

4.1 Content

Name: This name used to define notification on the AppGallery Connect and doesn’t shown to the users.

Type:Notification messages have a predefined format and do not need to be processed by the client app. Data messages have a custom format and need to be processed by the client app.
Choose notification message for this example.

Title: Title of notification

Body: Content of notification

4.2 Push Scope

AGC Console Push Kit Add Notification

App: App that notification will be send.

Push Scope: Choose Audience in this section.

Audience: Choose the audience that you want to send notification. In this example, choose the New Users.

Click Submit button to send notification to chosen audience. After couple of seconds, notification will be visible on your device.

Output

5.Conclusion

In this article, we did an android application that uses Push Kit and Analytics Kit and we sent audience based notification to it. You can check the References section to more information.

Good day, see you in next articles :)

6.References

--

--