4

I am developing application where I want to implement push notification for that I am using GCM, I have registered my project on google console and using project ID as senderID for GCM registraton.

GCMRegistrar.checkDevice(this); //no error 
GCMRegistrar.checkManifest(this); //no error          
final String regId = GCMRegistrar.getRegistrationId(this);               
if (regId.equals("")) {
            GCMRegistrar.register(this, "********"); //after this.. 
                                       //onError method of GCMIntentService class
                                      //is triggered, there I am printing error
                                     //in log its saying INVALD_SENDER 
        } 

I have given all required permissions in AndroidManifest.xml

I Have already referred following links

1) Android GCM SENDER_ID, how to get it? 2) Getting GCM Error: INVALID_SENDER occasionally in an app that has two GCM BroadcastReceivers 3) GCM Invalid sender error 4) http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

Community
  • 1
  • 1
DCoder
  • 3,486
  • 7
  • 36
  • 68

4 Answers4

23

SENDER_ID = Project Number, I was using Project Id.. Project Number is available on console beside project id.

DCoder
  • 3,486
  • 7
  • 36
  • 68
15

Google has changed its layout. you can find project_number from here

select project -> My Project

click three dots -> Project Information -> Project Number

enter image description here

Kishore Jethava
  • 6,666
  • 5
  • 35
  • 51
0

Here is a working example for push notifications, hope this helps:

private String SENDER_ID = "xxxxxxx";
private GoogleCloudMessaging gcm;

//somewhere else
gcm = GoogleCloudMessaging.getInstance(context);
String msg = gcm.register(SENDER_ID);

I recently got some service not available errors here so I also implemented a Broadcastreciever to recieve the regestration token.

@Override
public void onReceive(Context context, Intent intent) {
    Bundle data = intent.getExtras();
    if (data!=null){
        String regId = data.getString("registration_id");
    }
}
Arno van Lieshout
  • 1,570
  • 1
  • 13
  • 19
  • cant find GoogleCloudMessaging. I think you are using google-play-service_lib project. but I am using gcm.jar – DCoder Apr 30 '14 at 06:18
0

I got same error and found out that google login was not enabled in firebase console. After enabling it error was gone.

Check this image for reference:

image

Saket Milan
  • 103
  • 1
  • 8