Easiest Way to Send App Message in Jetpack Compose

Feyza Ürkut
Huawei Developers
Published in
4 min readOct 2, 2023
Photo by Matthew Hamilton on Unsplash

Hi 👋 In this article I will talk about how we can show messages to the user in various situations from within the application in a project using Jetpack Compose. I will use Huawei’s App Messaging kit for this.

We have a Weather App, and we want to give the user a sweet message based on today’s weather when logging in to the app 😊 Let’s get started!

What is App Messaging?

You’ll be able use App Messaging of AppGallery Connect to send pertinent messages to target clients effectively using your app to empower them to utilize key app capacities or send appealing advancement exercises to upgrade client devotion. App Messaging indeed permits you to customize how your messages see and the way they will be sent, in expansion to default message layouts.

  • App Messaging permits you to send focused on messages based on user behavior in your app to lock in users and empower certain user exercises such as overhaul, browsing, membership, and buy.
  • You’ll be able send pertinent messages to target users effectively using your app to empower them to use key app capacities.
  • To keep in touch with users, you’ll be able use the App Messaging benefit to send focused on messages to users.

App Messaging Service Integration

You need to create a project and add an app to it in AppGallery Connect first. To enabling the Service:

  1. Sign in to AppGallery Connect and click My projects.
  2. Find and click your project.
  3. Go to Grow > App Messaging.
  4. Click Use now in the upper right corner.

Obtaining SDK Configurations

  1. Sign in to AppGallery Connect and click My projects.
  2. Click your project card and select your app from the app drop-down list on the top.
  3. Go to Project settings > General information and download the agconnect-services.json file.

4. Copy the agconnect-services.json file to your app’s module directory in the Android Studio project.

5. Make necessary configurations in gradle files.

settings.gradle
build.gradle (WeatherApp)
build.gradle (:app)

Create Custom Event with Analytics Kit

  1. Under HUAWEI Analytics > Management > Events, after pressing the New > Custom buttons, you can create a custom event by entering the required information. We created two custom event called ‘ColdDay’ and ‘HotDay’.

By using the Huawei Analytics kit, we can trigger our message in any special situation we want. For this, we need to create a custom event on the Analytical kit side.

Create In App Messaging

  1. Go to Grow > App Messaging and click New.

2. Set the name, description, message style and content, including the image and button settings, and click Next. We are using Image layout for our project; you can see the preview in the next screenshot. You can also customize all these features for your own app.

3. While we set the sending time, we must choose the trigger event to display the message. In this project, we use the custom event that we created.

4. Finally, you can use the custom event to trigger in-app message.

Output for HotDay
Output for ColdDay

Conclusion

In this article, I have told you about the App Messaging service, which you can easily integrate into your application and use in many situations. You can also get beautiful and different features by using such kits and services in your application.

Take care of yourselves!

References

--

--