You should be able to achieve this using:
#import "AudioToolbox/AudioToolbox.h"
- (void) ifSilentModeThenShowIcon
{
CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if(CFStringGetLength(state) == 0)
{
// phone's ringer is off so put
// some icon showing code here
}
}
Source
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…