jlcvp / fcm-node

A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM) for Android & iOS & Web Notification and data push
MIT License
125 stars 46 forks source link

is it possible to send push notification with action buttons in message? #44

Closed RunnableWeb closed 5 years ago

RunnableWeb commented 5 years ago

my message is something like this let message ={ to: user.fcmToken, notification: { title: "title message", body:body message, "sound": "default" } }

jlcvp commented 5 years ago

Hi, @RunnableWeb

I recommend creating a data-only payload, and do the treatment and notification show on service

something like:

const message = {
    to: user.fcmToken,
    data: { 
        title: 'title message',
        body: 'body message',
        myButtons: "OK;ROLLBACK"
    }
}

then on your fcmservice in-app you build a notification based on the data payload received

RunnableWeb commented 5 years ago

Hey @jlcvp, thank you for the response,

by then on your fcmservice in-app you build a notification based on the data you mean I can configure and customize the notification from and within the app? does that mean that when the user runs the app for the first time the notification will be configured?

I am using Ionic that based on Cordova to build my apps and Cordova is a platform to build Native Mobile Applications using HTML5, CSS, and JavaScript. do you have any idea if it is possible to do that on Cordova apps?

jlcvp commented 5 years ago

@RunnableWeb Luckly I`m an ionic/cordova developer too. What I can say is that you need a background service that receives the fcm broadcast.

Once the data is sent from your fcm server, the service builds a local notification using the data object received. Remember you can send any key-value pair on data.

Use this ionic native plugin to help you build your notification within the app and this other native plugin to receive and handle your data object

RunnableWeb commented 5 years ago

Hey, @jlcvp Thank you so much for your help, I will have a look at these plugins ASAP.

jlcvp commented 5 years ago

@RunnableWeb np, feel free to get in touch