title: Using GCM to send notifications on app, returns InvalidRegistration error
body: <p>I'm trying to send a notification using GCM on my android device, but I always get InvalidRegistration error.</p>
  
  <p>Here is the PHP code that is supposed to send the notification:</p>
  
  <pre><code>&lt;?php
  define('API_ACCESS_KEY', 'API KEY HIDDEN');
  
  $registrationIds = array( $_GET['id']);
  
  // prep the bundle
  $msg = array
  (
      'message'   =&gt; 'TestMessage',
      'title'     =&gt; 'TestTitle',
      'subtitle'  =&gt; 'TestSubtitle',
      'tickerText'    =&gt; 'TestTicker',
      'vibrate'   =&gt; 1,
      'sound'     =&gt; 1,
      'largeIcon' =&gt; 'large_icon',
      'smallIcon' =&gt; 'small_icon'
  );
  
  $fields = array
  (
      'registration_ids'  =&gt; $registrationIds,
      'data'          =&gt; $msg
  );
  
  $headers = array
  (
      'Authorization: key=' . API_ACCESS_KEY,
      'Content-Type: application/json'
  );
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
  curl_setopt($ch, CURLOPT_POST, true );
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false );
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
  $result = curl_exec($ch );
  curl_close( $ch );
  
  echo $result;
  ?&gt;
  </code></pre>
  
  <p>This is how the registration is done: </p>
  
  <pre><code>private void registerInBackground() {
  new AsyncTask&lt;Void, Object, String&gt;() {
      @Override
      protected String doInBackground(Void... params) {
          String msg = "";
          try {
              if (gcm == null) {
                  gcm = GoogleCloudMessaging.getInstance(context);
              }
              regid = gcm.register(SENDER_ID);
              msg = "Device registered, registration ID=" + regid;
  
              //Here I save the registration ID, and when I try to use it manually, by running the PHP script above, I get the error.
              sendRegistrationIdToBackend();
  
              // Persist the registration ID - no need to register again.
              storeRegistrationId(context, regid);
          } catch (IOException ex) {
              msg = "Error :" + ex.getMessage();
          }
          return msg;
      }
  
      @Override
      protected void onPostExecute(String msg) {
          Toast.makeText(context, msg + "\n", Toast.LENGTH_SHORT).show();
      }
  
  }.execute(null, null, null);
  </code></pre>
  
  <p>After running the application, and calling the method that registers the app, I get a registration ID. Then, when I type <code>localhost/app/sendNotification.php?id=xxxxxxxxxxxxxx</code> I get </p>
  
  <pre><code>{"multicast_id":8460288429151356251,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
  </code></pre>