onesignal-ane icon indicating copy to clipboard operation
onesignal-ane copied to clipboard

custom notification sound not working on android

Open hamadasamir85 opened this issue 7 years ago • 7 comments

custom notification sound not working on android with all sound file formats, it just vibrates when i send the sound name i contacted the technical support in Onesignal.com and tested my apk and found this error with the ANE,

02-22 16:42:31.395 534-30039/? W/RingtonePlayer: error loading sound for android.resource://air.com.btolat/2131034117
                                                 java.io.IOException: Prepare failed.: status=0x1
                                                     at android.media.MediaPlayer.prepare(Native Method)
                                                     at com.android.systemui.media.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:90)

hamadasamir85 avatar Feb 23 '17 12:02 hamadasamir85

It's probably not possible to play a custom notification sound by simply packaging the sound the way you package other app assets with AIR. You'll have to provide the sound as an Android resource file. Unfortunately, there's no other way than to create ANE with the sound packaged as a resource. You could add the sound to the resources already packaged in this ANE (the notification icons) or you could create a separate ANE. The ID you assign to the sound should be used in the OneSignal dashboard.

marpies avatar Feb 28 '17 21:02 marpies

Thanks for your replay, I've already added the sound files to the ANE package within the resources folder in raw folder, the weird thing is when i send the right sound id from OneSignal it just vibrates and if i send any wrong id it plays the default notification sound

hamadasamir85 avatar Feb 28 '17 23:02 hamadasamir85

Thanks for the additional info. I'll take a look at it.

Just for a reference, what sound formats did you try?

marpies avatar Mar 01 '17 21:03 marpies

I have tried mp3, wav and ogg.

hamadasamir85 avatar Mar 01 '17 23:03 hamadasamir85

Unfortunately, it looks there's an issue with AIR itself. It seems to deal with sound resources incorrectly:

android.content.res.Resources$NotFoundException: File res/raw/sound.ogg from drawable resource ID #0x7f040005

I'll have to create a bug report and see what AIR dev team have to say about it.

marpies avatar Mar 02 '17 22:03 marpies

Please provide us with a link to bug tracker. We'll vote for it.

dnikolaev avatar Mar 03 '17 04:03 dnikolaev

https://tracker.adobe.com/#/view/AIR-4198415

marpies avatar Feb 08 '18 22:02 marpies