Skip to content

Example application

Alexander Boldyrev edited this page Oct 23, 2024 · 4 revisions

How to run example application

Example application source

Prepare application configuration in portal

As the first step, you will need to have an Application with Push enabled set up in Infobip Portal for your account. If you already have it, then you can skip this section, otherwise:

  1. Prepare your Huawei Messaging credentials to get HMS App ID (Sender ID) and API Key.
  2. Prepare your Infobip account (https://portal.infobip.com/push/applications) to get your Application Code:
    1. Create new application on Infobip Push portal.
    2. Navigate to your Application where you will get the Application Code.
    3. Mark the "Available on Huawei Sandbox" checkbox.
    4. Insert previously obtained API Key.

Run example application in Android Studio

Clone SDK repository and open the project in Android Studio. Go to infobip-mobile-messaging-huawei-demo module and add HMS App ID and Application Code from previous step to strings.xml:

<resources>
    <string name="app_id">SENDER ID</string>
    <string name="infobip_application_code">APPLICATION CODE</string>
    ...
</resources>

infobip-mobile-messaging-huawei-demo is an example Android application for Mobile SDK and it has multiple product flavours configured for different use-cases.

Product flavour Description
push application with simple layout which receives messages sent from the portal or through API
deeplink application which handles deeplinks in messages as described in: How can I use "deeplink" from custom payload to land user to a particular app page?
web application which receives push messages and opens web view on notification tap as described in: How to open application webView on message tap?
chat application with simple chat view layout where you can send messages and receive messages from API
cryptorMigration application which demonstrates how to migrate from old ECB cryptor

In order to run one of the flavours, select {flavour}Debug or {flavour}Release configuration for infobip-mobile-messaging-huawei-demo in Build Variants menu in Android Studio and run it as Android application on any Android device or emulator.

Running chat example

Use chatDebug or chatRelease for debug and release configurations accordingly. Once application starts, there is a button that leads you to the chat activity where you'll be able to send and receive messages.