Skip to content

Commit

Permalink
fix: promises should log/warn after trying send method
Browse files Browse the repository at this point in the history
  • Loading branch information
youralien committed Jun 3, 2021
1 parent 8280f28 commit 6268d4d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/server/push.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,16 @@ Push.Configure = function(options) {

apnConnection.send(note, userToken).then( (response) => {
response.sent.forEach( (token) => {
notificationSent(user, token);
console.log(`notification success for ${JSON.stringify(token)}`);
});
response.failed.forEach( (failure) => {
if (failure.error) {
// A transport-level error occurred (e.g. network problem)
notificationError(user, failure.device, failure.error);
console.warn(`potential network problem for device ${JSON.stringify(failure.device)}: ${JSON.stringify(failure.error)}.`);
} else {
// `failure.status` is the HTTP status code
// `failure.response` is the JSON payload
notificationFailed(user, failure.device, failure.status, failure.response);
console.warn(`notification failure ${JSON.stringify(failure.status)} on device ${JSON.stringify(failure.device)}: ${JSON.stringify(failure.response)}.`);
}
});
});
Expand Down

0 comments on commit 6268d4d

Please sign in to comment.