I am using NavDeepLinkBuilder to generate a pending intent for a push notification to open the app at a particular destination.
return NavDeepLinkBuilder(this)
.setComponentName(MainActivity::class.java)
.setGraph(R.navigation.main_navigation)
.setDestination(destinationId)
.setArguments(args)
.createPendingIntent()
When the app is in the foreground, the notification will navigate to the destination set in the pending intent built by the NavDeepLinkBuilder.
However when the app is not in the foreground, the notification will only navigate to the MainActivity and ignore the destination set in the NavDeepLinkBuilder.
Note: The pending intent and notification are built in a service extending FirebaseMessagingService.