2

I want to start my activity whenever app receive push notification from firebase even though app is not running or in background. Is there any broadcast listener which will listen incoming notification like SMS_RECIVED intentfilter is listening SMS . PS:I don't want to touch the notification to start the activity.

aks
  • 83
  • 9

2 Answers2

0

To receive the notification for your app even if it is in background set the priority of fcm message to high which have to be done in server side code. it will work.

you can find more detail from here:

How to handle notification when app in background in Firebase

Community
  • 1
  • 1
Anjali
  • 1
  • 1
  • 13
  • 20
  • Getting notification is not the real issue, I want to notify my app about incoming notification so I can perform specific task in onReceive method of broadcast receiver (If anything is there for notification) – aks Dec 27 '16 at 11:39
  • have you created fcm service which extends FirebaseMessagingService? – Anjali Dec 27 '16 at 11:40
  • onMessageReceived will automatically called whenever you have new notification – Anjali Dec 27 '16 at 11:40
  • Yes I have got your point,is there any way to pass application context in onMessageReceived so I can show toast message whenever I receive notification. – aks Dec 27 '16 at 11:51
0

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

You can keep data payload instead of notification payload in you Message from server. This will call onMessageReceived irrespective of your application is in foreground or background.

Vaibhav Jain
  • 163
  • 13