iOS No Sound Workaround!!!
Hello,
Obviously different people can experience the same symptom (iOS Sound not Working) for different reasons. I'm not sure WHY my iOS sound wasn't working, but I did find a work around that worked for me. I built a game that was working great in Android, but when I exported it from Construct 2 (as an XDK file), then wrapped it with XDK as an iOS app I got no sound. I was using the Cordova native audio plugin at first, then tried several others. One by one, I tried every single plugin I could find that mentioned the word audio. Eventually, I tried the Third Party Cordova Background Audio plugin (even though my app doesn't use background audio), annnnnnnd SUCCESS!! All of the sudden my sounds and music were working like a charm! The caveat here is getting it by Apple's review process since my app doesn't need it (background audio). Well, it took a few attempts and rejections before I was able to use it without them rejecting me for it. Here's how to do it in XDK (for building in other tools, adapting this info shouldn't be too difficult).
Step 1) Add the background audio plugin ...
- You can keep the others (like cordova-plugin-nativeaudio) if you want, but this one will work by itself.
- On the Build Page, under Plugins, click the button to add another plugin
- Choose Third Party Plugins
- Paste the following into the top textbox "nl.kingsquare.cordova.background-audio" (without quotes of course!)
- Click Add (Test it!)
Step 2) To get it approved by Apple if your app doesn't use background audio ...
- After adding the plugin goto the 'Develop' tab
- Do a 'Find in files' and search for "UIBack"
- You should get one result, the plugin's .xml file
- Just below "UIBackgroundModes" (about 3/4's of the way down the page) remove the following lines/tags ...
<array>
<string>audio</string>
</array>
-Then save and close the file, that's it. Now you can submit the app to Apple without them rejecting it for "declaring" a feature it doesn't use.
I hope this helps you . . .
P.S. - For those who don't know, background audio is the ability for your app to continue to play sound even when it's in the background (ie: user has hit 'Home' button and/or has gone on to some other app.)