Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android GCM : GCMRegistrar gives empty registration ID

I have followed http://developer.android.com/guide/google/gcm/gs.html#server-app to implement GCM in my application

                    GCMRegistrar.checkDevice(this);
        GCMRegistrar.checkManifest(this);
        if (GCMRegistrar.isRegistered(this)) {
            Log.d(TAG, GCMRegistrar.getRegistrationId(this));
        }
        final String regId = GCMRegistrar.getRegistrationId(this);

        if (regId.equals("")) {
            GCMRegistrar.register(this, sender_id);
            Log.d(TAG, "Registration id :  "+GCMRegistrar.getRegistrationId(this));
        }
            else {
            Log.d("info", "already registered as" + regId);
        }

that returns empty string as registration ID what else is needed to get the registration ID??

like image 980
techieWings Avatar asked Dec 05 '22 15:12

techieWings


1 Answers

Empty String comes when device is not registered successfully. There may be following reasons for it-

  1. Put you GCM code in application package. [You can make another package with same name of application package]
  2. Put all permissions properly.
like image 183
Mani Avatar answered Dec 14 '22 20:12

Mani