Reputation: 89
I want to customize background notification sound in my iOS application, i tried it by placing sound file in the below listed paths but not working.
cordova version:
8.0.0
cordova platform version :
Installed platforms: ios 4.5.5 Available platforms: android ~7.0.0 browser ~5.0.1 osx ~4.0.1 windows ~5.0.0 www ^3.12.0
Push Plugin version:
phonegap-plugin-push 2.2.3
sound file added in :
//i tried these file locations
{projectname}/
{projectname}/www
{projectname}/res
{projectname}/platforms/ios/{projectname}/
{projectname}/platforms/ios/{projectname}/Resources/
{projectname}/platforms/ios/
Thank you in advance.
Upvotes: 1
Views: 1452
Reputation: 440
I've faced the exact same issue and sorted it. I'm using FCM
The correct directory is:
{projectname}/platforms/ios/{projectname}/Resources/
BUT
Putting the file in the directory is not enough.
I had to drop the file from finder into XCode Resource folder of my app with options "Copy if needed" and "Add to target"
I think there could be a way to automate this maybe through config.xml.
Then finally i could manage to get the custom sound of the notification play.
Also in the payload you need to ensure you have on "Notification" top level "sound" and that needs to include filename with extension (putting "sound" in "data" does not work).
What is cool is that also mp3 are working so you can cut down the size of file comparing to caf files and use the same files for both iOS and Android
PS: Please note that phonegap-push-plugin requires cordova 7.1.0 and ios 4.5.0 (just in case it matters)
Upvotes: 1