issue with Nodejs Sdk #17161
Unanswered
hussenIbrahim
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello
I have issue with sending notifications with Nodejs sdk , onMessage, onBackgroundMessage and onMessageOpenedApp not working , but sending notification from Firebase console everything working fine
`//
var admin = require('firebase-admin');
// 1. Download a service account key (JSON file) from your Firebase console and add to the example/scripts directory
var serviceAccount = require('./google-services.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
// 2. Copy the token for your device that is printed in the console on app start (
flutter run
) for the FirebaseMessaging exampleconst token = "YOUR_DEVICE_TOKEN";
// 3. From your terminal, root to example/scripts directory & run
npm install
.// 4. Run
npm run send-message
in the example/scripts directory and your app will receive messages in any state; foreground, background, terminated.// If you find your messages have stopped arriving, it is extremely likely they are being throttled by the platform. iOS in particular
// are aggressive with their throttling policy.
admin
.messaging()
.send(
{
token: token,
notification: {
title: 'A great title',
body: 'Great content',
imageUrl: 'https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg',
},
android: {
// Required for background/terminated app state messages on Android
priority: 'high',
},
apns: {
headers: {
"apns-priority": "5",
},
payload: {
aps: {
//or you can use 'default' for the default sound.
sound: {
critical: true,
name: 'default',
},
mutableContent: true,
contentAvailable: true,
///to send
// "condition": "!('anytopicyoudontwanttouse' in topics)"
`
Everything was working fine until 3 days ago
Beta Was this translation helpful? Give feedback.
All reactions