title: How to get GCM error message 'NotRegistered' using PushSharp
body: <p>I am trying to figure out how to get a Google GCM response (ie NotRegistered error) so that I may remove the GCM info from the users account.</p>
  
  <p>From <a href="http://developer.android.com/guide/google/gcm/gcm.html" rel="nofollow">GCM Archetecture Overview</a> (in regards to unregistering a device from GCM), they state "It is only unregistered when the GCM server tries to send a message to the device and the device answers that the application is uninstalled or it does not have a broadcast receiver configured to receive com.google.android.c2dm.intent.RECEIVE intents. At that point, you server should mark the device as unregistered (the server will receive a NotRegistered error)."</p>
  
  <p>Within PushSharp for Mono for Android; how do you get the Google Response when trying to send a message to the user and instead you receive a "NotRegistered error" from Google? To send a message, I have this code:</p>
  
  <pre><code>    var push = new PushService();
  
      // setup channel settings: sender id, access key, registration package name
      var settings = new GcmPushChannelSettings(&lt;&gt;, &lt;&gt;, &lt;PACKAGE&gt;);
      push.StartGoogleCloudMessagingPushService(settings);
      var android = NotificationFactory.AndroidGcm();
      android = android.ForDeviceRegistrationId(GCM_Id); 
          push.QueueNotification(android.WithJson("{\"alert\":\"" + message + "\",\"URL\":\"" + URL + "\"}")); 
  </code></pre>
  
  <p>How do I get the response from Google to know if 1. the message went through 2. the app was uninstalled or 3. getting the NotRegistered error so that I may remove the GCM Id from the users account?</p>
  
  <p>Looking forward to any help I can get for this. The code above uses PushSharp for Mono for Android (MonoDroid) and it works flawlessly in sending a message to the user. <a href="https://github.com/Redth/PushSharp/" rel="nofollow">PushSharp</a> is amazing and I strongly recommend it for sending messages to your user via GCM.</p>