Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneSignal Cordova SDK - No custom sound / custom sound not working correctly / res/raw folder directory #510

Closed
elmbrent opened this issue May 10, 2019 · 38 comments

Comments

@elmbrent
Copy link

I have added the file via config.xml to my res/raw directory and it is not playing my custom audio files, just the normal beep.

Added line to config.xml

See image
https://ibb.co/KVBg0ds

Environment
CORDOVA 9.0.0
Phonegap 7.1.0
Android 6.4.0

Steps to Reproduce Issue:

  1. Added file to www and root
  2. Tried adding test.mp3 to Message and test
  3. Tried different phonegap and android version
@bencarrr
Copy link

I've got the same issue - Did anyone solve this?

@rgomezp
Copy link
Contributor

rgomezp commented May 21, 2019

@elmbrent , @Benjyclay Can you please check in the apk if the resource is actually being added? Also, please check in the notification info that the sound is not set to Default and is set to the resource name (without the file extension)

@elmbrent
Copy link
Author

@rgomezp If you look at the screenshot you can see the file being added to the android directory automatically, I did check the response and it was meant to be playing the file without the extension.

@rgomezp
Copy link
Contributor

rgomezp commented May 21, 2019

@elmbrent I know that the file is supposed to be added from looking at the screenshot, but you have to check the APK itself to see if it is actually where it is supposed to be (look in the directory itself)

@elmbrent
Copy link
Author

elmbrent commented May 22, 2019

@rgomezp I've used a tool to decompile the apk and it looks like the file is there.
https://ibb.co/tXMmcBZ

@rgomezp
Copy link
Contributor

rgomezp commented May 22, 2019

@elmbrent Ok that's good. But it looks like you're not putting it in the correct directory.

Solution: Make sure it is in <project-root>/platforms/android/res/raw/

If you take a look at our docs, you will see that the dir is different for different platforms

Edit: it is in the correct directory, my mistake

@rgomezp rgomezp changed the title No custom sound OneSignal Cordova SDK - No custom sound / custom sound not working correctly / res/raw folder directory May 22, 2019
@elmbrent
Copy link
Author

elmbrent commented May 22, 2019

@rgomezp It is in the directory, after it is complied into an APK the whole directory structure is different you docs referenced before complied, what you are saying is the directory structure before compiling which is also correct if you look at my first message.

https://ibb.co/d2r4cSQ

@rgomezp
Copy link
Contributor

rgomezp commented May 22, 2019

@elmbrent ,
After sending a notification, can you check the Realtime Message Data page for the following:
Screen Shot 2019-05-22 at 1 56 00 PM

@elmbrent
Copy link
Author

https://ibb.co/26jqwqD

Yes it seems to be set, just the normal phone beep sounds appears though

@rgomezp
Copy link
Contributor

rgomezp commented May 23, 2019

How about on iOS? Is it working there?

@elmbrent
Copy link
Author

We have not tried yet, we are doing an android release soon so we would like to get this fixed

@AcidTr
Copy link

AcidTr commented May 27, 2019

I have almost the same issue. I run the command to generate the apk, but the sound isn't copied to the correct directory.
I'd already tried to use diffrent config.xml commands to copy the sound file, but nothing works.
image

Here's the apk screenshot of the folder res/raw
image

@rgomezp
Copy link
Contributor

rgomezp commented May 28, 2019

@elmbrent , could you please test on iOS? This will give me a better idea of what is happening.

@AcidTr , it sounds like your issue is different as it isn't being even copied to the correct directory. Just curious, what is the empty.wav file?

@AcidTr
Copy link

AcidTr commented May 28, 2019

@rgomezp
I don’t know what is this empty.wav file. It just appeared there. One time I tried to build the apk and there was the correct file, but it had 0 bytes. And the empty.wav was there too

@rgomezp
Copy link
Contributor

rgomezp commented May 31, 2019

Try doing a recursive search through the entire project to see if it's being copied at all @AcidTr

@AcidTr
Copy link

AcidTr commented May 31, 2019

@rgomezp nothing was found

@rgomezp
Copy link
Contributor

rgomezp commented May 31, 2019

If nothing was found, I don't think it has to do with the OneSignal SDK. For some reason the file isn't being copied. Try searching for reasons this could be happening

@AcidTr
Copy link

AcidTr commented Jun 10, 2019

@rgomezp as I remember the OneSignal's docs said to just put the file inside the folder < project-root >/platforms/android/res/raw/. I Already put it there and the file still wasn't copied.

@rgomezp
Copy link
Contributor

rgomezp commented Jun 10, 2019

What about the src? Are you sure the source is in the correct directory? Take a look at the official Cordova docs regarding this

