Skip to content
Advertisement

API sent Firebase notifications not received on device

I’m trying to send notifications based on business logic that runs (on nodejs) on my server via a cron.

Issue

Notifications aren’t appearing on the device.

Description

I’m using the firebase admin node package.

My code looks something like this

JavaScript

My log output is something like this

JavaScript

Everything I’m seeing suggests this should be sent!

Advertisement

Answer

sendMulticast and the Admin FCM APIs allow you to multicast a message to a list of device registration tokens. You can specify up to 500 device registration tokens per invocation.

sendMulticast take 2 arguments as input, 1st one is notification which contains the title and body of the message. The other argument is fcmTokens with type array, so you must pass that argument as array even though there is only one fcmToken

JavaScript

app.js

JavaScript

This is tested code and working in a live environment.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement