I have a PyFCM server sending notifications via Firebase (FCM) to my simple android app. I have tested and get regular notification messages to appear in the tray when the app is running in the background no problem. I would now like to receive data messages in my app and trigger app functions when that happens. My understanding is that onMessageReceived()
is triggered when a data message is received, but I'm not sure how to implement this listener properly in my code.
The documentation states:
By overriding the method
FirebaseMessagingService.onMessageReceived
, you can perform actions based on the receivedRemoteMessage
object and get the message data:
What does that mean? I see that this onMessageReceived()
is in a file called MyFirebaseMessagingService.java. Where does this file go?
Say I have a function getLocation()
in my MainActivity.java, what are the exact steps to get an incoming FCM data message to trigger my getLocation()
function? I am having difficulty finding concrete examples.