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

Update example to find "bad" tokens #333

Merged
merged 1 commit into from
Jul 18, 2019
Merged
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: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ sender.send(message, { registrationTokens: registrationTokens }, 10, function (e
// 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) {
var failed_tokens = response.results // Array with result for each token we messaged
.map((res, i) => res.error ? registrationTokens[i] : null) // If there's any kind of error,
// pick _the token_ from the _other_ array
.filter(token => token); // Remove all the null values
var failed_tokens = registrationTokens.filter((token, i) => response[i].error != null);
console.log('These tokens are no longer ok:', failed_tokens);
});
```
Expand Down