0
public class GCMIntentService extends GCMBaseIntentService {

    NotificationManager mNotificationManager;
    Context cc;

    @Override
    protected void onRegistered(Context context, String regId) {
        Intent intent = new Intent(Constants1.ACTION_ON_REGISTERED);
        intent.putExtra(Constants1.FIELD_REGISTRATION_ID, regId);
        context.sendBroadcast(intent);
    }

    @Override
    protected void onUnregistered(Context context, String regId) {
        Log.i(Constants1.TAG, "onUnregistered: " + regId);
        AlertDialog.Builder alert = new AlertDialog.Builder(
                getApplicationContext());

        alert.show();

    }

    @Override
    protected void onMessage(Context context, Intent intent) {

        /**
         * You can get the Extras from TaxMann server
         * 
         * Bundle _bundle = intent.getExtras();
         */

        String msg = intent.getStringExtra("payload");
        mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        BackgroundAlert bg = new BackgroundAlert(mNotificationManager, msg);
        bg.onReceive(getApplicationContext(), intent);
    }

    @Override
    protected void onError(Context context, String errorId) {

    }
}

This is my code for gcm i have approx 15000 registered_device_id in my database for notification when i send notification to all register device id then it show 10000 success and 6000 unsuccessful .i want to delete all 6000 registered device id from our database so that it take less time to get notification .

user2794306
  • 175
  • 3
  • 5
  • 24
  • Follow that link might be useful for you. http://stackoverflow.com/questions/18200167/google-cloud-messaging-registration-id-expiration – AKSH Oct 21 '13 at 09:55

2 Answers2

1

You need not to do anything in android code. GCM is smart enough to handle it. So, once our app is uninstalled, GCM will take care of removing that Registration ID from GCM. However, we have to delete that registration Id from our server database, once we get the response from GCM as "NotRegistered", we have to remove that particular registration ID from our database.

Following are the sequence of events.

  1. The end user uninstalls the application.
  2. The 3rd-party server sends a message to GCM server.
  3. The GCM server sends the message to the device.
  4. The GCM client receives the message and queries Package Manager about whether there are broadcast receivers configured to receive it, which returns false.
  5. The GCM client informs the GCM server that the application was uninstalled.
  6. The GCM server marks the registration ID for deletion.
  7. The 3rd-party server sends a message to GCM.
  8. The GCM returns a NotRegistered error message to the 3rd-party server.Once, we receive this kinda response from GCM, we have to delete that particular registration ID from our database.
Shivanand Darur
  • 3,158
  • 1
  • 26
  • 32
0

Follow that link might be use full for you

Google Cloud Messaging registration id expiration

Community
  • 1
  • 1
AKSH
  • 201
  • 1
  • 12
  • Yes i have stored device 16000 User In which Only 10000 user active rest Uninstall the application so i want to delete Uninstall those 6000 device id from our database. i Must pass some parameter like flag for Uninstalling the application according to register device id . – user2794306 Oct 21 '13 at 08:00
  • if you are mainting a log in time or something, then in that case, u can run a service with a parameter that has login values less than some value so that deletion can take place from the db – Rat-a-tat-a-tat Ratatouille Oct 21 '13 at 08:34
  • @DharaShah i want simply delete unregistered device id from our database table in Our server – user2794306 Oct 21 '13 at 09:09
  • When the user uninstalls the app there is no way i presume you can track which device has uninstalled it.. :). – Rat-a-tat-a-tat Ratatouille Oct 21 '13 at 09:21
  • Then Do u have any Solution so that i can clean(delete) device id which is not active ? – user2794306 Oct 21 '13 at 09:28
  • You can just delete the ID's from your database table on server, simple. – AKSH Oct 21 '13 at 09:48