title: GCM push notification not received (gone through all)
body: <p>Before you point this as a duplicate, I know this has been asked many a times but it seems after the launch of new GCM (that which requires one to include play services project as library) <a href="http://developer.android.com/google/gcm/client.html" rel="nofollow">things have changed on how to correctly implement gcm in our code</a>.</p>
  
  <p>The breakpoint in my <code>GCMIntentService.java</code> and <code>GcmBroadcastReceiver.java</code> gets hit on register since I have set <code>&lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt;</code> in the manifest but the breakpoints don't get hit when i send a push from the server. Here's all which you would ever need:</p>
  
  <h2>Relevant <code>AndroidManifest.xml</code></h2>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.aceast.waveindia"
      android:versionCode="1"
      android:versionName="waveindia1" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="9"
          android:targetSdkVersion="11" /&gt;
  
      &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;uses-permission
          android:name="com.aceast.waveindia.permission.C2D_MESSAGE"
          android:protectionLevel="signature" /&gt;
  
  
  
   &lt;!-- App receives GCM messages. --&gt;
      &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
      &lt;!-- GCM connects to Google Services. --&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;!-- GCM requires a Google account. --&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;!-- Keeps the processor from sleeping when a message is received. --&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  
  
          &lt;receiver
              android:name=".GcmBroadcastReceiver"
              android:permission="com.google.android.c2dm.permission.SEND" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
                  &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt;
  
                  &lt;category android:name="com.aceast.waveindia" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
          &lt;service android:name=".GcmIntentService" /&gt;
  </code></pre>
  
  <h2><code>GCMBroadcastReceiver.java</code></h2>
  
  <pre><code>    public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
  
          @Override
          public void onReceive(Context context, Intent intent) {
              // Explicitly specify that GcmIntentService will handle the intent.
  //breakpoint gets hit on register here...
              ComponentName comp = new ComponentName(context.getPackageName(),
                      GcmIntentService.class.getName());
              // Start the service, keeping the device awake while it is launching.
              startWakefulService(context, (intent.setComponent(comp)));
              setResultCode(Activity.RESULT_OK);
          }
      }
  </code></pre>
  
  <h2>Part of GCMIntentService which breakpoint hits on <code>register</code></h2>
  
  <pre><code> @Override
      protected void onHandleIntent(Intent intent) {
          Bundle extras = intent.getExtras();
          GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
          // The getMessageType() intent parameter must be the intent you received
          // in your BroadcastReceiver.
          String messageType = gcm.getMessageType(intent);
  </code></pre>
  
  <h2><code>.NET code</code> which triggers push</h2>
  
  <pre><code>public string SendNotification()
      {
  
          var value = Message;
          WebRequest tRequest;
          tRequest = WebRequest.Create("https://android.googleapis.com/gcm/send");
          tRequest.Method = "post";
          tRequest.ContentType = " application/x-www-form-urlencoded;charset=UTF-8";
         // tRequest.ContentType = " application/json;charset=UTF-8";
          tRequest.Headers.Add(string.Format("Authorization: key={0}", GOOGLE_APPID));
  
          tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID));
  
          string postData = "collapse_key=score_update&amp;time_to_live=108&amp;delay_while_idle=1&amp;data.message=" + value + "&amp;data.time=" + System.DateTime.Now.ToString() + "&amp;registration_id=" + DeviceID + "";
          Console.WriteLine(postData);
          Byte[] byteArray = Encoding.UTF8.GetBytes(postData);
          tRequest.ContentLength = byteArray.Length;
  
          Stream dataStream = tRequest.GetRequestStream();
          dataStream.Write(byteArray, 0, byteArray.Length);
          dataStream.Close();
  
          WebResponse tResponse = tRequest.GetResponse();
  
          dataStream = tResponse.GetResponseStream();
  
          StreamReader tReader = new StreamReader(dataStream);
  
          String sResponseFromServer = tReader.ReadToEnd();
  
  
          tReader.Close();
          dataStream.Close();
          tResponse.Close();
          return sResponseFromServer;
      }
  </code></pre>
  
  <h2>Local firewall has 5228-5230 ports unblocked</h2>
  
  <p>Now can you point the error?</p>