Reputation: 5081
I have develope one app in that app i am working on proximity sensor detection. And when proximity detect make vibrate a phone. It's run successfully but when second time open that app and detect proximity phone not vibrate condition execute both first and second time. i am confuse now please help me to do this.
below code i have been used.
if([[delegate.vibrationdefault stringForKey:@"Vibration"] isEqualToString:@"on"])
{
NSLog(@"Proximity detect with vibration on") ;
[recorder stop];
//AudioServicesPlayalSound (kSystemSoundID_Vibrate) ;
AudioServicesPlayAlertSound (kSystemSoundID_Vibrate) ;
[recorder record];
}
Upvotes: 0
Views: 782
Reputation: 826
I am not very sure that this will work fine, but you can maybe do like this:
if([[delegate.vibrationdefault stringForKey:@"Vibration"] isEqualToString:@"on"])
{
NSLog(@"Proximity detect with vibration on") ;
[recorder stop];
//AudioServicesPlayalSound (kSystemSoundID_Vibrate) ;
AudioServicesPlayAlertSound (kSystemSoundID_Vibrate) ;
sleep(1);
AudioServicesPlayAlertSound (kSystemSoundID_Vibrate) ;
sleep(1);
AudioServicesPlayAlertSound (kSystemSoundID_Vibrate) ;
[recorder record];
}
You can use the sleep(timeInSeconds);
under to delay it. I'm not sure if you could use 0.5 seconds, but you can try it.
Upvotes: 1