firebase-admin-java icon indicating copy to clipboard operation
firebase-admin-java copied to clipboard

[FR] Expose `link` / `link_android` in notifications for deep linking

Open sheepmaster opened this issue 2 months ago • 1 comments

Problem statement

Deep linking on Android requires the data field in the Intent to be set. As described in this SO post or firebase/firebase-android-sdk#6703, the only way to populate the the field in notifications created automatically by the Firebase Android SDK (when the app is in the background) is by setting the gcm.n.link or gcm.n.link_android keys in data, which have reserved prefixes and are therefore not supposed to be used (although setting them works, at least today).

Originally posted by @lehcar09 in #6703:

Alternatively, we can file a feature request to support the link or link_android field. I’ll get back to you once I hear back from them.

So, this is the FR to officially support these :)

Strawman

A strawman proposal would be to add link properties to the Notification / AndroidNotification classes, which would then be mapped to gcm.n.link / gcm.n.link_android in the JSON payload. Equivalently, in the HTTP API instead of this:

{
  "message": {
    "notification": {
      "title": "Lorem",
      "body": "Ipsum"
    },
    "data": {
      "gcm.n.link": "app://deep/link"
    },
  }
}

It would be this:

{
  "message": {
    "notification": {
      "title": "Lorem",
      "body": "Ipsum",
      "link": "app://deep/link"
    }
  }
}

or this:

{
  "message": {
    "android": {
      "notification": {
        "title": "Lorem",
        "body": "Ipsum",
        "link": "app://deep/link"
      }
    }
  }
}

Alternatives

The workaround suggested here of using setAction doesn't work, because actions needs to be declared in the Android manifest in order to match the intent, which conflicts with dynamically registering deep link targets.

Thanks!

sheepmaster avatar Oct 01 '25 08:10 sheepmaster

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Oct 01 '25 08:10 google-oss-bot