All Collections
[Android ] Handling deeplinks sent via FCM
[Android ] Handling deeplinks sent via FCM

To handle deep links from push notifications sent via FCM in your Android app, follow these steps

Written by Marat Zhanabekov
Updated over a week ago

1. Update the AndroidManifest.xml

First, you need to declare the intent filter for deep linking in your AndroidManifest.xml for the activity that should handle the deep link:

<activity android:name=".YourDeepLinkActivity">
<!-- Intent filter for handling deep links -->
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="<your_app_url_schema>" />

2. Handle the Deep Link in the Activity

In the activity that handles the deep link (YourDeepLinkActivity in this case), you can retrieve the deeplink data:

protected void onCreate(Bundle savedInstanceState) {

Intent intent = getIntent();
Uri data = intent.getData();
if (data != null) {
// Handle the deep link. For example:
String path = data.getPath();
// Do something with the path or other parts of the URI

3. Handle the FCM Push Notification

To handle the FCM push notification and extract the deep link, you can use the FirebaseMessagingService:

public class MyFirebaseMessagingService extends FirebaseMessagingService {

public void onMessageReceived(RemoteMessage remoteMessage) {
// Check if the message contains data payload
if (remoteMessage.getData().size() > 0) {
String deepLink = remoteMessage.getData().get("deeplink");
if (deepLink != null) {
// Handle the deep link

private void handleDeepLink(String deepLink) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(deepLink));

Make sure you've declared this service in your AndroidManifest.xml:

<service android:name=".MyFirebaseMessagingService">
<action android:name="" />

4. Ensure Firebase Setup

Ensure you've set up Firebase Cloud Messaging correctly in your app. This includes adding the necessary dependencies in your build.gradle file and initializing Firebase in your app.

That's it! With these steps, your app should be able to handle deep links sent via FCM.

Did this answer your question?