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

How to use rich text notification, i want to send image that display event if app is in background. #42

Closed devsiodedra closed 5 years ago

devsiodedra commented 5 years ago

How to use rich text notification, i want to send image that display event if app is in background.

so i want to add "mutable_content": true,

my current code is as below.

var message = { //this may vary according to the message type (single recipient, multicast, topic, et cetera)
                                            to: existToken.device_token, 
                                        // collapse_key: 'your_collapse_key',

                                            notification: {
                                                title: 'title', 
                                                body: 'New Promotion.' 
                                            },

                                            data: {  //you can send only notification or only data(or include both)
                                                title: post.title,
                                                image: 'image_url'
                                            }
                                        };

                                        fcm.send(message, function(err, response){
                                            if (err) {
                                                console.log("Something has gone wrong!");
                                            } else {
                                                console.log("Successfully sent with response: ", response);
                                            }
                                        });
jlcvp commented 5 years ago

remove the notification object, send just the data and build your rich notification internally in your application