firebase / quickstart-android

Firebase Quickstart Samples for Android
https://firebase.google.com
Apache License 2.0
8.82k stars 7.32k forks source link

onMessageReceived isn't always called #372

Open stkq opened 6 years ago

stkq commented 6 years ago

The onMessageReceived method is only called for about 2/3 of the users. It's not because it's in the background because it's a data payload sent from Microsoft Azure, and the method is called for me and the notification displayed when I have the app closed. I know they're reaching the device because I checked the Play Console and they're marked as 'Acknowledged'.

Steps to reproduce:

  1. Follow the quickstart example and log the onMessageReceived call
  2. Send a message with a data payload
  3. See how many of your push notifications are logged

Observed Results:

Only about 2/3 of the notifications end up with a call to onMessageReceived.

Expected Results:

I expected all of the notifications to reach onMessageReceived.

Relevant Code:

 <service
 android:name=".push.MyFirebaseMessagingService">
     <intent-filter>
         <action android:name="com.google.firebase.MESSAGING_EVENT"/>
     </intent-filter>
 </service>
public class MyFirebaseMessagingService extends FirebaseMessagingService {

...
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
...
}
kroikie commented 6 years ago

Hi @stkq couple questions:

stkq commented 6 years ago
  1. When I say 2/3 I mean 2/3 of thousands of notifications, but yes, for about 1/3 of those notifications, the console says 'Acknowledged' but the onMessageReceived method is not called. For the other 2/3, the console says Acknowledged and the onMessageReceived is called.
  2. It's multiple devices but when it happens on one device it usually happens multiple times on that device. There's no pattern when it comes to type of device though.
amitportish commented 6 years ago

We are having the same issue, and it is a major problem. Any forecast on when is it going to be resolved? Any workaround?

mowbell commented 6 years ago

We have same issues with our test devices. Seems like some device manufacturers don't allow notifications in some situations, We are investigating also Take a loook on manufacturers-interfere-with-reliable-notifications

KORuL commented 5 years ago

822

memfis19 commented 3 years ago

Hi. We have same issue even in release builds. According to FCM diagnostic tool we found out that we received all messages but some of them weren't broadcasted to our app. Any thoughts how to deal with it? To be clear:

  1. We send high priority push notifications
  2. We use legacy http protocol
  3. Push-notifications work fine until device is in doze mode and app is in standby mode. At least this is the only way we as developers were able to reproduce this issue.
  4. This issue reproduced even if device connected to the charger. How is it possible?
  5. Indeed it is rare case but it is very important for us because we have calling app.
willmastered commented 3 years ago

Im not a bot I just don't talk

IvanSimovic commented 2 years ago

I am also working on a calling app, and I am still dealing with the same issue. For me there are random periods of a minute or two where no notifications arrive, and then it works again. For a calling app that is not fine. Did you ever find a work around for this problem @memfis19 ?