gabrjan
gabrjan

Reputation: 3049

Starting push notifications GCM on android

I'm trying to set up simple push notifications for android. But it went off right from the start. I'm following this tutorial before I also tried by google start up guide however the problem is I can't register my app to my google service. I have enabled Google cloud Messaging. My code is:

   try{
    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);
    String regId = GCMRegistrar.getRegistrationId(this);
    if (regId.equals("")) {
      GCMRegistrar.register(this, "SENDER ID");
      Log.v("Registration", "new registration");// Note: get the sender id from configuration.
      regId = GCMRegistrar.getRegistrationId(this);
      Log.v("Registration", "Already registered, regId: " + regId);
    } else {             
      Log.v("Registration", "Already registered, regId: " + regId);
    }
    }
    catch(Exception e){
        String a=e.toString();
        Log.v(a,a);
    }

It goes on just fine but nothing really happens and after this function finishes, my app force closes. For the sender ID, I use the number from google.(at the end of the link).

So there seems to be no error just my app shut down after and it doesn't register. There is also one more funny thing. When I debug the app on my phone, it runs on, but when I start it on emulator it force closes.

Upvotes: 1

Views: 392

Answers (1)

gabrjan
gabrjan

Reputation: 3049

Finally find a solution :d

The problem was that i named GCMIntentService wrong i named it GcmIntentService and then all went appart :S

So i post this answer if another fool like me comes into this problem...

Upvotes: 1

Related Questions