What we try to achieve is when a user taps a notification, he/she should be redirected to a certain fragment. That destination fragment is marked as startDestination
in the graph (it has its own .xml
file).
To create the PendinIntent
for this, we use the NavDeepLinkBuilder
like this:
// `this` represents the notification service.
NavDeepLinkBuilder(this)
.setGraph(R.navigation.destination_graph)
.setDestination(R.id.start_destination)
.createPendingIntent()
where R.id.start_destination
is the id of the fragment specified in app:startDestination
attribute of the root navigation
tag in the R.navigation.destination_graph
a.k.a. the start destination of that graph.
If we try to use this, we get the following error. If we use any other fragment other than the one marked as startDestination
, it works seamlessly.
Our graph is this.
What could be the actual case and what's a workaround?
EDIT: If the graph is just like the above one, but it's missing its android:id
attribute and it's not included in the BottomNavigationView
, the error changes to Caused by: java.lang.IllegalStateException: unknown destination during deep link: 0
(line 3)
EDIT2: The above scenario, but the graph has an ID this time and is not used in any BottomNavigationView. The error becomes Caused by: java.lang.IllegalStateException: unknown destination during deep link: test.ourapp.app:id/messages