It seems payload key from my note doesn't get delivered. When I receive the payload with didReceiveRemoteNotification I only see aps key. I don't see the payload. If I send following payload by Pusher app, eveything works as expected.
let note = new apn.Notification();
note.expiry = 0;
note.badge = 1;
note.collapseId = job._id;
note.alert = {
title: "Some Title",
body: "Some Body",
}
note.contentAvailable = 1;
note.payload = { '_id': job.id };
note.topic = "com.my.topic";
console.log('Note: ' + JSON.stringify(note)); // When I print I also don't see `payload`
const devices = await Database.getAllDevices(job.owner);
const tokens = _.map(devices, 'token');
const result = await apnProvider.send(note, tokens);
EDIT: I found the error if payload has a null value, then payload gets ignored. Since I made a typo in job.id; it sets _id as null, and that value is lost during return Object.assign({}, this.payload, { aps: this.apsPayload() }); So it seems, you can't use null in the payload.
It seems
payload
key from my note doesn't get delivered. When I receive the payload withdidReceiveRemoteNotification
I only seeaps
key. I don't see the payload. If I send following payload by Pusher app, eveything works as expected.Here is my code
EDIT: I found the error if payload has a null value, then payload gets ignored. Since I made a typo in job.id; it sets
_id
as null, and that value is lost duringreturn Object.assign({}, this.payload, { aps: this.apsPayload() });
So it seems, you can't use null in the payload.