Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect iphone is on silent mode

I am developing an application. In that i want to detect through coding that "is iPhone on silent mode or not?". I am developing it by using cocoa with Objective-C.

If anyone knows it kindly reply.

like image 480
Jyotsna Avatar asked May 07 '09 07:05

Jyotsna


People also ask

How can you tell if someone's phone is on silent?

There's no immediate way to alert someone when their phone is on silent. Once a person switches on "silent" mode, their phone will mute notifications from everyone on their contact list. When you call, they won't be able to hear ring tones or alerts.

Can you ping a silent iPhone?

If you lose your device and you think it's nearby, you can use Find My iPhone on iCloud.com to play a sound on it to help you find it. The sound plays even if the device is in silent mode or the volume is muted.

How do I check silent mode?

Press the "Up" volume button on the Android phone until the Silent Mode icon on the screen changes. The Silent Mode icon looks like a speaker with a line through it or a speaker with circle and a line superimposed over it. When the Silent Mode is disabled, only a speaker icon appears.


1 Answers

The reason Pirripli's code does not work is that the simulator does not support the test and the code does not check for errors. Corrected code would look like:

CFStringRef state = nil;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
OSStatus status = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);

if (status == kAudioSessionNoError)
{
    return (CFStringGetLength(state) == 0);   // YES = silent
}
return NO;
like image 95
Neil Avatar answered Oct 06 '22 01:10

Neil