Skip to content

Commit

Permalink
Merge pull request #333 from sidhantpanda/patch-1
Browse files Browse the repository at this point in the history
Update example to find  "bad" tokens
  • Loading branch information
hypesystem authored Jul 18, 2019
2 parents 4b74526 + 1816786 commit 8bae681
Showing 1 changed file with 1 addition and 4 deletions.
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

0 comments on commit 8bae681

Please sign in to comment.