Push Message

<br />

> 📘 Supported SDK Version
>
> This feature is supported in Android SDK version 2.33.0 and above.

# 1\. Integrate Firebase Project

To use push messages in an Android app, you need to integrate the Hackle workspace with the Firebase project.

For more details, please refer to [Android FCM Integration](https://docs-en.hackle.io/docs/fcm-integration).

# 2\. Integrate Firebase Cloud Messaging SDK

Please complete the Android app settings by following the [Firebase Cloud Messaging Installation Guide](https://firebase.google.com/docs/cloud-messaging/android/client).

# 3\. Integrate with Hackle SDK

Refer to [SDK Integration](https://docs-en.hackle.io/docs/android-sdk-init) to add the Hackle SDK dependency and initialize the SDK.

The push token will be automatically registered when building and running the app.

# 4\. Test Push Messages

* **Check Token**: You can verify the token set on the Android device by following the [User Identifier Verification Guide](https://docs-en.hackle.io/docs/android-user-explorer#%EC%82%AC%EC%9A%A9%EC%9E%90-%EC%8B%9D%EB%B3%84%EC%9E%90-%ED%99%95%EC%9D%B8%ED%95%98%EA%B8%B0).

* **Send Test**: Follow the [Push Message Test Sending Guide](https://docs-en.hackle.io/docs/send-push-message#step-3-1-%ED%85%8C%EC%8A%A4%ED%8A%B8-%EB%B0%9C%EC%86%A1) to verify the push message on the Android device.

# (Advanced) Deep Link Navigation

Hackle push messages support deep link navigation when clicked. If an activity opens through a push message, you can check the opened deep link information as follows:

> For more details on Android deep linking, please refer to the [Android Deep Linking Guide](https://developer.android.com/training/app-links/deep-linking).

```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}")
        }
    }
}
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);
        }
    }
}