Exploring HMS App Messaging

Ekrem Hatipoglu
Huawei Developers
Published in
5 min readMay 27, 2020
Huawei Mobile Services — App Messaging

Introduction

HMS App Messaging service helps you engage with your users from within your application. It allows you increase user experience and make happy users. You can use App messaging in many scenarios such as get users to subscribe, show tips in your games, buy an product, show discounts in your commercial apps, share a coupon.

Message Types

Currently, App Messaging supports pop-up, image, and banner messages.

In-App Message Types

Development

Prerequisites

If you want to use the App Messaging service, you must first have a developer account from AppGallery Connect. You need to create an application from your developer account and integrate HMS SDK.

I won’t write these steps so that the article doesn’t lose its purpose and I will assume that it is already integrated in your project.

You can find the guide here.

Note: Make you sure enabled Analytics Kit and entered SHA-256 fingerprint on your project on App Gallery Connect.

Enable App Messaging Service from AppGallery Connect

AppGallery Connect App Messaging Console

Creating an In-App Message from AppGallery Connect

For create an in-app message click to New button after enable service.

Creating In-App Message Steps

We will create pop-up in-app messages in this article.

Step 1: Set style and content

Set your in-app message name and description.

Select the message type from the Type dropdown list. Currently Pop-up, Image, and Banner messages are support.

You can customize your messages by changing title text color, body text color, background color, title, message body.

You should to set Image URL for both the portrait and landscape modes. Image ratio of portrait mode should be 3:2 and for landscape mode should be 1:1 or 3:2.

You can add secondary button on your messages. Currently only two button action is allow. When user click the button you can disable message or redirect a website. Also you can use deep link instead of website. You can find more information in App Linking article.

You can click Preview button to preview your message.

You can preview how your messages will appear in landscape and portrait mode on tablets and phones.

If you’re ready click next button.

Step 2: Select sending target

You can filter your users by defining conditions so your users avoid unnecessary messages.

If you’re ready click next button.

Step 3: Set sending time

You can define start and end time to your messages. ( Now or scheduled )

In-App messages is triggered by events. For example when user open app, click purchase a product or open some spesific page in your app.

App Messaging supports two types of trigger events:

  • Preset events ( AppLaunch, AppOnForeground)
  • Analytics Kit events (Predefined or custom events)

You can easily set the frequency for display the message. A message can display only once, only once every specified number of days, displayed for up to X times each day.

If you’re ready click next button.

  • Step 4: Set conversion events (Optional)

You can associate the in-app message with a conversion event. The conversion relationship will be displayed in statistics.

Before set a conversion event, you need to enable the conversion event.

You have completed all the steps. You can publish the in-app message by clickling Publish.

Displaying an In-App Message on App

There should be done two condition before display a in-app message.

  • The app must be running on the foreground.
  • A user triggers the event upon which an in-app message will be displayed.

Add App messaging library to gradle file (App Level) and sync your project.

Enable fetch and display message. This values already enable by default but App Messaging SDK allow you to change it.

You can track user clicks on your messages.

Also you can show custom views instead of default view. You should need call callback functions right place.

For remove custom view call removeCustomView function.

Test an In-App Message

App Messaging allow test an in-app message when your app is still under tests.

You need add AAID of your device before testing.

How to get AAID?

Application Associated ID (AAID) is a unique anonymous ID for identifying an app on a device. It can be used in scenarios in which the device must be identified, for example, sending a push notification or in-app message to a user device, and reporting a analytics event.

Note: If app is uninstall and install again, app calls the API for deleting the AAID, user restores the device to its factory settings or app data is deleted then AAID may change.

You can obtain AAID like at below.

Call the AGConnect App Messaging.setForce function for get the in-app messages from the AppGallery Connect server by force.

Run

You have completed all the steps. You are ready for testing your messages.

In-App Messages

Conclusion

In this article, you learned what is App messaging service and how to use it.

You can find more information about App messaging below the links.

Guide

That is all.

Thanks.

--

--