Titanium JIRA Archive
Appcelerator Community (AC)

[AC-939] Android push notifications not working when app is out of focus - force close

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-08-20T23:19:27.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAppcelerator Modules
LabelsTCSupportTriage, android, exception, pushnotification
ReporterEdward Robertshaw
AssigneeMauro Parra-Miranda
Created2014-07-25T16:20:39.000+0000
Updated2016-03-08T07:37:15.000+0000

Description

Push notifications work only when app is in focus. A force close error appear if they are received when the app is in the background. When the app is minimized the following stack trace is produced prior to running any app code.
[ERROR] :  TiApplication: (main) [41,156900] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver ti.cloudpush.GCMReceiver: java.lang.NullPointerException; Titanium 3.2.3,2014/04/22 10:17,b958a70
[ERROR] :  TiApplication: java.lang.RuntimeException: Unable to start receiver ti.cloudpush.GCMReceiver: java.lang.NullPointerException
[ERROR] :  TiApplication: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2431)
[ERROR] :  TiApplication: 	at android.app.ActivityThread.access$1500(ActivityThread.java:141)
[ERROR] :  TiApplication: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)
[ERROR] :  TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] :  TiApplication: 	at android.os.Looper.loop(Looper.java:137)
[ERROR] :  TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:5103)
[ERROR] :  TiApplication: 	at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Method.java:525)
[ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
[ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[ERROR] :  TiApplication: 	at dalvik.system.NativeStart.main(Native Method)
[ERROR] :  TiApplication: Caused by: java.lang.NullPointerException
[ERROR] :  TiApplication: 	at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
[ERROR] :  TiApplication: 	at org.json.JSONTokener.nextValue(JSONTokener.java:94)
[ERROR] :  TiApplication: 	at org.json.JSONObject.<init>(JSONObject.java:154)
[ERROR] :  TiApplication: 	at org.json.JSONObject.<init>(JSONObject.java:171)
[ERROR] :  TiApplication: 	at ti.cloudpush.CloudpushModuleGeneric.showTrayNotification(CloudpushModuleGeneric.java:198)
[ERROR] :  TiApplication: 	at ti.cloudpush.CloudpushModuleGeneric.receivePayload(CloudpushModuleGeneric.java:96)
[ERROR] :  TiApplication: 	at ti.cloudpush.GCMReceiver.onReceive(GCMReceiver.java:26)
[ERROR] :  TiApplication: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2424)
[ERROR] :  TiApplication: 	... 10 more
[ERROR] :  AndroidRuntime: FATAL EXCEPTION: main
[ERROR] :  AndroidRuntime: java.lang.RuntimeException: Unable to start receiver ti.cloudpush.GCMReceiver: java.lang.NullPointerException
[ERROR] :  AndroidRuntime: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2431)
[ERROR] :  AndroidRuntime: 	at android.app.ActivityThread.access$1500(ActivityThread.java:141)
[ERROR] :  AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)
[ERROR] :  AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] :  AndroidRuntime: 	at android.os.Looper.loop(Looper.java:137)
[ERROR] :  AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:5103)
[ERROR] :  AndroidRuntime: 	at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] :  AndroidRuntime: 	at java.lang.reflect.Method.invoke(Method.java:525)
[ERROR] :  AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
[ERROR] :  AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[ERROR] :  AndroidRuntime: 	at dalvik.system.NativeStart.main(Native Method)
[ERROR] :  AndroidRuntime: Caused by: java.lang.NullPointerException
[ERROR] :  AndroidRuntime: 	at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
[ERROR] :  AndroidRuntime: 	at org.json.JSONTokener.nextValue(JSONTokener.java:94)
[ERROR] :  AndroidRuntime: 	at org.json.JSONObject.<init>(JSONObject.java:154)
[ERROR] :  AndroidRuntime: 	at org.json.JSONObject.<init>(JSONObject.java:171)
[ERROR] :  AndroidRuntime: 	at ti.cloudpush.CloudpushModuleGeneric.showTrayNotification(CloudpushModuleGeneric.java:198)
[ERROR] :  AndroidRuntime: 	at ti.cloudpush.CloudpushModuleGeneric.receivePayload(CloudpushModuleGeneric.java:96)
[ERROR] :  AndroidRuntime: 	at ti.cloudpush.GCMReceiver.onReceive(GCMReceiver.java:26)
[ERROR] :  AndroidRuntime: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2424)
[ERROR] :  AndroidRuntime: 	... 10 more
Code used was a direct copy from: http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.CloudPush Additional notes, a stack overflow question is in progress on the issue. http://stackoverflow.com/questions/24857937/unable-to-receive-push-notifications-to-notifications-tray-on-appcelerator-andro

