title: Use collapse key for 2 type ofmessages gcm
body: <p>In my gcm android app I am sending 2 types of messages from application server.I got the idea about what is collapse key, but Idont know how to use.These are the two types of messages.
  1.</p>
  
  <pre><code>$message = array(
          "price" =&gt; "signal",
          "type" =&gt; $user_type,
          "date" =&gt; $date1,
          "name" =&gt; $signal_name,
          "buy" =&gt; $price,
          "stop" =&gt; $stop,
          "tv" =&gt; $trig_value,
          "tp" =&gt; $profit,       
          "res" =&gt; $result,
      );
  </code></pre>
  
  <p>second one</p>
  
  <pre><code>$message = array(
        "price" =&gt; "instru",
        "price1" =&gt; $trade1,
         "price2" =&gt; "$trade2",
        "price3" =&gt; "$trade3",
        "price4" =&gt; "$trade4",
        "price5" =&gt; "$date"
     );
  </code></pre>
  
  <p>What I need is the last messages send for both of the message types persist in gcm server.How can I do that.I am giving the gcm class also .Please help.</p>
  
  <p>GCM.php</p>
  
  <pre><code>&lt;?php
  
  
  
  class GCM {
  
      //put your code here
      // constructor
      function __construct() {
  
      }
  
      /**
       * Sending Push Notification
       */
      public function send_notification($registatoin_ids, $message) {
          // include config
          include_once './config.php';
  
          // Set POST variables
          $url = 'https://android.googleapis.com/gcm/send';
  
          $fields = array(
              'registration_ids' =&gt; $registatoin_ids,
              'data' =&gt; $message,
          );
  
          $headers = array(
              'Authorization: key='.GOOGLE_API_KEY,
              'Content-Type: application/json'
          );
          // Open connection
          $ch = curl_init();
  
          // Set the url, number of POST vars, POST data
          curl_setopt($ch, CURLOPT_URL, $url);
  
          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  
          // Disabling SSL Certificate support temporarly
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  
          curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
  
          // Execute post
          $result = curl_exec($ch);
          if ($result === FALSE) {
              die('Curl failed: ' . curl_error($ch));
          }
  
          // Close connection
          curl_close($ch);
          echo $result;
      }
  
  }
  
  ?&gt;
  </code></pre>