# Push Message Integration

{% stepper %}
{% step %}

#### Integrate Firebase Project

To use Push Messages in an Android app, you need to configure the integration between the Hackle Workspace and a Firebase project.

{% content-ref url="/pages/EnrApWvzWfZ7innLv6Le" %}
[Android FCM Integration](/en/external-link/crm-channels/fcm-integration.md)
{% endcontent-ref %}
{% endstep %}

{% step %}

#### Integrate Firebase Cloud Messaging SDK

Complete the Android app setup by following the [Firebase Cloud Messaging Installation Guide](https://firebase.google.com/docs/cloud-messaging/android/client).
{% endstep %}

{% step %}

#### Integrate with Hackle SDK

Follow [SDK Integration](/en/development-guide/android.md) to add the Hackle SDK dependency and initialize the SDK.

The push token is automatically registered when the app is built and launched.

{% hint style="info" %}
Once the SDK integration is complete, push token collection, push reception, and push click handling are automatically enabled.
{% endhint %}
{% endstep %}

{% step %}

#### Test Push Messages

**Check Token**

* Use the [User Identifier guide](/en/development-guide/android/android-user-explorer.md) to check the token configured on the Android device.
* Use the [User Profile guide](/en/user-view/user-profile.md) to check the Android push token assigned to a specific user.

**Test Send**

* Follow the [Push Message test send guide](/en/crm-marketing/push-message-guide/create-campaign.md#id-3-1) to verify Push Messages on an Android device.
  {% endstep %}

{% step %}

#### Push Message Reception

When a push is received, an icon is displayed in the status bar and notification center.

* On Samsung Galaxy Android smartphones, the app icon is displayed.
* On standard Android smartphones or simulators, a white circle icon is displayed.
* If you have customized the push icon, the changed icon is displayed.
  {% endstep %}
  {% endstepper %}

## Deep Link Navigation

Hackle Push Messages support deep link navigation on click. When the activity is opened via a Push Message, you can retrieve the opened deep link information as follows.

{% hint style="info" %}
For more details on Android deep links, see the [Android Deep Link Guide](https://developer.android.com/training/app-links/deep-linking).
{% endhint %}

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
import android.app.Activity
import android.content.Intent
import android.os.Bundle

class ExampleActivity : Activity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstance)
        if (intent != null && !intent.dataString.isNullOrEmpty()) {
            //  Do something ...
            println("link : ${intent?.dataString}")
        }
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        setIntent(intent)
        if (intent != null && !intent.dataString.isNullOrEmpty()) {
            //  Do something ...
            println("link : ${intent?.dataString}")
        }
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;

public class ExampleActivity extends Activity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();
        if (intent != null && intent.getDataString() != null) {
            String text = String.format("link : %s", intent.getDataString());
            System.out.println(text);
        }
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        if (intent != null && intent.getDataString() != null) {
            String text = String.format("link : %s", intent.getDataString());
            System.out.println(text);
        }
    }
}
```

{% endtab %}
{% endtabs %}

## Change Push Message Icon

{% hint style="info" %}
This feature is supported in Android SDK 2.57.0 and above.
{% endhint %}

Hackle Push Messages support changing the push icon. By assigning a resource to the pre-defined keys in `AndroidManifest.xml`, you can change the push icon using local app resources.

{% hint style="warning" %}
Due to Google policy, icons with color cannot be set as push icons on standard Android smartphones.
{% endhint %}

{% hint style="info" %}
For more details on small\_icon, large\_icon, and color, see the [Android Push Design Guide](https://developer.android.com/design/ui/mobile/guides/home-screen/notifications?hl=ko#notification-header).
{% endhint %}

<table><thead><tr><th width="451.35546875">key</th><th>Description</th></tr></thead><tbody><tr><td><code>io_hackle_android_default_notification_small_icon</code></td><td>Sets the small icon.</td></tr><tr><td><code>io_hackle_android_default_notification_large_icon</code></td><td>Sets the large icon.</td></tr><tr><td><code>io_hackle_android_default_notification_color</code></td><td>Sets the small icon background color.</td></tr></tbody></table>

#### Example

```xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <application
        android:name=".MainApplication"
        >
       ...
       <meta-data
            android:name="io_hackle_android_default_notification_small_icon"
            android:resource="@drawable/ic_push_small"/>

       <meta-data
            android:name="io_hackle_android_default_notification_large_icon"
            android:resource="@drawable/ic_push_large"/>

       <meta-data
            android:name="io_hackle_android_default_notification_color"
            android:resource="@color/pie" />
       ...
    </application>
</manifest>
```

#### Modify Push Message Icon from the Dashboard

When a push icon is configured in the Dashboard, the large icon of the push is modified.

* If a push icon is configured both as a local resource and in the Dashboard, the icon set in the Dashboard takes precedence.

## Push Channel Support

{% hint style="info" %}
This feature is supported in Android SDK 2.58.0 and above.
{% endhint %}

With Hackle Push Messages, you can receive pushes on a pre-declared channel in the app. If a push is received with a channel ID that does not exist in the app, it is received on the default channel provided by Hackle.

{% hint style="info" %}
For how to add a push channel to your app, see the [Android Developer Documentation](https://developer.android.com/develop/ui/views/notifications/channels?hl=ko).

If you want to display a notification popup when a push is received (as on iOS), set the push channel importance to `IMPORTANCE_HIGH`.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hackle.io/en/development-guide/android/android-push-message-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
