I have a messaging app and I use Parse server as my backend.
Push notifications work just fine between my users, however whenever I send a message from my user account, the recipient does not get a push notification (even though it looks like it was delivered to APNS just fine). If I log in with another users account on my phone, push notifs are delivered fine, but as soon as I log back into my own account, push notifs are not received by others.
My code is not doing anything different for my user than it is for others. The message is saved to the database just fine (recipients can manually refresh to get my messages on their app - they just don't get the push notif).
It seems like APNS for some reason is not delivering just the push notifs for my user.
Anybody experience anything like this before? Or any ideas how I can debug this?
UPDATE: Cloud function that sends the push
Parse.Cloud.define("sendPushToUser2", function(request, response) {
var senderUser = request.user;
var recipientUserId = request.params.recipientId;
var message = request.params.message;
if (message.length > 140) {
message = message.substring(0, 137) + "...";
}
// Find devices associated with the recipient user
var recipientUser = new Parse.User();
recipientUser.id = recipientUserId;
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo("user", recipientUser);
// Send the push notification to results of the query
Parse.Push.send({
where: pushQuery,
data: {
alert: senderUser.get("name"),
badge: "Increment",
message: message,
title: senderUser.get("name"),
senderObjId: senderUser,
sound: "sounds.caf",
"content-available": 1
}
}, { success: function() {
console.log("PUSH SUCCESSFUL");
}, error: function(error) {
console.log("PUSH ERROR" + error.message);
}, useMasterKey: true});
});
My problem was that the this object "senderObjId: senderUser" that I was passing in the data was very large. It probably exceeded the payload limit. I only really needed 3 items from that object and passed those instead, and it started working. That object kept building up over time without me noticing, and it only affected users who had a lot built up in that object.
Thanks for you help with this @DaviMacêdo.