How can i get or detect FCM notification while app running?

Pyae Hein

I am trying to show in App notification to my current using user. But, FCM only show to foreground and background users. How can i do it?

Riley MacDonald

You can create a service that will receive all FCM messages and then you can react on the received messages accordingly to show a notification.

https://firebase.google.com/docs/cloud-messaging/android/receive

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Map<String, String> message = remoteMessage.getData();
        // do something once message is received
        }
}

In your manifest:

<service
    android:name=".MyFirebaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

While my app is running, how can I update the current activity with the contents a GCM notification, without clicking on the notification?

How can I get "data payload" from push notification (using FCM) when android app is in killed state?

How can I prevent to display FCM notification on Flutter app background?

How can I detect if app is running on PDA

How can I detect if a user has changed the iPhone system language settings while the app is running?

iOS How to handle FCM while app is not running

How can I get missed CloudKit notification while app is in the background mode?

How Can I Handle Push Notification When App Is Not Running?

How can I detect, that my app is running on the Ripple Emulator?

How can I detect if my app is running on Windows 10

How can I detect if my Flutter app is running in the web?

How can I detect if the notification center was opened

How I can serialize database results as FCM/Push notification data?

How can I confirm that firebase notification was actually sent (fcm)?

Local notification while app not running

How can I detect if the currently running app was installed from the app store?

I get a SQLCipher error while running an app

How can I detect if telnet is running on a server?

How to show push notification while app is in running state in Swift 4?

FCM How to get Notification().getTitle() when app open from in background during notification click

How can I get prometheus exporters running in my grails app?

How can I set notification sound when app is not running in React-Native firebase

How to get push notification when app is not running/app is terminated

how can I get mail app's notification in iOS from my own app?

How to send FCM notification to app from web

Can I detect that the app in not running state is started by background mode?

How can I tell if handleOpenURL is called app startup or while app is running?

While running I can't get app to recognize bankcustomers once added, customers are stored in arraylist

Can't get notification on Production server while existing app on App Store getting notification