Achal Urankar
Achal Urankar

Reputation: 159

Not receiving FCM notification after sometime

I've implemented firebase cloud messaging into my chat application, im using retrofit to send message through fcm notification from source user to destination user, everything works fine for sometime even when the app is closed, but after say some hours i don't receive any notification. Why this might be happening? any help is appreciated, thanks in advance.

Upvotes: 2

Views: 4309

Answers (1)

MG1616
MG1616

Reputation: 377

Did you look about this : https://firebase.google.com/docs/cloud-messaging/android/receive ?

To keep receiving, when the app is killed, you need to mark your Firebase Service class to not get killed with your main app.

Do something like that (not tested)

ComponentName componentName = new ComponentName(
      applicationContext,
      FCMService.class);

applicationContext.getPackageManager().setComponentEnabledSetting(
       componentName,
       PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
       PackageManager.DONT_KILL_APP);

This may also help : https://github.com/firebase/quickstart-android/issues/41#issuecomment-306066751

Upvotes: 1

Related Questions