title: GCM registration : SERVICE NOT AVAILABLE on mobile network
body: <p>I am getting  SERVICE NOT AVAILABLE during GCM registration.</p>
  
  <p>Strange behavior is that the code runs fine when device is on Wifi. Fails almost always (90 % times) when it is on mobile network.</p>
  
  <p>Internet on mobile data is working fine , and other server operations are working, though they are bit slower compared to Wifi.</p>
  
  <p>I tried to add a simple loop (not exponential wait) to keep retrying after a sleep interval, but no luck. </p>
  
  <p>Moment I switch Wifi on the operation (GCM registration) succeeds.  </p>
  
  <p>Please help.</p>
  
  <p>****Update More information** ** : I tested the <a href="http://developer.android.com/google/gcm/client.html" rel="noreferrer">GCM Demo</a> on my device and it also has the same issue. Fails on mobile data, works fine on Wifi. 
  Device where it is failing is Note 3, target version is 4.4.2.
  Strangely same code works fine on other device (version 2.3.6)</p>
  
  <p><strong>GCM Registration</strong></p>
  
  <pre><code>try {
                  String sDeviceID=null;
                  if (checkPlayServices()) {
                      GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
                      sDeviceID = getRegistrationId(context);
                      if (sDeviceID==null) {
                          for(int i=0;i&lt;60;i++){
                              try{
                                  sDeviceID= gcm.register(SENDER_ID);
                                  break;
                              }catch(IOException e){
                                  Thread.sleep(2000);
                                  continue;
                              }
                          }
                          // Persist the regID - no need to register again.
                          storeRegistrationId(context, sDeviceID);
                      }
                      sDeviceID = getRegistrationId(context);
                      if (sDeviceID==null) {
                          error=true;
                          throw new Exception("GCM Error");
                      }
  </code></pre>
  
  <p><strong>Manifest XML</strong>
       
              </p>
  
  <pre><code>            &lt;!-- Receives the actual messages. --&gt;
              &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
              &lt;!-- Receives the registration id. --&gt;
              &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt;
  
              &lt;category android:name="com.planetapp.schoolink" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
      &lt;service android:name="com.planetapp.schoolink.GCMIntentService" /&gt;
  </code></pre>
  
  <p><strong>Broadcast Receiver</strong></p>
  
  <pre><code>public class GCMBroadcastReceiver extends WakefulBroadcastReceiver  {
      @Override
      public void onReceive(Context context, Intent intent) {
      System.out.println("++++++++++++ON RECEIVE");
         String regId = intent.getExtras().getString("registration_id");
  
         if(regId != null &amp;&amp; !regId.equals("")) {
            /* Do what ever you want with the regId eg. send it to your server */
             System.out.println("++++++++++++ID RECEIVED++++++++++++"+regId);
  
         }
      }
  </code></pre>
  
  <p>}</p>