I want to send some data from the server to users using Firebase Cloud Message and show that data in MainActivity.
But my situation is I want to show the data directly in MainActivity without any notification when MainActivity is in the foreground. For all the other cases like when the app is in the background or the app is in the foreground but other activities (Not MainActivity) open, it will show a notification and if I click the notification it will go to MainActivity(this part can be handled by pendingIntent or click_action). But combining both logic seems tricky. Is using BroadcastReceiver a solution?
How can I handle this? Any suggestion or link?