- (void) checkMicrophoneAccess { switch ([[AVAudioSession sharedInstance] recordPermission]) { case AVAudioSessionRecordPermissionGranted: [self addAudioFromMicrophone]; NSLog(@"📹 Mic enabled 👍"); break; case AVAudioSessionRecordPermissionDenied: NSLog(@"📹 Mic does not have permission 👎"); [self presentMicrophoneSettings]; break; case AVAudioSessionRecordPermissionUndetermined: [[AVAudioSession sharedInstance] requestRecordPermission: ^(BOOL granted) { NSLog(@"Mic enabled %@", granted == YES ? @"YES" : @"NO"); }]; break; default: break; } } - (void) presentMicrophoneSettings { UIAlertController * alert = [UIAlertController alertControllerWithTitle: NSLocalizedString(@"common_alert_title_warning", nil) message: NSLocalizedString(@"toast_error_permission_mic", nil) preferredStyle: UIAlertControllerStyleAlert]; UIAlertAction* settingsButton = [UIAlertAction actionWithTitle: NSLocalizedString(@"application_settings_title", nil) style: UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSURL * url = [NSURL URLWithString: UIApplicationOpenSettingsURLString]; if ([[UIApplication sharedApplication] canOpenURL: url]) { [[UIApplication sharedApplication] openURL: url options: @{} completionHandler: nil]; } }]; UIAlertAction* cancelButton = [UIAlertAction actionWithTitle: NSLocalizedString(@"common_button_cancel", nil) style: UIAlertActionStyleDestructive handler: nil]; [alert addAction: settingsButton]; [alert addAction: cancelButton]; [UIApplication.sharedApplication.keyWindow.rootViewController presentViewController: alert animated: YES completion: nil]; }