Send android push notification when new doc arrives at sync gateway?

Hi i am developing an android chat app using CBL now i need to send push notification(using Google Cloud Messaging) to user when new chat message(doc) arrives at couchbase db through sync gateway how i can do this ?

Hi @psrinivasgoud,

You can get Replicator’s change event through Replicator ChangeListener. Couchbase Capella for Mobile Developers

If you’d like to know which document is updated, please use Database ChangeListener.

I hope this helps you.

Thanks!

HI @hideki thanks for reply . this for client side right i added addChangeListener to database but its working only when app is running when i closed app its not working (even tried with android service) that why i need server side listener.

Hello @psrinivasgoud,

There are two options for making sure client applications have the latest data from sync gateway (in this case, chat messages):

Thanks
James

1 Like

Hi @psrinivasgoud,

You can also check out this blog post on using push notifications with Couchbase Mobile Tutorial: Implement Android Push Notifications in your Couchbase Mobile app - The Couchbase Blog

In this case, the wakeful service executes the pull replication regardless of whether the app is opened or closed.

James

Thanks a lot @jamiltz

Hi team . How sync_gateway can be configured to send new data to firebase cloud message fcm. I want every time sync gateway get new object it sends it to fcm and fcm handle the push notification to the device with couchbase lite.