When i press volume button three times its need to show notification. i want to integrate this feature in my app.
Any help will be appreciated.Thanks in advance.
When i press volume button three times its need to show notification. i want to integrate this feature in my app.
Any help will be appreciated.Thanks in advance.
First, you initialise the AVAudioSession and add a listener by:
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:YES error:nil];
[audioSession addObserver:self
forKeyPath:@"outputVolume"
options:0
context:nil];
Then you store the current system volume by:
float currentVolume = [audioSession outputVolume];
Then observe the volume change notification:
-(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqual:@"outputVolume"]) {
float newVolume = [[AVAudioSession sharedInstance] outputVolume];
}
}
You compare the newVolume and the currentVolume to determine the expected outcome.