iOS: How to set ringer and alert volume within my App

2.4k views Asked by At

For my APP, one of the important function is to mute the iPhone, but I can't find any available iOS API that I can use to mute the phone(or change the ringer volume level to minimum). Is their a specific API for developer to mute (or change the ringer volume of) the phone, if their is not, is there a indirect way to do this?

2

There are 2 answers

0
modesitt On

I believe you can only mute other application sounds. You need to configure the AVAudioSession category :

AVAudioSession Class Reference : http://goo.gl/rh7CX7 .

Look for which fit the most for your application. You only need to set it once in your code (make sure it's called).

AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategorySoloAmbient, error: nil) // AVAudioSessionCategorySoloAmbient is default AVAudioSession.sharedInstance().setActive(true, error: nil)
1
Moin Shirazi On

No.

Applications developed using the official SDK cannot change (and in most cases cannot even access) system-wide settings.

It is possible, but only using private API's. I only went as far as muting the ringer, but you should be able to control the master level as well.

See How to disable iOS System Sounds