@AcidTr
Copy link

AcidTr commented Jun 10, 2019

Yes, it is!

@rgomezp
Copy link
Contributor

rgomezp commented Jun 10, 2019

@AcidTr ,
I would open an issue with Apache Cordova since this is a build issue unrelated to OneSignal.

@elmbrent,
Closing due to no response. If you would like to reopen just let me know

@rgomezp rgomezp closed this as completed Jun 10, 2019
@AcidTr
Copy link

AcidTr commented Jun 12, 2019

@rgomezp , I have just solved it. I just changed the path of the target from "res/raw/phonering.wav" to "app/src/main/res/raw/phonering.wav"

@elmbrent
Copy link
Author

AcidTr can you post a link of your config.xml, I think that would help me out loads!

@AcidTr
Copy link

AcidTr commented Jun 12, 2019

@elmbrent I'm using cordova 8.1.2. Maybe there's some diffrence between versions about this tag
< resource-file >

image

@elmbrent
Copy link
Author

elmbrent commented Jun 12, 2019

I will give this a try thank-you, which android version are you using?

@AcidTr
Copy link

AcidTr commented Jun 12, 2019

"cordova-android": "7.1.4"

@rgomezp
Copy link
Contributor

rgomezp commented Jun 12, 2019

Thanks for following up

@mollyAC
Copy link

mollyAC commented Jul 6, 2019

This is not working with android 8.0.0 and above

@blinks32
Copy link

worked for me

@sergiol29
Copy link

Hi, I've similar issue. When I send a notification with default sound or custom sound the android devices show notification but only vibrate and don't play any sound.

At devices iOS I have not issues, the devices show notification and play sound correctly.

First issue was I've issue that I run the command to generate the apk, the sound wasn't copied to the correct directory and I solved with this line in config.xml:
Captura de pantalla 2019-09-30 a las 14 05 58

As second step, I configured a category on oneSignal as you can see in the next picture:
Captura de pantalla 2019-09-30 a las 14 09 09

And last step, I generate a notification and the options I select "urgent" category:
Captura de pantalla 2019-09-30 a las 14 11 17

Also, I tested with default sound at the category:
Captura de pantalla 2019-09-30 a las 14 15 21

But my devices show the notification and don't play any sound and only vibrate.
I tested in several devices and nothing devices play sound.

To init oneSignal in my project, I developed the next function:
Captura de pantalla 2019-09-30 a las 14 17 44

NOTE: I don`t have the devices on silent when receiving the push notifications.

Could you help me?
Thanks.

@rgomezp
Copy link
Contributor

rgomezp commented Sep 30, 2019

Take a look at our docs. It looks like you may not have it in the right path

@efebello
Copy link

efebello commented Jan 28, 2020

@sergiol29 Did you find a solution? I'm facing exactly the same problem (Android).
Worse, in my case, the custom sound does not sound (it only vibrates) when I update the APK.
If I do a clean installation of the APK it sounds correct.

Sound files have the correct file extension
Sound files are encoded in a supported format
Sound files are in the correct location
Sound files are not too long
Sound files are in the APK when I look/decompile

Thanks

@spinninghamster
Copy link

spinninghamster commented Apr 4, 2020

Does anyone have a solution? We checked and all the paths are correct and the same app receives notification sounds on Android 8 but not on Android 9. Both clean installs and updates don't make a sound.

@sergiol29
Copy link

I fixed up the issue, I installed different versions the plugin OneSignal-Cordova-SDK (https://github.com/OneSignal/OneSignal-Cordova-SDK/releases) until the issue was fixep up (version 2.6.0) because the last version I do not worked for me

@spinninghamster
Copy link

Take a look at our docs. It looks like you may not have it in the right path

This issue shouldn't be closed. It's still happening to a lot of people and clearly a real problem. We wanted to use OneSignal but this problem was too much for us, so we switched back to plain Firebase.

We made sure all the paths are correct, the files are in correct formats, not too long, ensured that after building they are there, etc.

The issue for us was that on some Android versions it worked and on others it didn't. When we switched back to plain Firebase it worked fine on every version.

There's clearly a problem here..

@Waterloo
Copy link

Does anyone have a solution?

@rgomezp
Copy link
Contributor

rgomezp commented Apr 27, 2020

Howdy,
@rcpinheiro says this solved the issue. Try:

In my case I just had to change the destination folder:
<resource-file src="/res/notificacao/mybell.mp3" target="app/src/main/res/raw/mybell.mp3" />

It seems the official docs are wrong.

@ahliit
Copy link

ahliit commented Nov 27, 2023

Is this issue still open? The solution above is not working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests