Skip to content

Push with custom Installation query doesn't reach device #1439

Closed
@ullstrm

Description

@ullstrm

Environment Setup

My package.json (I started the server from this parse-server-example, but I'm hosting it on heroku now):

{
  "name": "parse-server-example",
  "version": "1.3.0",
  "description": "An example Parse API server using the parse-server module",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/ParsePlatform/parse-server-example"
  },
  "license": "MIT",
  "dependencies": {
    "express": "~4.11.x",
    "kerberos": "~0.0.x",
    "parse": "~1.8.1",
    "parse-server": "~2.2.6",
    "parse-server-simple-mailgun-adapter":"~1.0.0"
  },
  "scripts": {
    "start": "node index.js"
  },
  "engines": {
    "node": ">=4.3"
  }
}

My cloud code:

var pushQuery = new Parse.Query(Parse.Installation, { useMasterKey: true });

  pushQuery.equalTo('userId', 'Y3Vy6tJYpz');

  Parse.Push.send({
    where: { pushQuery },
    data: {
      alert: 'Test push to Y3Vy6tJYpz',
      badge: 0,
      sound: 'default'
    }
  }, { useMasterKey: true })
  .then(function() {
    console.log("pushQ brodie: " + JSON.stringify(pushQuery));
    response.success();
  }, function(error) {
    console.error("PUSH ERROR: " + error);
    response.success();
  });

My _PushStatus document:

{
  "_id": ObjectId("5708d8cc0384d1110020e74a"),
  "objectId": "bOY7nDeYET",
  "pushTime": "2016-04-09T10:26:20.662Z",
  "_created_at": new Date(1460197580662),
  "query": "{\"pushQuery\":{\"where\":{\"userId\":\"Y3Vy6tJYpz\"}}}",
  "payload": {
    "alert": "Test push to Y3Vy6tJYpz",
    "badge": 0,
    "sound": "default"
  },
  "source": "rest",
  "title": null,
  "expiry": null,
  "status": "succeeded",
  "numSent": 0,
  "pushHash": "866b3dc5c93f5a5bc3f33c325ec08f55",
  "_wperm": [

  ],
  "_rperm": [

  ],
  "numFailed": 0
}

Im interested in the part about the query:
"query": "{\"pushQuery\":{\"where\":{\"userId\":\"Y3Vy6tJYpz\"}}}",
When looking trough other issues here I find that the query-string looks more like this (I.e. not the "pushQuery" name existing, see issue #1127):
"query" : "{\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"sdOD1uHCCa\"}}"
What is this? Am I missing some fundamental thing in node.js, or why is my server behaving this way?

FYI, a full broadcast push works splendid, i.e:

...
Parse.Push.send({
    where: { Parse.Installation },
...

and the _PushStatus for this broadcast looks like this:

{
  "_id": ObjectId("5708dafe0384d1110020e74c"),
  "objectId": "TFdg5DHvv8",
  "pushTime": "2016-04-09T10:35:42.323Z",
  "_created_at": new Date(1460198142323),
  "query": "{}",
  "payload": {
    "alert": "Broadcast test push from app",
    "badge": 0,
    "sound": "default"
  },
  "source": "rest",
  "title": null,
  "expiry": null,
  "status": "succeeded",
  "numSent": 1,
  "pushHash": "93dcdd557c4cb2558713d589261684ce",
  "_wperm": [

  ],
  "_rperm": [

  ],
  "numFailed": 0,
  "sentPerType": {
    "ios": 1
  }
}

I only have one installation object, and it looks like this (And as I said, the broadcast push works):

{
  "_id": "ZiyJKc7l5k",
  "timeZone": "Europe/Stockholm",
  "appVersion": "1",
  "appName": "XXXXXXXX",
  "deviceType": "ios",
  "badge": 1,
  "installationId": "aa23f82a-84b6-4c2c-af58-e82b8cd89407",
  "appIdentifier": "XXXXXXXX",
  "parseVersion": "1.12.0",
  "localeIdentifier": "en-SE",
  "_updated_at": new Date(1460191812187),
  "_created_at": new Date(1460191609057),
  "deviceToken": "09638XXXXXXXXXXXXXXXXXXXad9b7382ccf6910",
  "_p_user": "_User$Y3Vy6tJYpz",
  "userId": "Y3Vy6tJYpz"
}

Is this a bug or am I missing something? Thank you for your help. I hope that this issue is well formed, and I hope that I'm not just missing something obvious. I'm new to node.js.


Also, the verbose log output:
2016-04-09T11:01:28.455088+00:00 app[web.1]: verbose: sending push to 0 installations
2016-04-09T11:01:28.455777+00:00 app[web.1]: verbose: sent push! 0 success, 0 failures

And for the broadcast:
2016-04-09T10:59:55.870824+00:00 app[web.1]: verbose: sending push to 1 installations
2016-04-09T10:59:56.715648+00:00 app[web.1]: verbose: sent push! 1 success, 0 failures

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions