0

I want to open a specific fragment in my navigation graph through deep linking.

I added a deep link URL like this enter image description here

I tried putting the same URL in the payload in the FCM console, but it did not open my fragment, the same thing opens when I put the URL in a text message.

enter image description here

I have added the nav graph in manifest too, can someone please address what's wrong and how can I fix it.

Siddhesh Pawar
  • 259
  • 4
  • 24

1 Answers1

0

If your navigation graph is in an Activity other than the launcher activity. Call setComponentName(<your_class_name::class.java>) while building the Deep link.

NavDeepLinkBuilder(context)
    .setGraph(R.navigation.menu_job_navgraph)
    .setComponentName(MainActivity::class.java)
    .setDestination(R.id.jobDetailFrag)
    .setArguments(JobDetailFragsArg("1").toBundle())
    .createPendingIntent()
Alpha 1
  • 4,118
  • 2
  • 17
  • 23
  • Hi, your method is working but it just opens the destination page when the app is in foreground, but when it's in background it simple opens the app, can you please tell what's the issue? – Siddhesh Pawar Apr 20 '21 at 06:17
  • 1
    If your app is in the background, onMessageReceived might not be called. refer: https://stackoverflow.com/questions/45671869/firebase-onmessagereceived-not-called/45673611#45673611 – Alpha 1 Apr 20 '21 at 06:37
  • I tried using postman too I added this code to my activity – Siddhesh Pawar Apr 20 '21 at 07:30