How to check a system vibration is on or off by pogramatically through App? In my case UI design is like- I set a button into viewcontroller. Which funcanality is, when I press the button it's alert me the system vibration is On or Off. Here is the below code. But it's not working. It's always go with else part.
- (IBAction)checkVibrate:(id)sender {
CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if(CFStringGetLength(state) == 0)
{
//off
[self Alert:@"It seems that your phone's vibration is off. Please go to your phone setting and make the vibration ON"];
}
else
{
//on
[self Alert:@"It seems that your phone's vibration is On.If you want to off the vibration, please go to device setting and make vibration Off"];
}
}
If I go through wrong way,please help me out with this topic?