0

Now I am processing push notification using FCM. It works well when app is in foreground.

I'd like to process the notification even when the app is on background or is destroyed.

I googled about it for a few days, but couldn't find the solution yet. Thanks in advance.

AL.
  • 36,815
  • 10
  • 142
  • 281
saltTiger K
  • 29
  • 1
  • 7

1 Answers1

0

So, if you use firebase, you should send data notification (json contained data section, not notification) according to this:

https://firebase.google.com/docs/cloud-messaging/android/receive

Then override FirebaseMessagingService with onMessageReceived, and there you will receive push message. You have to also register this service in AndroidManifest.xml:

   <service android:name=".service.FirebaseMessageService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
Tomasz Czura
  • 2,414
  • 1
  • 14
  • 18