title: How to send push notifications form javascript using quickblox
body: <p>I am trying to send push notifications messages through Quickblox from my backend server. The code that does this goes like the following:</p>
  
  <pre><code>    app.post('/requests', function(req, res) {
  
      var mobileNumber = req.param('mobile_number');
  
      if (typeof mobileNumber === 'undefined') {
          return res.badRequest("Parameters missing: [mobile_number]");
      }
  
      var query = {
          international_number: mobileNumber
      }
      User.findOne(query, function(err, user) {
          if (err) {
              return res.dbError(err);
          }
          if (!user) {
              console.log("User not found");
              return res.apiError("NOT_FOUND");
          }
  
          var request = new Request();
          request.sender_id = req.user._id;
          request.receiver_id = user._id;
          request.status = 'pending';
  
          request.save(function(err) {
              if (err) {
                  return res.dbError(err);
              }
              var response = {};
              response.image_url = user.image_url;
              response.id = request._id;
  
              // ¡TODO! Notify the end user -- Quickblox 
              QB.createSession(function(err, result) {
                  if (err) {
                      console.log(err);
                      return res.apiError();
                  }
                  console.log("**** SESSION CREATE ****")
                  console.log(result);
                  var params = {
                      login: req.user.qb_username,
                      password: req.user.qb_password
                  }
                  console.log("LOGIN PARAMS");
                  console.log(params);
                  QB.login(params, function(err, result) {
                      if (err) {
                          console.log(err);
                          return res.apiError();
                      }
                      console.log("**** USER LOGIN ****")
                      console.log(result);
                      var params = {
                          notification_type: 'push',
                          environment: 'production',
                          user : {
                              ids: user.qb_id
                          },
                          message: 'SSBsb3ZlIE0mTSdzISBFc3BlY2lhbGx5IHJlZCBvbmUh',
                          push_type: user.device.notification_channel
                      }
                      console.log("EVENTS CREATE PARAMS");
                      console.log(params);
                      QB.messages.events.create(params, function(err, result) {
                          if (err) {
                              console.log(err);
                              return res.apiError();
                          }
                          console.log("**** MESSAGE EVENT CREATE ****");
                          console.log(result);
                          console.log(result.event.subscribers_selector);
                          QB.messages.events.list(function(err, result) {
                              if (err) {
                                  console.log(err);
                                  return res.apiError();
                              }
                              console.log(result);
                              console.log("**** EVENTS LIST ****");
                              console.log(result.items);
                              res.apiSend(response);
  
                          });
                      });
                  });
              });
          });
      });
  });
  </code></pre>
  
  <p>Note that I am logging the response after every single Quickblox request. So the log after QB.messages.events.create() is the following:</p>
  
  <pre><code>**** MESSAGE EVENT CREATE ****
  { event: 
     { active: true,
     application_id: 18113,
     created_at: '2015-01-13T10:32:45Z',
     date: null,
     end_date: null,
     event_type: 'one_shot',
     id: 1809320,
     message: 'data.message=SStsb3ZlK00lMjZNJTI3cyUyMStFc3BlY2lhbGx5K3JlZCtvbmUlMjE=',
     name: null,
     occured_count: 0,
     period: null,
     updated_at: '2015-01-13T10:32:45Z',
     user_id: 2185263,
     notification_channel: { name: 'gcm' },
     subscribers_selector: 
        { environment: 'production',
          tags_query: null,
          user_ids: [Object] } } }
  </code></pre>
  
  <p>and when i list the events using QB.messages.events.list() i get the following response:</p>
  
  <pre><code>{ current_page: 1,
    per_page: 10,
    total_entries: 19,
    items: 
       [ { event: [Object] },
         { event: [Object] },
         { event: [Object] },
         { event: [Object] },
         { event: [Object] },
         { event: [Object] },
         { event: [Object] },
         { event: [Object] },
         { event: [Object] },
         { event: [Object] } ] }
  </code></pre>
  
  <p>Therefore it says that there are 19 entries in the messages queue and everything seems to be OK.
  However when I login to my Quickblox account and check the messages queue it is always empty and therefore no messages are scheduled to be sent. Note as well that subscriptions show the users subscribed to push notification services such as 'gcm' and 'apns'. Can anyone help me find out why is this happening please?</p>