0

I have a chat app using Google cloud messaging. I have to migrate to FCM because of API Key. I used this tutorial: GCM to FCM but When I start the app, it closes immediately. This is the part of Gcmintentservice. I didn't understand what I should make Gcmintentservice.

protected void onHandleIntent(Intent intent) {
        String key = intent.getStringExtra(KEY);
        switch (key) {
            case SUBSCRIBE:
                // subscribe to a topic
                String topic = intent.getStringExtra(TOPIC);
                subscribeToTopic(topic);
                break;
            case UNSUBSCRIBE:
                String topic1 = intent.getStringExtra(TOPIC);
                unsubscribeFromTopic(topic1);
                break;
            default:
                // if key is not specified, register with GCM
                registerGCM();
        }

    }

When I delete inside of onHandleIntent function, App is working and there is no error but instant messaging is not working.

Cœur
  • 32,421
  • 21
  • 173
  • 232
  • Can you post the manifest file section of services and permissions. – ADimaano Aug 30 '17 at 00:20
  • The problem occurs on `GcmIntentService.java:49`. It's hard to say more than that it's a `NullPointerException`, which is https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it – Frank van Puffelen Aug 30 '17 at 00:34
  • It is the onHandleIntent function ` String key = intent.getStringExtra(KEY); switch (key) { case SUBSCRIBE: // subscribe to a topic String topic = intent.getStringExtra(TOPIC); subscribeToTopic(topic); break; case UNSUBSCRIBE: String topic1 = intent.getStringExtra(TOPIC); unsubscribeFromTopic(topic1); break; default: // if key is not specified, register with GCM registerGCM(); }` @FrankvanPuffelen – CaglarCaliskan Aug 30 '17 at 11:18

0 Answers0