Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: FCM push notification overrides are only applied to first device token #4850

Closed
2 tasks done
strangeAeon opened this issue Nov 15, 2023 · 0 comments · Fixed by #4866
Closed
2 tasks done
Labels

Comments

@strangeAeon
Copy link
Contributor

📜 Description

When sending push notifications with overrides (e.g. setting the type to data) to a subscriber with multiple FCM device tokens, only the first registered device will receive the notification with the correct overrides. The first device token might not even be valid anymore, so the notification with the correct overrides might not have been received at all.

Looking at the code it seems that the options object including the overrides is modified in-place, e.g.:

delete (options.overrides as { type?: string })?.type;

and this code gets called when iterating over the device tokens of the subscriber:

👟 Reproduction steps

curl --location --request POST 'https://eu.api.novu.co/v1/events/trigger' \
     --header 'Authorization: ApiKey <REPLACE_WITH_API_KEY>' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "name": "post-comment-mention",
         "to": {
           "subscriberId": "<ID-OF-SUBSCRIBER-WITH-MULTIPLE-FCM-DEVICE-TOKENS>"
         },
         "payload": {
           "data": {
             "user": {
               "fullName": "Test SF",
             },
           },
         },
         "overrides": {
           "type": "data",
           "fcm": {
             "type": "data",
             "data": {
               "userFullName": "Test SF",
             }
           },
           "apns": {
             "payload": {
               "data": {
                 "user": {
                   "fullName": "Test SF",
                 },
               },
             }
           }
         }
       }'

👍 Expected behavior

All push notifications for a subscriber with multiple device tokens should be sent with all overrides provided.

Example notification with type data set via overrides (currently no message body due to #4639)

notification_expected

👎 Actual Behavior with Screenshots

Example notification that should have been sent with type data set via overrides (expected no message body due to #4639)

notification_received

Novu version

Novu SaaS

npm version

No response

node version

No response

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant