templates icon indicating copy to clipboard operation
templates copied to clipboard

fix bug 🐛 push notifications not working for node

Open Snehasis4321 opened this issue 10 months ago â€ĸ 2 comments

What does this PR do?

This PR fix the issue where push notification does not work correctly for push-notification-with-fcm template for node.

Test Plan

When trying to use push notification fcm cloud function from templates, I found that the function is not working correctly.

Then, I came across this bug 🐛.

On previous code:

  • main.js - line : 26 token: req.deviceToken,

    this will be
    token: req.body.deviceToken, for that reason the correct device token was not reaching to the sendPushNotification().

  • on utils.js everytime we were calling sendPushNotification function we were initializing admin.initializeApp ,

    This gives the error firebase-admin already initialized.

    To fix we need to initialize only once, so initializing outside before calling the sendPushNotification().

after modifying all this it is now working fine.

Feature added :

added a feature to pass additional data payload within the message with the notification.

Have you read the Contributing Guidelines on issues?

Yes

Snehasis4321 avatar Apr 26 '24 10:04 Snehasis4321