How do I know if the iPhone is in silent mode?

I have a newsletter app. If the user sends mail successfully, then I need to notify that the letter was sent successfully. To do this, I need to know whether his phone is in silent mode (in this case it will “vibrate”) or normal mode (in this case there will be a “sound signal”). Can anyone help me with this?

Thanks in advance

+3
source share
2 answers
CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if(CFStringGetLength(state) == 0)
{
    //SILENT

}
else
{
    //NOT SILENT

}

If the status bar is empty, the phone is disconnected - otherwise the phone has an audio output

EDIT:

Remember to add the AudioToolbox structure and import. - Thomas Clayson

, (http://iphone-dev-tips.alterplay.com/2009/12/iphone-silent-mode-detection.html)

0

Source: https://habr.com/ru/post/1768396/


All Articles