//To prompt Microphone request at anytime [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {}]; //To detect if microphone is allowed for the application // This can be found inside privacy settings of the device -(BOOL)isMicrophonePrivacyOn { __block BOOL micStatus; if([[AVAudioSession sharedInstance] respondsToSelector: @selector(requestRecordPermission:)]) { [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) { if(!granted) { micStatus = NO; } else { micStatus = YES; } }]; return micStatus; } else { return YES; } }
iOS 7 Microphone request
iOS 6+ interruption handling
//init interruption handler AVAudioSession* session = [AVAudioSession sharedInstance]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(InterruptionHandler:) name:AVAudioSessionInterruptionNotification object:session]; - (void) InterruptionHandler: (NSNotification*) notification { NSUInteger type = [[notification.userInfo objectForKey:@"AVAudioSessionInterruptionTypeKey"] unsignedIntegerValue]; switch(type) { case AVAudioSessionInterruptionTypeBegan: printf_console("-> AVAudioSessionInterruptionTypeBegan()\n"); break; case AVAudioSessionInterruptionTypeEnded: { printf_console("-> AVAudioSessionInterruptionTypeEnded()\n"); break; } } }
Subscribe to:
Posts (Atom)