Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVAudioSession.requestRecordPermission not showing dialog

I'm trying to record audio in a project I inherited. All used to work fine, until iOS 9. It seems now requestRecordPermission calls it's block with false without displaying a dialog. When I check for the current permission, before requesting it, I always get Undetermined. Even on subsequent runs of the app without a reset.

I'm testing on an actual device, and resetting the permissions (settings->general->reset->reset location and privacy) each time. Also my app does not show in settings->privacy->microphone, but does show in the general app's list, where I can see the other permissions it uses but no microphone.

Is there some project setting that can affect it? It seems like the os does not understand that I ask for the permission, hence no dialog and no listing in the permissions.

code:

AVAudioSessionRecordPermission permissionStatus = [[AVAudioSession sharedInstance] recordPermission];    
switch (permissionStatus) {
    case AVAudioSessionRecordPermissionUndetermined:
        [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
            if (granted) {
                NSLog(@"req granted");
            }
            else {
                NSLog(@"req denied");
            }
        }];
        break;
    case AVAudioSessionRecordPermissionDenied:
        NSLog(@"denied");
        break;
    case AVAudioSessionRecordPermissionGranted:
        NSLog(@"granted");
        break;
    default:
        break;
}

this is in AppDelegate.applicationDidFinishLaunchingWithOptions. On every run (first after reset as well as subsequent), the first check returns undetermined, and then requestRecordPermission calls it's block with granted=false without displaying a dialog.

like image 939
Ridiculous Avatar asked Jan 07 '23 02:01

Ridiculous


1 Answers

Setting the "Bundle display name" (basically the name of your app) in the "Info.plist" will fix the problem.

like image 194
Guitz Avatar answered Jan 19 '23 07:01

Guitz