Program doesn't terminate when running FCM.sendToDevice in nodejs.
See original GitHub issue[READ] Step 1: Are you in the right place?
- For issues or feature requests related to the code in this repository
file a Github issue.
- If this is a feature request make sure the issue title starts with “FR:”.
- For general technical questions, post a question on StackOverflow with the firebase tag.
- For general Firebase discussion, use the firebase-talk google group.
- For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.
[REQUIRED] Step 2: Describe your environment
- Operating System version: Mac OS High Sierra (10.13.1)
- Firebase SDK version: firebase: (^4.5.1)
- Library version: firebase-admin (^5.4.2)
- Firebase Product: FCM / admin.messaging()
[REQUIRED] Step 3: Describe the problem
NodeJS program doesn’t terminate after running FCM command.
Steps to reproduce:
- save the following code as: fcm-test.js
- run the code with
node fcm-test.js
- In my enviroment, it’ll not stop untill you forcefully stop it by pressing CTRL+C.
Relevant Code:
const admin = require('firebase-admin');
const serviceAccount = require("../../../service-accounts/production.json");
const registrationTokens = require('./tokens');
// ["someShortString1:someLongString1", "someShortString2:someLongString2", ...];
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
})
const body = 'body';
const title = 'title';
const payload = {
data: {
body,
title
},
notification: {
body,
title
}
}
const fcm = admin.messaging();
const printJSON = (thing) => { console.log(JSON.stringify(thing, null, 2))};
fcm.sendToDevice(registrationTokens, payload).then(printJSON).catch(printJSON);
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Program won't exit when call to Firebase Cloud Messaging ...
Currently, the problem is when I call firebase.admin.messaging().sendToDevice , my app never ends its execution. Here is the code : main.js :
Read more >Build app server send requests | Firebase Cloud Messaging
Using the Firebase Admin SDK or FCM app server protocols, you can build message requests and send them to these types of targets:....
Read more >Send push notifications to Android devices using Firebase ...
In this tutorial, you create a blank Android app that receives push notifications by using Firebase Cloud Messaging (FCM).
Read more >firebase-admin.Messaging.sendToDevice JavaScript and ...
sendToDevice (registrationToken, payload, options) ... [END function_get_token] //[START pushNotification] function pushNotification(deviceID, accessToken, ...
Read more >Cloud Messaging | FlutterFire
FCM via APNs does not work on iOS Simulators. ... Terminated, When the device is locked or the application is not running. The...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
How was the developer supposed to know they had to call
app.delete()
?Given that you’re calling
res.send()
in each possible case, I believe it’s fine.