Jacolack Jacolack - 21 days ago 6x
Swift Question

Query Session class with cloud code Parse

I am trying to send a push notification using a user's id. I have already tested sending with installationId, querying the _Installation class, but i would like to query the session class of the user pointer, to then turn around and query the installation class.

My problem is lying in the restrictions of querying the session class. I have successfully used createWithoutData() found here, and I know it is working because i can output that user. However, even after using the master key found here, the results are always empty.


The general practise for sending Push Notification to specific user is that you will store pointer to User in Installation class... for example when user register do this


if let installation = PFInstallation.current() {
    installation["user_id"] = PFUser.current()!


      var pushQuery = new Parse.Query(Parse.Installation);
      pushQuery.equalTo('user_id', tarUser);
      pushQuery.limit(1); // in case there are more Installation with the user ID, use only the latest
        where: pushQuery, // Set our Installation query
        data: {
          alert: "Some push text"
      }, {
      success: function() {
        // Push was successful

      error: function(error) {
        console.error("Got an error " + error.code + " : " + error);
       useMasterKey: true 

if I remember correctly you have to query the pointer in Cloud code with pointer structure, like this

var tarUser = { 
  __type: 'Pointer',
  className: '_User',
  objectId: 'insertObjectIDHere'