[AC-939] Android push notifications not working when app is out of focus - force close
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2014-08-20T23:19:27.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Appcelerator Modules |
Labels | TCSupportTriage, android, exception, pushnotification |
Reporter | Edward Robertshaw |
Assignee | Mauro Parra-Miranda |
Created | 2014-07-25T16:20:39.000+0000 |
Updated | 2016-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
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.
Tested on 3.3.0.GA, works fine.
I am also facing this issue on 3.3.0GA
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.monospaced
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.
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.I'd like to add to my comment, that I'm using Alloy, if that helps...
Same issue here on Nexus 5 running Android L + SDK 3.4.0GM
In my case downgrading ti.cloudpush 3.2.1 fixed the issue completely, app no longer crash when in foreground, background and when terminated.