morinel / gcmpush

Titanium Module for Android Push
Apache License 2.0
57 stars 35 forks source link

Error when app is closed and notif is received #24

Open DFoxinator opened 8 years ago

DFoxinator commented 8 years ago

Hey,

Thanks for creating this awesome module. It is much appreciated.

My notifs are working fine when my app is in the background. When I close the app and try to receive a notification, on the device I get "Unfortunately, myapp has stopped."

In adb logcat, I see the following error:

E/AndroidRuntime(10364): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean nl.vanvianen.android.gcm.GCMModule.isInForeground()' on a null object reference E/AndroidRuntime(10364): at nl.vanvianen.android.gcm.GCMIntentService.onMessage(GCMIntentService.java:340) E/AndroidRuntime(10364): at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223) E/AndroidRuntime(10364): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) E/AndroidRuntime(10364): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime(10364): at android.os.Looper.loop(Looper.java:135) E/AndroidRuntime(10364): at android.os.HandlerThread.run(HandlerThread.java:61)

Am I doing something incorrectly?

Any help is appreciated.

DFoxinator commented 8 years ago

Looking more through the code, I would guess this has something to do with the fact that I have backgroundOnly set to true, which is making it do this check.

morinel commented 8 years ago

Does version 1.6 fix this issue for you?