iPhone silent mode detection
#import "AudioToolbox/AudioToolbox.h"
- (void) ifSilentModeThenMessage
{
CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if(CFStringGetLength(state) == 0)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Silent mode"
message:@"Please turn sound on"
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
浙公网安备 33010602011771号