Home > OS >  Capacitor: handle data-only push notifications in background
Capacitor: handle data-only push notifications in background

Time:10-01

I hope some of you can help me for I have been stuck on this for a few days now.

I'm using Ionic React / Capacitor to build an Android app that includes a chat function.

Since I don't have the financial means to pay for a server that can handle every single message sent, I have to rely on FCM. So the capacitor docs state that handling data-only push notifications in the background is not implemented in the FCM plugin: https://capacitorjs.com/docs/apis/push-notifications#silent-push-notifications--data-only-notifications It states that one would have to extend some service, but I absolutely do not know anything about Java so I don't even know where to look. Does anyone have performed handling of data-only FCMs while the app is killed and point me in the right direction?

All that needs to happen is basically:

  1. data message comes in
  2. message payload is written to SQLite DB

So if anyone could give an idea of how to add this to the existing FCM notification handling done by the Capacitor plugin, that should work fine...

CodePudding user response:

You can use the Capacitor Firebase Cloud Messaging plugin which already supports this: https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/messaging

  • Related