Mute email alert sound on iOS

I’m sure there must be a simple way to do this but I haven’t found it yet, despite plenty of searching.

I want to disable the incoming email alert sound while my app is running. Likewise for incoming phone calls. Maybe phone calls are diverted already but the iPhone I’m testing on at the moment has no SIM, so I can’t be sure. I’m also testing on an iPad and the incoming email sound ruins it (it’s a music app, you see).

The app is a universal build for all iPhones and iPads (and iPod Touch, in theory at least).

Any help appreciated.
Tony [import]uid: 111970 topic_id: 27363 reply_id: 327363[/import]

Apple won’t allow your app to do this even if it was possible.

Apps are not allowed to modify the functionality of the device, if a phone call happens while a user is playing your game, the best you can do is save it’s state and initiate a pause screen.

For mail, the only thing you can do is have a tagline or something that recommends they disable mail while playing your game. [import]uid: 84637 topic_id: 27363 reply_id: 111151[/import]

OK, thanks Danny. At least now I can stop hunting for a feature that doesn’t exist. :slight_smile: [import]uid: 111970 topic_id: 27363 reply_id: 111159[/import]

I don’t know if this is possible but some of it might be. By default, when you start using audio in your app, Apple changes the ‘Audio Session Category’ to ‘SoloAmbient’ which means only sound from your app will play and other sounds like iPod music will be stopped/disabled.

If you call any of the primary audio APIs (say audio.loadSound), Corona informs iOS that it will be playing audio and Apple will activate the SoloAmbient category mode which will shut off sounds from other apps (e.g. iPod music).

Alternatively, you can try setting the audio session mode directly yourself using the (advanced) Audio Session APIs in Corona. (Refer to the Audio Notes page which has the link.)
This will not let you suppress the incoming phone call or any special iOS ‘interruption’ events. These are impossible to override. But it might lock things like the email ding.
[import]uid: 7563 topic_id: 27363 reply_id: 111242[/import]

Thanks ewing, that was very helpful.

I have now set the Audio Session manually in the code, and while this doesn’t disable email dings and the like, it does fix a major bug that I was struggling with. That is, when the app was interrupted by the user pressing the Home button, the audio did not resume properly, resulting in silence on certain channels.

Now, I set the Audio Session type like so in the main.lua file:

audio.setSessionProperty(audio.MixMode, audio.MediaPlaybackMixMode)

The app now resumes its audio state perfectly when relaunched after being quit with the home button.
For the benefit of anyone with similar problems, this “bug” was only happening if the app was quit during an audio.fade process. The channels or sounds that were interrupted during a fade would not resume or would remain silent when the app was restarted.

But now it works, thanks to changing the Audio Session :slight_smile: [import]uid: 111970 topic_id: 27363 reply_id: 112141[/import]