Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25501] Android: App crash on receiving notification if app in background

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2017-11-17T19:29:29.000+0000
Affected Version/sRelease 6.3.0, Release 6.2.2
Fix Version/sRelease 7.0.0
ComponentsAndroid
Labelsnotifications, push
Reporter Ricardo Ramirez
AssigneeGary Mathews
Created2017-11-10T23:52:56.000+0000
Updated2017-12-19T12:22:24.000+0000

Description

Issue Description

In our application, we have push notification functionality. When the app is in background and a notification is sent from the dashboard, the notification is not adding to the notification tray instead the app is getting crashed saying “App has been stopped”. But when the app is in foreground, on receiving notification app is behaving as expected. Sample payload data:
 
{ 
"alert": "test", 
"title": “Appname”, 
"vibrate": true, 
"icon": "push_notification_icon", 
"sound": "", 
"badge": "", 
"ClaimID": “123456”, 
"UserID": “1234566”, 
"ChannelName": “mychannel” 
} 
But when we remove the property “sound” from the payload data, app is not getting crashed even when the app is in background. Note: This issue is in Pixel (8.0.0 OS). In nexus(6.0.1 OS) and Samsung S4(4.4.2 OS) it is working fine. We are using SDK 6.3.0GA, CloudPush module : 4.0.3 and Cloud module : 3.2.11. Please download the test-case: https://drive.google.com/file/d/1yVJ-NkICtWDZQXgLyDWstPROiyMHC0Hm/view?usp=sharing

Comments

  1. Gary Mathews 2017-11-13

    This is the error log:
       11-13 13:19:20.375 6624-6624/? E/TiApplication: (main) [144850,284753] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: android.os.FileUriExposedException: file:///storage/emulated/0/cocoafish/sound/com.test.push exposed beyond app through Notification.sound; Titanium 6.3.0,2017/10/31 18:13,undefined
                                                       java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: android.os.FileUriExposedException: file:///storage/emulated/0/cocoafish/sound/com.test.push exposed beyond app through Notification.sound
                                                           at android.app.ActivityThread.handleReceiver(ActivityThread.java:3047)
                                                           at android.app.ActivityThread.-wrap18(ActivityThread.java)
                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1561)
                                                           at android.os.Handler.dispatchMessage(Handler.java:102)
                                                           at android.os.Looper.loop(Looper.java:154)
                                                           at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                        Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/cocoafish/sound/com.test.push exposed beyond app through Notification.sound
                                                           at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
                                                           at android.net.Uri.checkFileUriExposed(Uri.java:2346)
                                                           at android.app.NotificationManager.notifyAsUser(NotificationManager.java:300)
                                                           at android.app.NotificationManager.notify(NotificationManager.java:284)
                                                           at android.app.NotificationManager.notify(NotificationManager.java:268)
                                                           at com.appcelerator.aps.APSCloudPush.showTrayNotification(APSCloudPush.java:523)
                                                           at com.appcelerator.aps.APSCloudPush.receivePayload(APSCloudPush.java:253)
                                                           at com.appcelerator.aps.GCMReceiver.onReceive(GCMReceiver.java:30)
                                                           at android.app.ActivityThread.handleReceiver(ActivityThread.java:3040)
                                                           at android.app.ActivityThread.-wrap18(ActivityThread.java) 
                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1561) 
                                                           at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                           at android.os.Looper.loop(Looper.java:154) 
                                                           at android.app.ActivityThread.main(ActivityThread.java:6119) 
                                                           at java.lang.reflect.Method.invoke(Native Method) 
                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
       
    using payload:
       {
       "alert": "test",
       "title": "title",
       "vibrate": true,
       "icon": "push_notification_icon",
       "sound": "",
       "badge": ""
       }
       
  2. Gary Mathews 2017-11-14

    aps_sdk: https://github.com/appcelerator/aps_sdk/pull/304 cloudpush: https://github.com/appcelerator-modules/cloudpush/pull/33
  3. Lokesh Choudhary 2017-11-14

    FR Passed. Check it with cloudpush prerelease 5.0.0 & ti.playservices 11.0.40. Push notifications are sent & received successfully. Also, there is no app crash in the background when sound or icon is present in the payload. Studio Ver: 4.10.0.201709271713 SDK Ver: 7.0.0.v20171114124039 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.10 Appc CLI: 6.3.0 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.7 Node Ver: 7.10.1 Java Ver: 1.8.0_101 Devices: ⇨ samsung SM-G955U1 --- Android 7.0
  4. Lokesh Choudhary 2017-11-16

    Having a custom sound in "Resources/sound/" crashes the app when push notification is sent on android 7.0 & above. Android 6.0.1 works fine.
       [ERROR] :  TiApplication: (main) [27214,32660] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: android.os.FileUriExposedException: file:///storage/emulated/0/cocoafish/sound/com.app.cloudpushprod/test.wav exposed beyond app through Notification.sound; Titanium 7.0.0,2017/11/16 08:48,undefined
       [ERROR] :  TiApplication: java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: android.os.FileUriExposedException: file:///storage/emulated/0/cocoafish/sound/com.app.cloudpushprod/test.wav exposed beyond app through Notification.sound
       [ERROR] :  TiApplication:  at android.app.ActivityThread.handleReceiver(ActivityThread.java:3047)
       [ERROR] :  TiApplication:  at android.app.ActivityThread.-wrap18(ActivityThread.java)
       [ERROR] :  TiApplication:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1561)
       [ERROR] :  TiApplication:  at android.os.Handler.dispatchMessage(Handler.java:102)
       [ERROR] :  TiApplication:  at android.os.Looper.loop(Looper.java:154)
       [ERROR] :  TiApplication:  at android.app.ActivityThread.main(ActivityThread.java:6119)
       [ERROR] :  TiApplication:  at java.lang.reflect.Method.invoke(Native Method)
       [ERROR] :  TiApplication:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
       [ERROR] :  TiApplication:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
       [ERROR] :  TiApplication: Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/cocoafish/sound/com.app.cloudpushprod/test.wav exposed beyond app through Notification.sound
       [ERROR] :  TiApplication:  at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
       [ERROR] :  TiApplication:  at android.net.Uri.checkFileUriExposed(Uri.java:2346)
       [ERROR] :  TiApplication:  at android.app.NotificationManager.notifyAsUser(NotificationManager.java:300)
       [ERROR] :  TiApplication:  at android.app.NotificationManager.notify(NotificationManager.java:284)
       [ERROR] :  TiApplication:  at android.app.NotificationManager.notify(NotificationManager.java:268)
       [ERROR] :  TiApplication:  at com.appcelerator.aps.APSCloudPush.showTrayNotification(APSCloudPush.java:492)
       [ERROR] :  TiApplication:  at com.appcelerator.aps.APSCloudPush.receivePayload(APSCloudPush.java:255)
       [ERROR] :  TiApplication:  at com.appcelerator.aps.GCMReceiver.onReceive(GCMReceiver.java:30)
       [ERROR] :  TiApplication:  at android.app.ActivityThread.handleReceiver(ActivityThread.java:3040)
       [ERROR] :  TiApplication:  ... 8 more
       
    Reopening.
  5. Gary Mathews 2017-11-17

    cloudpush: https://github.com/appcelerator-modules/cloudpush/pull/34 aps: https://github.com/appcelerator/aps_sdk/pull/306
  6. Lokesh Choudhary 2017-11-17

    FR Passed. PR's merged.
  7. Lokesh Choudhary 2017-11-17

    Closing as fix is verified in Cloudpush 5.0.0.

JSON Source