Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android devices not receiving 5% of push sent with Firebase Cloud Messaging

The graph below from Firebase Cloud Messaging (FCM) Console shows how only ~95% of our push are being received by the phones. This is causing lots of issues for us as we're creating a VoIP app and need the push to be received immediately. Can anyone explain why this is happening and how to get this rate closer to 100%?

Some important notes:

  • All phones are Android
  • All phones had our app open at the time they received the push or up to 2 minutes prior
  • All push are data push (i.e. no body/title) with priority high
  • The push is sent with expiration 10 seconds to prioritize them following Android docs
  • We had ~30 errors (registration-token-not-registered and internal-error) sending push in the same period, which is nothing compared to the ~500 undelivered push

Screenshot from FCM Console

like image 597
pir Avatar asked May 08 '20 23:05

pir


People also ask

Is there a limit for Firebase push notification?

You can send up to 240 messages/minute and 5,000 messages/hour to a single device.

How do I test FCM push notifications Android?

Send a test notification messageOpen the Notifications composer and select New notification. Enter the message text. Select Send test message. In the field labeled Add an FCM registration token, enter the registration token you obtained in a previous section of this guide.

How to use Firebase Cloud Messaging to push notifications to Android devices?

Following is the example of using Firebase Cloud Messaging to push the notifications to the mobile devices which will contain our android application. Create a new android application using android studio and give names as PushNotification.

What is Firebase Cloud Messaging?

Firebase Cloud Messaging (FCM) is a cross-platform (Android, iOS, Mobile Web) messaging solution which is used to send notification messages to the mobile devices at no cost. By using firebase we can easily send messages to any device or schedule messages to send in the user’s local time zone based on our requirements.

How to add FCM to your Firebase app?

The following is the gist of adding FCM to the app. Go to Tools -> Firebase -> Cloud Messaging -> Set up Firebase Cloud Messaging Connect your app to Firebase: Complete the three steps of creating a Firebase project.

Do Firebase notifications work with foregrounded apps?

Firebase notifications behave differently depending on the foreground/background state of the receiving app. If you want foregrounded apps to receive notification messages or data messages, you’ll need to write code to handle the onMessageReceived callback.


Video Answer


2 Answers

pir,

As far as I understand, there are many reasons why a message might not be delivered. I think without looking at your specific data, it is going to be difficult for anyone to give a conclusive answer.

What I do recommend is that you spend some time reading Understanding message delivery on the Firebase Documentation. Although I recommend you read the entire article, of particular interst for you will probably be the BigQuery data export section. This covers exporting your message data to BigQuery. Data exported to BigQuery is covered in the What data is exported to BigQuery? section. I think you're going to be interested in the event field which holds data about the type of event that occurred. These events types include:

  • MESSAGE_ACCEPTED: the message was received by the FCM server and the request is valid;
  • MESSAGE_DELIVERED: the message has been delivered to the app's FCM SDK on the device. By default, this field is not propagrated. To enable, follow the instructions provided in setDeliveryMetricsExportToBigQuery(boolean)).
  • MISSING_REGISTRATIONS: the request was rejected due to a missing registration;
  • UNAUTHORIZED_REGISTRATION: the message was rejected because the sender is not authorized to send to the registration;
  • MESSAGE_RECEIVED_INTERNAL_ERROR: there was an unspecified error when processing the message request;
  • MISMATCH_SENDER_ID: the request to send a message was rejected due to a mismatch between the sender id sending the message, and the one declared for the end-point;
  • QUOTA_EXCEEDED: the request to send a message was rejected due to insufficient quota;
  • INVALID_REGISTRATION: the request to send a message was rejected due to an invalid registration;
  • INVALID_PACKAGE_NAME: the request to send a message was rejected due to an invalid package name;
  • INVALID_APNS_CREDENTIAL: the request to send a message was rejected due to an invalid APNS certificate;
  • INVALID_PARAMETERS: the request to send a message was rejected due to invalid parameters;
  • PAYLOAD_TOO_LARGE: the request to send a message was rejected due to a payload larger than the limit;
  • AUTHENTICATION_ERROR: the request to send a message was rejected due to an authentication error (check the API Key used to send the message);
  • INVALID_TTL: the request to send a message was rejected due to an invalid TTL.

I hope this helps. Good luck!

like image 59
oreid Avatar answered Nov 14 '22 22:11

oreid


There are several reasons that could make notification not delivered.

  • There are devices that might have a specific battery optimization that will stop notifications from showing. And to fix that you might ask user to do the following. check Settings > Battery > Battery Optimization or Adaptive Battery > Find your app and press Don't optimize

  • The app has might push permissions Disabled In Device Settings, user can turn on and off push notifications. From notification setting under Settings > Apps

like image 20
Ibrahim Ali Avatar answered Nov 14 '22 21:11

Ibrahim Ali