-
Notifications
You must be signed in to change notification settings - Fork 389
Allow fcmOptions
in payload keys
#629
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
Conversation
In #597 support was added for `fcmOptions` for specifying the analytics label for notifications. Unfortunately, the allowable list of keys wasn't updated to support it.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@hiranya911 I tried to add all the right specs for this to ensure that this change is correct and avoids regressions, which pass locally, but I note that
|
I opted for this implementation for the index signature: /* Payload for fcmOptions messages */
export interface FcmOptionsPayload {
analyticsLabel?: string;
[key: string]: string;
} you're welcome to edit the PR to adjust if this isn't suitable 😄 or just let me know what to change. Thanks! |
I have a few concerns with this change.
@chong-shao wdyt? |
Thanks @hiranya911 for the review. For some extra context which may help with deciding about this PR, here's how we're using this code inside a cloud function using messaging.sendToDevice: const admin = require('firebase-admin')
admin.messaging().sendToDevice(
pushToken,
data: {
custom_notification: JSON.stringify(
Object.assign({ deepLink, show_in_foreground: true }, notification)
),
deepLink,
},
fcmOptions: {
analyticsLabel: 'test.analytics.label',
},
notification,
) We saw this error: { Error: Messaging payload contains an invalid "fcmOptions" property. Valid properties are "data" and "notification". I guess that is triggering usage of the legacy APIs when using MessagingPayload; is there another way to do this that uses the non-legacy API and allows us to use Thanks for your time! 😄 |
You're using the legacy FCM APIs ( |
@parndt please take a look at the Node.js examples on this page and update your code to use the new API: https://firebase.google.com/docs/cloud-messaging/send-message The old API doesn't support |
Thanks a lot! 🙇♂️ that's exactly what I needed. |
In #597 support was added for
fcmOptions
for specifying the analytics label for notifications.Unfortunately, the list of valid payload keys wasn't extended to support it.