node_apns
node_apns copied to clipboard
Sending payload with just badge returns invalid
When trying to send a push notification which should just clear the badge count (e.g. set it to 0) an error ("Invalid") is returned.
Modifying the isValid method of Notification to be
Notification.prototype.isValid = function () {
if (!this.device || !this.device.isValid()) return false;
var normalized = this.normalizedPayload();
if (Buffer.byteLength(JSON.stringify(normalized), this.encoding) > 256) return false;
if (!normalized.aps.alert && !normalized.aps.sound && normalized.aps.badge === undefined) return false;
return true;
};
allows a badge value of 0 but not undefined
Hey @JNK Thanks for spotting this! Would you like to make a PR ?