Ad

How Does Firebase Cloud Messaging Work On Android

I am sending data to FCM server via an 'admin app' and would like the other 'non-admin app' to be able to receive push notifications, whenever the 'admin app' sends data to the FCM server.

To achieve that, I am using AWS SNS in tandem with FCM to store the list of recipients and to disseminate the push notifications. However, as opposed to the answer stated in https://stackoverflow.com/a/47413178/9846004, when the application is in the foreground, my device does not receive any push notifications; it only receives them when it is in the background.

In addition, how do I implement the feature to "open up the intended activity screen" using the "click_action" key in the payload? Do I need to include the full package name as part of the value?

Something like {"click_action" : "com.example.application.androidapp.main_activity"} or just {"click_action" : "main_activity"} will do?

Ad

Answer

In order to receive messages while your app is in foreground, create a service that extends FirebaseMessagingService and override the onMessageReceived and onDeletedMessages methods. For more information, visit this link.

Maybe this can help.

Ad
source: stackoverflow.com
Ad