Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The deprecated <code>GCMRegistrar</code> was just a helper client class that stored the RegistrationID locally on the device. <code>GCMRegistrar.isRegistered()</code> never called the GCM server to find if the device is registered (since there is no such API). It just checked if a previously received RegistrationID is locally stored on the device for a specific app (and invalidated the stored RegistrationId on some occassions, such as when the app version changes).</p> <p>In fact, you can see the code of GCMRegistrar <a href="http://code.google.com/p/gcm/source/browse/gcm-client/src/com/google/android/gcm/GCMRegistrar.java?r=87275a7eaab265c60b17f178b0c5cdd2983dc686" rel="nofollow">here</a>:</p> <pre><code>/** * Gets the current registration id for application on GCM service. * &lt;p&gt; * If result is empty, the registration has failed. * * @return registration id, or empty string if the registration is not * complete. */ public static String getRegistrationId(Context context) { final SharedPreferences prefs = getGCMPreferences(context); String registrationId = prefs.getString(PROPERTY_REG_ID, ""); // check if app was updated; if so, it must clear registration id to // avoid a race condition if GCM sends a message int oldVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE); int newVersion = getAppVersion(context); if (oldVersion != Integer.MIN_VALUE &amp;&amp; oldVersion != newVersion) { Log.v(TAG, "App version changed from " + oldVersion + " to " + newVersion + "; resetting registration id"); clearRegistrationId(context); registrationId = ""; } return registrationId; } /** * Checks whether the application was successfully registered on GCM * service. */ public static boolean isRegistered(Context context) { return getRegistrationId(context).length() &gt; 0; } </code></pre> <p>Therefore, if you store the registration ID in your app, you would achieve the exact same functionality you had when you used <code>GCMRegistrar</code>. The only way to know for sure in the client app that the device is registered or not registered to GCM is to call <code>GoogleCloudMessaging.register</code> or <code>GoogleCloudMessaging.unregister</code>. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload