Description
Issue Description
I've recently moved my Parse Server instance to Heroku. I've put my push logic in Cloud Code instead of using client push and I can send and receive push notifications.
My issue is that the status of the push object is stuck at SENDING in Parse Dashboard ("status": "running" on the mongo object) when one of the pushes can't be delivered to an installation.
Example: I send a push to a list of users, but some of them have an installation with no deviceToken configured. Those with a deviceToken receive the push, but the others don't.
That's an expected result, but the push status will stay forever in the SENDING state and I'm not sure if I should worry about it or not.
Note: The push status is changed correctly to SENT if all the Installations have a deviceToken and the number of push sent matches the number of push delivered. Also this behaviour did not occurred when I was using client push.
Steps to reproduce
Send a push to one or more installations with some correctly configured and some with no deviceToken.
Expected Results
Those with a deviceToken receive the push, but the others don't.
The push status change to something other than "running" even if some failed.
Actual Outcome
The push object is stuck forever at SENDING in Parse Dashboard ("status": "running" on the mongo object) even is some notifications were delivered.
I'm not sure if this is a big issue and if I should worry about the server trying to send pushes indefinitely.
Environment Setup
-
Server
- parse-server version : 2.3.5
- Hardware: Standard-1x (512 MB)
- Localhost or remote server?: Heroku
-
Database
- MongoDB version: 3.0.14
- Hardware: Shared Cluster
- Localhost or remote server? mLab
Logs/Trace
Example: 3 pushes sent, 1 device received it, 2 failed because of missing deviceToken. Push object now in sending state forever.
2017-02-24T13:59:29.004277+00:00 app[web.1]: �[32minfo�[39m: Ran cloud function sendPushToRecipients for user xVOydE7ugH with:
2017-02-24T13:59:29.004293+00:00 app[web.1]: Input: {"recipients":["dpVQ9ZQypH","Vs3OADhHnS"],"data":{"alert":"test.","NTYPE":"NEW","badge":1,"sound":"default"},"appVersion":"1"}
2017-02-24T13:59:29.004295+00:00 app[web.1]: Result: "Push Sent!" functionName=sendPushToRecipients, recipients=[dpVQ9ZQypH, Vs3OADhHnS], alert=test., NTYPE=NEW, badge=1, sound=default, appVersion=519, user=xVOydE7ugH
_PushStatus object
{
"_id": "ZieiF3w31X",
"pushTime": "2017-02-24T13:59:28.981Z",
"query": "{\"currentProfile\":{\"$inQuery\":{\"where\":{\"objectId\":{\"$in\":[\"dpVQ9ZQypH\",\"Vs3OADhHnS\"]}},\"className\":\"Profile\"}},\"appVersion\":\"1\"}",
"payload": "{\"alert\":\"test",\"NTYPE\":\"NEW\",\"badge\":1,\"sound\":\"default\"}",
"source": "rest",
"status": "running",
"numSent": 1,
"pushHash": "882c51079dfab452aed1f146fedb37a2",
"_wperm": [],
"_rperm": [],
"_acl": {},
"_created_at": {
"$date": "2017-02-24T13:59:28.981Z"
},
"_updated_at": {
"$date": "2017-02-24T13:59:29.066Z"
},
"count": 3,
"sentPerType": {
"ios": 1
}
}
Cloud Code
Parse.Cloud.define("sendPushToRecipients", function(request, response) {
var profileQuery = new Parse.Query("Profile");
profileQuery.containedIn("objectId", request.params.recipients);
var installationQuery = new Parse.Query(Parse.Installation);
installationQuery.matchesQuery("currentProfile", profileQuery);
installationQuery.equalTo("appVersion", request.params.appVersion);
Parse.Push.send({
expiration_interval:600,
where: installationQuery,
data: request.params.data
}, {
success: function() {
response.success("Push Sent!");
},
error: function(error) {
response.error("Push failed: " + error);
},
useMasterKey: true
});
});