Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:06:39+00:00 2026-06-17T05:06:39+00:00

Taking a look at the gcm-demo-client sample application that comes with the GCM package,

  • 0

Taking a look at the gcm-demo-client sample application that comes with the GCM package, I notice that the following pattern has been used:

GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
    // Register application with GCM
} else {
    // Device is already registered on GCM, check server.
    if (GCMRegistrar.isRegisteredOnServer(this)) {
        // Skip registration.
    } else {
        // Try to register again on server
    }
}

But what if, for some reason, the application was previously succesfully registered to GCM and the application server, then unregistered from GCM succesfully but not from the application server, then the application would try to re-register on the application server without unregistering first, right? So shouldn’t the pattern be more like:

GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
    // Check if device was previously registered with application server
    if (GCMRegistrar.isRegisteredOnServer(this)) {
        // Unregister on application server
    }
    // Register application with GCM
} else {
    // Device is already registered on GCM, check server.
    if (GCMRegistrar.isRegisteredOnServer(this)) {
        // Skip registration.
    } else {
        // Try to register again on server
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:06:41+00:00Added an answer on June 17, 2026 at 5:06 am

    You could do it that way, but because the unregistration is (or should be) an asynchronous event, you would have to trigger a special unregistration that would then register with GCM after completing.

    So something like:

    if (regId.equals("")) {
        // Check if device was previously registered with application server
        if (GCMRegistrar.isRegisteredOnServer(this)) {
            // Unregister on application server and trigger GCM registration
        } else {
            // Register application with GCM
        }
    }
    

    I’m not sure that you should worry about it, because it shouldn’t be that big of a deal to your application server if the same device registers again since the registration ID provided by GCM will likely be the same. But if it’s not the next time you send a message GCM should give solve the problem for you by returning a canonical Id.

    You could also only unregister from GCM if you successfully unregister from your application server first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am taking a look at the default OAuth implementation that comes with asp.net
I'm taking a look at how to properly escape data that comes from the
Lately I've been taking a look at Haxe , to build an application to
I'm taking a look at an application that defines a large set of constant
Thanks for taking a look at this. The issue has to do with the
thanks for taking the time to look at my question. I've been diving into
While taking a look at this awesome thread I noticed that some examples use
I've been taking a look at some different products for .NET which propose to
I have been taking a look around and the most popular .NET drivers for
Thanks for taking a look at my post. I've been working with linq to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.