Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FCM does not deliver notification to all the topic subscribers (data notification)

I use FCM to push notifications to my apps users. I also use Firebase Analytics to get some feedback about the app behaviour.

I have an app that subscribes to a specific topic when it starts its default activity. So basically every users that started at least one time the app is a topic subscriber. From firebase analytics, I can see 21374 first_open in the events logs in the past 30 days. I can also see this amount in the "active users" dashboard.

So basically, at least 21k subscribers should be available for the topic.

I pushed a notification to this topic yesterday. It's a data notification, so there is no problem with the background / foreground / not started state of the app.

In the onMessageReceived method, I log an event on firebase analytics. And apparently, only 2,9K users did receive the notification.

What can explain this difference between the subscribers count and the notification effectively pushed to users?

Some element that can be linked:

  • The app was updated on the store 3 days ago. So the users may not have started the new version of the app. But an update should not remove the topic already subscribed by the previous version. I also ran some tests to verify this, and an update does not remove the topic subscribed by a previous version (unless the app is uninstalled first). So it should not be the reason to this issue.

  • The app was updated with a new version of the GooglePlayServices / Firebase package (From 9.2 to 10.0.1) Does it remove all the topics subscribed by the older version of GooglePlayServices / Firebase package?

Is there any other reason that can lead to such a difference between subscribers count & notification delivered count?


@Bob Snyder

Here is how I check for the Google Play Services version:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    GoogleApiAvailability googleApiAvailability =  GoogleApiAvailability.getInstance();
    int success = googleApiAvailability.isGooglePlayServicesAvailable(this);
    if(success != ConnectionResult.SUCCESS) {
        googleApiAvailability.makeGooglePlayServicesAvailable(this);
    }

    FirebaseMessaging.getInstance().subscribeToTopic("mytopic");

The version of the Google Play Services used is related to the environment mobile+wear, a lot of users have some difficulties to update their GooglePlayService version, so I generally keep a lower version than the latest release, and update it only if necessary.


@Jorgesys

My FirebaseMessagingService is actually quite simple:

public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Logger.d("From: " + remoteMessage.getFrom());

    MyFirebaseAnalytics mAnalytics = new MyFirebaseAnalytics(this);
    mAnalytics.logEvent("notif", "reception");

    Map<String, String> data = remoteMessage.getData();
    // Check if message contains a data payload.
    if (data.size() > 0) {
        Logger.d("Message data payload: " + data);
}

The logEvent method is the one logging the event on Firebase.

like image 320
Thomas Thomas Avatar asked Dec 19 '17 13:12

Thomas Thomas


People also ask

Is there a limit for Firebase push notification?

Notification messages can contain an optional data payload. Maximum payload for both message types is 4000 bytes, except when sending messages from the Firebase console, which enforces a 1024 character limit.


2 Answers

Well there can be a number of things that can be a factor here:

1) People may have removed your app

2) People might have used 'Force Stop' on your app

3) Analytics data usually takes some time to log, it can be incomplete

4) People are not connected to a network have their topic messages cached until the expiry time of the topic message (default is 4 weeks)

5) User might have cleared App Data which leads to instance id getting invalidated and topic messages also get unsubscribed. If you don't have a resubscription logic on your end, they will stay unsubscribed.

6) In newer android versions, if your app doesn't get opened for around some time(google hasn't disclosed the amount) and in those days if your app has not had any visible components eg Foreground service, notification etc.. The app get's cached and notifications don't get delivered as usual. This is App standby

7) The time to expiry of the data message has elapsed and by that time, the user did not connect to the FCM server and get messages.

8) In some situations, FCM may not deliver a message. This occurs when there are too many messages (>100) pending for your app on a particular device at the time it connects or if the device hasn't connected to FCM in more than one month. In these cases, you may receive a callback to FirebaseMessagingService.onDeletedMessages()

There might be other factors contributing like the topic screen showing 21k but it's not up to date with the actual count etc.

like image 83
Kushan Avatar answered Sep 28 '22 17:09

Kushan


Looks like firebase analytics on the 'notification received' in case of data notification is highly inaccurate.

I conducted the following test: sent to ~100k users a data notification that displays a notification immediately and to another ~100k users the same notification this time using firebase console. (Before creating the topics for the test, randomly shuffled the tokens)

According to firebase console, the received rate for the data notification is 40% and for the notification sent form console 84%. So you would expect the number of push opens to be proportional to the number of 'received' but surprisingly the number of push opens in both groups were pretty much the same.

In another test we conducted, we compared the analytics from our internal system to firebase, and the 'received' in our system was double than what reported in firebase. Please note that those test were conducted very recently (2 days) and there might be some delay with the events showing up in firebase. I will update the comment if the numbers will get aligned in the coming days.

Edit As promised to update, the dashboard did not refresh. I have a strong a feeling that the 'received' event for data notification is not reliable.

like image 23
Efi G Avatar answered Sep 28 '22 17:09

Efi G