I have a composable which triggers a notification....
# compose
c
I have a composable which triggers a notification. Is there a best practice in Compose for how to obtain the
Intent
for the notification’s
setContentIntent()
? I’m trying to avoid having the composable know about its host Activity. Clicking the notification will launch that Activity. I can think of a few things I could do: • Pass in a lambda like
intent: () -> Intent
to invoke anytime I need an intent • Pass in the Activity
Class<?>
• CompositionLocal? (bad idea?)
i
Are you using Navigation Compose and its support for deep linking into the correct screen based on your Intent? Besides automatically parsing arguments out of the Intent's data string for you, it also gives you the raw Intent itself as an argument: https://developer.android.com/reference/androidx/navigation/NavController.Companion#KEY_DEEP_LINK_INTENT()
c
Indeed I am. Thanks for the tip!