Comments

  1. Mostafizur Rahman 2014-08-05

    Hello [~erobertshaw]! Can you please try this test code and report back if you get the same results? TIA! Push notifications work when app is in focus and run in background. But push notifications not working when we stop the app by force from Manage application. *TESTING ENVIRONMENT:* Titanium SDK: 3.3.0.GA and 3.2.3.GA Titanium CLI: 3.3.0 OS X Version: 10.9.3 Android API Level: 17 and 19 *STEPS TO REPRODUCE:* 1. Create a classic Project. 2. Paste the following gits code in app.js file and tiapp.xml file. 3. Enable cloud and add module cloud and cloudpush. 4. At Application Dashboard in setting option insert GCM API key and GCM Sender ID. 5. Create user in development option that you will use for login. 6. Run this code with testing environment. *TESTING CODE:* [https://gist.github.com/MotiurRahman/8766037] *TESTING RESULT:* Push notifications work when app is in focus and run in background.But push notifications not working when we stop the app by force from Manage application.
  2. Mauro Parra-Miranda 2014-08-20

    Tested on 3.3.0.GA, works fine.
  3. Fouad Kada 2014-10-15

    I am also facing this issue on 3.3.0GA
       [WARN] :   dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4161cba8)
       [ERROR] :  TiApplication: (main) [132642,138481] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver com.appcelerator.cloudpush.GCMReceiver: java.lang.NullPointerException; Titanium 3.3.0,2014/07/11 12:36,787cd39
       [ERROR] :  TiApplication: java.lang.RuntimeException: Unable to start receiver com.appcelerator.cloudpush.GCMReceiver: java.lang.NullPointerException
       [ERROR] :  TiApplication: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2414)
       [ERROR] :  TiApplication: 	at android.app.ActivityThread.access$1700(ActivityThread.java:135)
       [ERROR] :  TiApplication: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
       [ERROR] :  TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:102)
       [ERROR] :  TiApplication: 	at android.os.Looper.loop(Looper.java:136)
       [ERROR] :  TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:5001)
       [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invokeNative(Native Method)
       [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Method.java:515)
       [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
       [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
       [ERROR] :  TiApplication: 	at dalvik.system.NativeStart.main(Native Method)
       [ERROR] :  TiApplication: Caused by: java.lang.NullPointerException
       [ERROR] :  TiApplication: 	at com.appcelerator.cloudpush.utils.APSProperties.<init>(APSProperties.java:45)
       [ERROR] :  TiApplication: 	at com.appcelerator.cloudpush.Settings.props(Settings.java:45)
       [ERROR] :  TiApplication: 	at com.appcelerator.cloudpush.Settings.useSingleCallback(Settings.java:67)
       [ERROR] :  TiApplication: 	at com.appcelerator.cloudpush.APSCloudPush.receivePayload(APSCloudPush.java:229)
       [ERROR] :  TiApplication: 	at com.appcelerator.cloudpush.GCMReceiver.onReceive(GCMReceiver.java:31)
       [ERROR] :  TiApplication: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2407)
       [ERROR] :  TiApplication: 	... 10 more
       [INFO] :   Process: Sending signal. PID: 4816 SIG: 9
       
  4. Cristian Cepeda 2014-10-16

    I have the same problem, this is an adb log monospaced E/TiApplication( 5409): (main) [25,656] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver com.appcelerator.cloudpush.GCMReceiver: java.lang.NullPointerException; Titanium 3.3.0,2014/07/11 12:36,787cd39 E/TiApplication( 5409): java.lang.RuntimeException: Unable to start receiver com.appcelerator.cloudpush.GCMReceiver: java.lang.NullPointerException E/TiApplication( 5409): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2441) E/TiApplication( 5409): at android.app.ActivityThread.access$1700(ActivityThread.java:139) E/TiApplication( 5409): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286) E/TiApplication( 5409): at android.os.Handler.dispatchMessage(Handler.java:102) E/TiApplication( 5409): at android.os.Looper.loop(Looper.java:136) E/TiApplication( 5409): at android.app.ActivityThread.main(ActivityThread.java:5086) E/TiApplication( 5409): at java.lang.reflect.Method.invokeNative(Native Method) E/TiApplication( 5409): at java.lang.reflect.Method.invoke(Method.java:515) E/TiApplication( 5409): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) E/TiApplication( 5409): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) E/TiApplication( 5409): at dalvik.system.NativeStart.main(Native Method) E/TiApplication( 5409): Caused by: java.lang.NullPointerException E/TiApplication( 5409): at com.appcelerator.cloudpush.utils.APSProperties.(APSProperties.java:45) E/TiApplication( 5409): at com.appcelerator.cloudpush.Settings.props(Settings.java:45) E/TiApplication( 5409): at com.appcelerator.cloudpush.Settings.useSingleCallback(Settings.java:67) E/TiApplication( 5409): at com.appcelerator.cloudpush.APSCloudPush.receivePayload(APSCloudPush.java:229) E/TiApplication( 5409): at com.appcelerator.cloudpush.GCMReceiver.onReceive(GCMReceiver.java:31) E/TiApplication( 5409): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2434) E/TiApplication( 5409): ... 10 more monospaced
  5. Fouad Kada 2014-10-16

    feels good im not the only one facing this, and what bothers me is that it used to work perfectly and now it is not, it's not easy to explain for the customer.
  6. Oliver Milanovic 2014-10-17

    I have the same issue here with 3.4.0GA on a Nexus 5 with Android 4.4.4 running on it: monospaced 10-17 16:01:04.880: E/AndroidRuntime(30682): java.lang.RuntimeException: Unable to start receiver com.appcelerator.cloudpush.GCMReceiver: java.lang.NullPointerException 10-17 16:01:04.880: E/AndroidRuntime(30682): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2414) 10-17 16:01:04.880: E/AndroidRuntime(30682): at android.app.ActivityThread.access$1700(ActivityThread.java:135) 10-17 16:01:04.880: E/AndroidRuntime(30682): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272) 10-17 16:01:04.880: E/AndroidRuntime(30682): at android.os.Handler.dispatchMessage(Handler.java:102) 10-17 16:01:04.880: E/AndroidRuntime(30682): at android.os.Looper.loop(Looper.java:136) 10-17 16:01:04.880: E/AndroidRuntime(30682): at android.app.ActivityThread.main(ActivityThread.java:5001) 10-17 16:01:04.880: E/AndroidRuntime(30682): at java.lang.reflect.Method.invokeNative(Native Method) 10-17 16:01:04.880: E/AndroidRuntime(30682): at java.lang.reflect.Method.invoke(Method.java:515) 10-17 16:01:04.880: E/AndroidRuntime(30682): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 10-17 16:01:04.880: E/AndroidRuntime(30682): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 10-17 16:01:04.880: E/AndroidRuntime(30682): at dalvik.system.NativeStart.main(Native Method) 10-17 16:01:04.880: E/AndroidRuntime(30682): Caused by: java.lang.NullPointerException 10-17 16:01:04.880: E/AndroidRuntime(30682): at com.appcelerator.cloudpush.utils.APSProperties.(APSProperties.java:45) 10-17 16:01:04.880: E/AndroidRuntime(30682): at com.appcelerator.cloudpush.Settings.props(Settings.java:45) 10-17 16:01:04.880: E/AndroidRuntime(30682): at com.appcelerator.cloudpush.Settings.useSingleCallback(Settings.java:67) 10-17 16:01:04.880: E/AndroidRuntime(30682): at com.appcelerator.cloudpush.APSCloudPush.receivePayload(APSCloudPush.java:229) 10-17 16:01:04.880: E/AndroidRuntime(30682): at com.appcelerator.cloudpush.GCMReceiver.onReceive(GCMReceiver.java:31) 10-17 16:01:04.880: E/AndroidRuntime(30682): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2407) 10-17 16:01:04.880: E/AndroidRuntime(30682): ... 10 more
  7. Oliver Milanovic 2014-10-17

    I'd like to add to my comment, that I'm using Alloy, if that helps...
  8. Petr Cervenka 2014-10-30

    Same issue here on Nexus 5 running Android L + SDK 3.4.0GM
  9. David Fischer 2014-11-07

  10. Fouad Kada 2014-11-08

    In my case downgrading ti.cloudpush 3.2.1 fixed the issue completely, app no longer crash when in foreground, background and when terminated.

JSON Source