1

Most of the times when I try to make a Push, none is beign sent. "Pushes sent" field in Push console tab displays 0. Despite that there are installations matching the query. When I uncomment this few lines below, installation is being returned successfully.

When trying to send Push manually via panel, when setting audience parameters, correct number of recipients is being displayed. After sending, once again "Pushes sent" displays ZERO.

Installations have deviceTokens [iOS]. That's my cloud code:

var installationQuery = new Parse.Query(Parse.Installation);
var inUserQuery = new Parse.Query(PKUser);
inUserQuery.equalTo("objectId", toUserID);
installationQuery.matchesQuery("user", inUserQuery);

// installationQuery.find({      
//     success: function(iresults) {
//         console.log("inst results");
//         console.log(iresults);
//     }, error: function(err) { 
//         console.log("inst error");
//         console.log(err);
//     }
// });

// sending a push
Parse.Push.send({
    where: installationQuery,
    data: {
        "alert": user.get("firstName")+": "+shortenedMessage,
        "badge": "Increment",
        "content-available": 1,
        "text": message,
        "from": user.id,
        "id": object.id
    }
}, { success: function() { 
        response.success("ok");
    }, error: function(err) { 
        response.error("push");
    }
});
rici
  • 234,347
  • 28
  • 237
  • 341
Rabur
  • 31
  • 1
  • 2

1 Answers1

0

When trying to use only the user ID for finding the users installation you should use a pointer object and passing that to installationQuery since equalTo on Parse.User compares the objectId no need for matchesQuery. If this doesn't work then you will need to check if the device tokens you have are valid for that phone+install since device tokens can change (ios 7 device token is different for same device).

var installationQuery = new Parse.Query(Parse.Installation);

var pointerUser = new Parse.User();
pointerUser.id = toUserID;
installationQuery.equalTo("user",pointerUser);

Parse.Push.send({
    where: installationQuery,
    data: {
        "alert": user.get("firstName")+": "+shortenedMessage,
        "badge": "Increment",
        "content-available": 1,
        "text": message,
        "from": user.id,
        "id": object.id
    }
}).then(function(){
  response.success("ok");
},function(){
  response.error("push");
});
Community
  • 1
  • 1
zagu
  • 101
  • 1
  • 7
  • That doesn't help actually. I have tested installationQuery itself and it has been working correctly. Maybe deviceTokens are rejected for some reasons on the Apple side. How do I debug it? DeviceTokens are 90% correct. Could this be issue with Push Notification certificates? Thanks in advance :) – Rabur Nov 28 '14 at 15:54
  • 1
    Have you made a development push cerftificate and a production push cerftificates? And do you understand how to properly set them up? If not go to [https://www.parse.com/docs/push_guide#troubleshooting/iOS](https://www.parse.com/docs/push_guide#troubleshooting/iOS) and go over the list to double check it is a really good list of common problems. Otherwise just go back and do it from scratch following steps on this link [https://www.parse.com/docs/push_guide](https://www.parse.com/docs/push_guide). Don't forget to choose your environment on the last link - iOS, Android and so on. – zagu Nov 28 '14 at 23:15
  • Seems like regenerating of push certificates did the job! Thanks. I don't know how to mark comment as a right answer to the problem :F – Rabur Nov 29 '14 at 21:03