Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2429] Arrow Push Custom Notification Sounds for Android 8+ Not Found

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-12-20T18:27:48.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsCloudPush
Labelsarrow, push
ReporterKen Rucker
AssigneeYordan Banev
Created2018-05-16T19:34:18.000+0000
Updated2019-12-20T18:27:54.000+0000

Description

Titanium 7.1.1.GA When sending Arrow Push notifications with a custom sound file to an Android device running Android 8 or above, the sound is not found and depending on the status of the app (foreground or background, the app either only plays the device default sound, or crashes the app. A sample payload:
{
  "alert": "My Alert Text",
  "icon": "q",
  "badge": " 1",
  "sound": "popq.wav",
  "vibrate": "false",
  "title": "My Title",
  "priority": "high",
  "content-available": 0
}
The sounds are located at: /resources/popq.wav (For iOS) /resources/sound/popq.wav (for Android) Note: The docs state to specify the sound without the extension. However, I am only able to get the push notification custom sounds to work on both Android and iOS WITH the extension specified. If you do not specify an extension, then you get the default notification sound on both Android and iOS. I am using WAV because that sound format is supported by both Android and iOS. Icon works fine with not including the extension. With app in foreground:
[WARN] :   W/System.err: java.io.FileNotFoundException: /sdcard/cocoafish/sound/com.walkthelot.qalerts/popq.wav (No such file or directory)
[WARN] :   W/System.err: 	at java.io.FileOutputStream.open0(Native Method)
[WARN] :   W/System.err: 	at java.io.FileOutputStream.open(FileOutputStream.java:287)
[WARN] :   W/System.err: 	at java.io.FileOutputStream.<init>(FileOutputStream.java:223)
[WARN] :   W/System.err: 	at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
[WARN] :   W/System.err: 	at com.appcelerator.aps.APSCloudPush.getAndTransferFile(APSCloudPush.java:544)
[WARN] :   W/System.err: 	at com.appcelerator.aps.APSCloudPush.showTrayNotification(APSCloudPush.java:443)
[WARN] :   W/System.err: 	at com.appcelerator.aps.APSCloudPush.receivePayload(APSCloudPush.java:269)
[WARN] :   W/System.err: 	at com.appcelerator.aps.GCMReceiver.onReceive(GCMReceiver.java:30)
[WARN] :   W/System.err: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:3187)
[WARN] :   W/System.err: 	at android.app.ActivityThread.-wrap17(Unknown Source:0)
[WARN] :   W/System.err: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1672)
[WARN] :   W/System.err: 	at android.os.Handler.dispatchMessage(Handler.java:106)
[WARN] :   W/System.err: 	at android.os.Looper.loop(Looper.java:164)
[WARN] :   W/System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6494)
[WARN] :   W/System.err: 	at java.lang.reflect.Method.invoke(Native Method)
[WARN] :   W/System.err: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
[WARN] :   W/System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
[WARN] :   Notification: Use of stream types is deprecated for operations other than volume control
[WARN] :   Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
When app is closed I get an Android error that APP Name has stopped, and no notification comes through. This all works flawlessly on iOS and any Android device running Android API 25 or LOWER. The app is in production on both iOS and Android stores. For Android installations greater than API 25 I just disable the option for the user to choose a custom sound.

Comments

  1. Yordan Banev 2018-06-05

    APS_SDK: https://github.com/appcelerator/aps_sdk/pull/320
  2. Michael Scholz 2018-08-06

    Any status/progress update on this issue?
  3. Ken Rucker 2018-08-06

    Sadly, I know I haven't heard zip and the latest SDK's have not fixed it.
  4. Michael Scholz 2018-08-06

    I'm wondering if other modules like Ti.goosh has this issue resolved. I was testing with it and it worked well in many regards. I did not check for this issue specifically. I have seen a related issue posted back in March 2018. It has been 6 months.
  5. Ken Rucker 2018-09-10

    I doubt it since the issue is related to basically having permissions/access to the custom sound file in the Android app container.
  6. Joshua Quick 2018-10-02

    I'll ask the test team to re-test, but I suspect this issue still exists when running on Android 7.0 and above. It's due to a breaking-change that Google has made where external apps need to be given permission to read another app's files. https://developer.android.com/about/versions/nougat/android-7.0-changes#sharing-files The problem here is that their is a design issue on Google's end where there is no way to grant the system permission without using *hack* (grant it to Google's "com.android.systemui" system app), which is not guaranteed to work on all devices and OS versions. You can see Google's bug reports on this issue below. Supposedly they fixed it in Android 9.0, but we would have to see if the issue is still outstanding in Android 7.0 - 8.x. https://issuetracker.google.com/issues/36524161 https://issuetracker.google.com/issues/37118905
  7. Joshua Quick 2018-12-04

    The issue is that Google has made a breaking change in Android 8.0 and above. You can no longer assign a sound to individual notifications. Instead, you must configure a "notification channel" with a sound and assign that notification the ID to that notification channel. We've added notification channel "sound" support in 7.5.0. Please see... https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Android.NotificationChannel-property-sound The test procedure and code example attached to the below pull request shows you how to set up a notification channel with sound. While it's an example for a local notification, you still need to create a channel yourself for push notification as well within your app. Arrow can't do this for you. The key thing is you need to assign the notification channel a name, channel ID, importance level, and path to the sound file. https://github.com/appcelerator/titanium_mobile/pull/10400 The channel ID string you set up is important. You need to apply this channel ID to your remote notification JSON so that the Android side knows which channel to assign it to. If you don't assign it a channel ID, then it ends being posted to a default channel, which is what is happening to you now. For example, if your notification channel ID is "my_channel_1", then your Arrow JSON needs to be the below...
       {
       	"android": {
       		"title": "My Title",
       		"alert": "My alert message.",
       		"channelId": "my_channel_1"
       	}
       }
       
    Under the JSON's "android" table, the "channelId" is where you put the notification channel ID string. Also note that the above only applies to Android 8.0 and above. Older Android OS versions do not support notification channels and you still have to apply a sound to individual notifications for it to work on older systems. Unfortunately, you have to do it both ways. That's how Google has made it, not us. I hope this helps.

JSON Source