Change color and icon of FCM notification in node.js

Viewed 926

I am setting color and icon of my android notification in node.js after setting title and body it does not seem to work. and I need different notification background color and different icon for two notifications for same app that i am creating.

I have tried changing icon and color in android manifest meta tag and it works but the problem is i need separate notification icon and color for request received notification and separate notification color and icon for for new message notification. Also to mention that the code for both new request notification and new chat request notification and in same index.js file and after receiving new message, the notification that pops up is that of new friend request I don't know why.

//Request notification format.
return DeviceToken.then(result => 
    {
        const token_id = result.val();

        const payload = 
        {
            notification:
            {
                from_sender_user_id : from_sender_user_id,
                title: "New Friend Request",
                body: `${senderUserName} wants to connect with you`,
                icon: "/requestsmall.png"
                color: "#fffbd7"
            }
        };


//New Message notification
return Token.then(result => 
    {
        const tid = result.val();

        const pload = 
        {
            notification:
            {
                from_sender_id : from_sender_id,
                title: "New Message",
                body: `${senderName} sent you a message`,
                icon: "chatsmall.png"
                color: "#e5fafa"
            }
        };

I want to display now different icon and color for these two notifications but it is not working also the send message notification displays the title and body of new request notification

1 Answers

As per my knowledge this is fully depend on the extension which you are using inside your project. Every extension of Firebase didn't support all features. Even if you send a FCM message directly from the Firebase console it will not redirect to the desired page. After many days I found an extension which supports all the features. just install and try inside your project and use it. Hope it will work for you.
For installation of the extension npm i cordova-plugin-firebasex

Related