Fixing FCM Push Notifications: Solutions for Common Issues

Category Quality Assurance

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably deliver messages at no cost.

Using FCM:

1.You can notify a client app that new email or other data is available to sync.
2.You can send notification messages to drive user re-engagement and retention.

For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.

Detailed information on Firebase Cloud Messaging can be found in here: https://firebase.google.com/docs/cloud-messaging/

But there are some situations where we need to fix the issues related to FCM push notifications such as:

1.Notification is not working in the Oreo.
2.Notification is not working as a background service in One plus 3/3T.

In situation one, Oreo, the latest version of Android, supports some methods and classes which are not used by the legacy code present in the application.

The below mentioned line of code snippet will help you fix it.

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
 int importance = NotificationManager.IMPORTANCE_HIGH;
 NotificationChannel mChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, title, importance);
 mChannel.setDescription(notification);
 mChannel.enableLights(true);
 mChannel.setLightColor(ContextCompat.getColor(getApplicationContext(),R.color
 .colorPrimary));
 notificationManager.createNotificationChannel(mChannel);
 }
view rawfcm hosted with ❤ by GitHub

In situation two, where the notification is not working as a background service in One plus 3/3T, turn your battery optimisation off and it’s done. You will now receive the push notification.

Ready to embark on a transformative journey? Connect with our experts and fuel your growth today!