I am struggling with the same issue that is to receive a push notification with afterSave() cloud code and I am receiving PushStaus summary { BadDeviceToken: 1 and success: 0; what could be the reason? Is it the token format, or it has to do with communicating with APNs?
Parse.Cloud.afterSave(“Tasks”, function(request) {
const content = request.object.get(‘TaskMessage’);
const pushTo = request.object.get(‘UserNameTo’);
const sender = request.object.get(‘UserNameFrom’);
const deadline = request.object.get(‘TaskDeadline’);
let query = new Parse.Query(Parse.Installation);
query.equalTo(“userId”, pushTo);
query.descending(“updatedAt”);
return Parse.Push.send({
where: query,
data: {
title: "New request for action from " + sender,
alert: content + " deadline set to " + deadline,
badge: “Increment”,
sound: “default”
}
}, { useMasterKey: true});
});
PARSE INFO LOGS
2022-02-06T11:47:23.822Z - PushStatus wkBEpEm78k: {“summary”:{“BadDeviceToken”:1,“success”:0},“where”:{“userId":"[email protected]”},“query”:{}}
2022-02-06T11:47:23.679Z - All 1 packages were enqueued for PushStatus wkBEpEm78k
2022-02-06T11:47:23.676Z - Ran cloud function createTask for user apu3UfAqw1 with:
Input: {“userto":"[email protected]”,“taskdeadline”:“Feb 8, 2022”,“taskmessage”:“testing another push”}
Result: [{“TaskDeadline”:{"__type":“Date”,“iso”:“2021-09-17T04:00:00.000Z”},“UserNameTo":"[email protected]”,“userTo”:{"__type":“Pointer”,“className”:"_User",“objectId”:“nMDEH6Dgnk”},“TaskMessage”:“Recruitment for procurement officer”,“TaskLogo”:“”,“userFrom”:{"__type":“Pointer”,“className”:"_User",“objectId”:“apu3UfAqw1”},“UserNameFrom":"[email protected]”,“TaskStatus”:“Read”,“ActionLogo”:“”,“createdAt”:“2021-09-16T17:20:05.895Z”,“updatedAt”:“2022-01-29T11:59:15.736Z”,“message_logo”:“”,“Active”:true,“objectId”:“XMgirR8ASF”,"__type":“Object”,“className”:“Tasks”},{“TaskDeadline”:{"__type":“Date”,“iso”:“2021-10-21T12:16:28.000Z”},“UserNameTo":"[email protected]”,“userTo”:{"__type":“Pointer”,“className”:"_User",“objectId”:“nMDEH6Dgnk”},“TaskMessage”:“Develop and standardize a procedure for rounding numbers in order to provide consistency in calculating and reporting results”,“TaskLogo”:“”,“userFrom”:{"__type":“Pointer”,“className”:"_User",“objectId”:“apu3UfAqw1”},"UserNameFr… (truncated)
2022-02-06T11:47:23.667Z - afterSave triggered for Tasks for user undefined:
Input: {“TaskDeadline”:{"__type":“Date”,“iso”:“2022-02-08T00:00:00.000Z”},“TaskMessage”:“testing another push",“UserNameFrom”:"[email protected]”,“UserNameTo”:"[email protected]",“TaskStatus”:“Not Read”,“TaskLogo”:“”,“ActionLogo”:“”,“userFrom”:{"__type":“Pointer”,“className”:"_User",“objectId”:“apu3UfAqw1”},“userTo”:{"__type":“Pointer”,“className”:"_User",“objectId”:“apu3UfAqw1”},“Active”:true,“createdAt”:“2022-02-06T11:47:23.658Z”,“updatedAt”:“2022-02-06T11:47:23.658Z”,“objectId”:“6oeBHCVJf7”}
Result: {“result”:true}
2022-02-06T11:47:23.661Z - afterSave triggered for Tasks for user undefined:
Input: {“TaskDeadline”:{"__type":“Date”,“iso”:“2022-02-08T00:00:00.000Z”},“TaskMessage”:“testing another push",“UserNameFrom”:"[email protected]”,“UserNameTo”:"[email protected]",“TaskStatus”:“Not Read”,“TaskLogo”:“”,“ActionLogo”:“”,“userFrom”:{"__type":“Pointer”,“className”:"_User",“objectId”:“apu3UfAqw1”},“userTo”:{"__type":“Pointer”,“className”:"_User",“objectId”:“apu3UfAqw1”},“Active”:true,“createdAt”:“2022-02-06T11:47:23.658Z”,“updatedAt”:“2022-02-06T11:47:23.658Z”,“objectId”:“6oeBHCVJf7”}