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

Add fcm_options as allowed params to message object #342

Merged
merged 3 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ sender.send(message, { registrationTokens: registrationTokens }, 10, function (e
else console.log(response);
});

// Q: I need to remove all "bad" token from my database, how do I do that?
// Q: I need to remove all "bad" token from my database, how do I do that?
// The results-array does not contain any tokens!
// A: The array of tokens used for sending will match the array of results, so you can cross-check them.
sender.send(message, { registrationTokens: registrationTokens }, function (err, response) {
sender.send(message, { registrationTokens: registrationTokens }, function (err, response) {
var failed_tokens = registrationTokens.filter((token, i) => response[i].error != null);
console.log('These tokens are no longer ok:', failed_tokens);
});
Expand Down Expand Up @@ -167,6 +167,7 @@ This is due to [a restriction](https://firebase.google.com/docs/cloud-messaging/
|dryRun|Optional, JSON boolean|This parameter, when set to true, allows developers to test a request without actually sending a message.|
|data|Optional, JSON object|This parameter specifies the custom key-value pairs of the message's payload.|
|notification|Optional, JSON object|This parameter specifies the predefined, user-visible key-value pairs of the notification payload. See "Notification payload option table" below for more details.|
|fcm_options|Optional, JSON object|This parameter is used to pass FCM specific options as outlined [here](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#FcmOptions)|

## Notification usage

Expand Down
9 changes: 6 additions & 3 deletions lib/message-options.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* This module defines all the arguments that may be passed to a message.
*
*
* Each argument may contain a field `__argName`, if the name of the field
* should be different when sent to the server.
*
*
* The argument may also contain a field `__argType`, if the given
* argument must be of that type. The types are the strings resulting from
* calling `typeof <arg>` where `<arg>` is the argument.
*
*
* Other than that, the arguments are expected to follow the indicated
* structure.
*/
Expand Down Expand Up @@ -51,5 +51,8 @@ module.exports = {
__argType: "object"
//TODO: There are a lot of very specific arguments that could
// be indicated here.
},
fcm_options: {
__argType: "object"
}
};