1

Only use of data payload not receive any notification when app is closed, and also onMessageReceive method is not triggered.

In bellow image show data payload click here to view parameter

and Response is click here to view response

In response success 1 but not receive any notification in redmi phone.

Raja Jawahar
  • 6,742
  • 9
  • 45
  • 56
Nikita Jain
  • 35
  • 1
  • 7

3 Answers3

6

Supporting Fire-base push notification for all device is like a maze. There are 3 scenario for push notification

  1. Foreground (fire FirebaseMessagingService's onMessageReceived method)
  2. Background (can't fire FirebaseMessagingService but firebase service push their message into device's Notification Tray)
  3. App kill (can't fire FirebaseMessagingService firebase service push push their message into device's Notification Tray)

NOTE: Some chinese device like Xiaomi, Asus, Huawei etc. are force stop your app when you swipe out from your background stack, so that the service is kill. For that reason firebase service is not run and can't push their notification into Notification tray.

In Xiaomi - security-->permissions-->autostart then check mark your app. Enable this means app's any service always run in background. Then you get all kinds of notification from your app every time.

If you want to learn more about that, Check that and if you want to go particular device's security page from your app then check this.

Community
  • 1
  • 1
Nazmus Saadat
  • 973
  • 9
  • 22
  • thnak u . yes this was a security permission issue "autostart" . in mi phon we need to take permission "autostart" mainually .bellow link help to understand about auto start permission – Nikita Jain Jul 19 '18 at 06:51
  • If this answer seems to be correct or match what are you looking for, then check mark this as a right answer.. :) – Nazmus Saadat Jul 19 '18 at 10:17
  • if you dont specify the notification property even having the app in the background calls onMessageReceived. But then when app it's closed it wont show the notification period. So annyoing. I want to have a custom layout that is the same for each case. – Taunter exd May 08 '23 at 15:58
2

Send data message and use onMessageReceived function to display the notification manually.

Ragesh
  • 205
  • 3
  • 11
0

when you omit priority field in the JSON the default will be normal and that means firebase will send you the push whenever is appropriate.

and usually when your app is closed it takes more time to receive the message than when its foregrounded.

so if you are testing you can use "priority":"high" to get things done quicker.

but remember to remove the field as it has high battery consumption for the end user

one more thing to consider is that on some devices (like Huawei) you have to make the app as trusted to use more power if this is the case you can do this under the power settings

Update

sending a push to a token sometimes wont work properly (since token change quickly during development time) and it's hard to verify token every time it refreshes.

So every time I'm testing the push I rather use a topic/package as "to" parameter.

In case you subscribe your app to a topic you can check the working fellow using dashboard which suggests all the topics your app has subscribed to.

seyed Jafari
  • 1,235
  • 10
  • 20