IPhone: software checks if vibration is turned on

Can I programmatically check if the iPhone system option is

Settings -> Sounds -> Vibrate on Ring 

included?

In my application, I would like to show a warning to the user if this option is disabled.

0
ios iphone settings vibration isenabled
source share
2 answers

You can not. Because Apple does not provide an API to access the iPhone settings application.

0
source share

Perhaps you can try and make sure that you are using the application in iDevice, because the simulator does not have a silent or ringer mode :)

New changes

 -(BOOL)silenced { #if TARGET_IPHONE_SIMULATOR // return NO in simulator. Code causes crashes for some reason. return NO; #endif CFStringRef state; UInt32 propertySize = sizeof(CFStringRef); AudioSessionInitialize(NULL, NULL, NULL, NULL); AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state); if(CFStringGetLength(state) > 0) return NO; else return YES; } 

and you can call this method as follows

 if ([self silenced]) { NSLog(@"silenced"); } else { NSLog(@"not silenced"); } 

Hope this helps you!

-one
source share

All Articles