I am trying to implement Firebase notifications for our android app.
I have also implemented Dynamic Links in the app.
But, I am not able to figure out a way to send the notification with a dynamic link (so that on clicking the notification, a certain dynamic link is opened). I can only see an option to send a text notification.
Is there any workaround or is this a limitation of FCM?
You will have to implement a server side sending of the notification with a custom data as currently the console doesn't support it. (Using the custom key-value pairs wont work either as when your app is in background mode the notification wont deep link). Read more here: https://firebase.google.com/docs/cloud-messaging/server
Once you have your own App Server, you can then include the Deep Link URL into the custom data section of the notification.
In your
FirebaseMessagingService
implementation you will need to look at the payload and take the URL from there, create a custom intent that uses that Deep Link URL.I am currently using AirBnb's deep link dispatcher library (https://github.com/airbnb/DeepLinkDispatch) that works quite well in this situation as you can set the data and the link to the DeepLinkActivity and that will do the link processing for you. In the below example, I convert the payload from the server into an object called DeepLinkNotification and this contains a URL field.
DeepLinkActivity:
In doing this implementation, you also won't open any links you cant handle compared to if you just set the intent to
Intent.ACTION_VIEW
with any URL.