How do i request mic record permission from user

As "One Man Crew" claimed you can use requestRecordPermission.

Important thing to be aware of is that you must check that requestRecordPermission is implemented. The reason is that if your app would run on older iOS version (iOS 6.x for example) it would crash after this call. To prevent that you must check that this selector is implemented (this is a good practice anyway).

Code should be something like this:

if([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission:)]){
    [[AVAudioSession sharedInstance] requestRecordPermission];
}

Using this method your app would support the new OS and also previous versions of the OS.

I'm using this method every time Apple add more functionality to new OS (that way I can support older versions pretty easy).


Here is final code snippet that does work for me. It support both Xcode 4 and 5, and works for iOS5+.

#ifndef __IPHONE_7_0
    typedef void (^PermissionBlock)(BOOL granted);
#endif

    PermissionBlock permissionBlock = ^(BOOL granted) {
        if (granted)
        {
            [self doActualRecording];
        }
        else
        {
            // Warn no access to microphone
        }
    };

    // iOS7+
    if([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission:)])
    {
        [[AVAudioSession sharedInstance] performSelector:@selector(requestRecordPermission:)
                                              withObject:permissionBlock];
    }
    else
    {
        [self doActualRecording];
    }

In the new iOS7 it's very simple try this:

if([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission)])
{
    [[AVAudioSession sharedInstance] requestRecordPermission];
}