Watch audio recording - no microphone permissions

Hi all,


i am trying to develop simple app which would allow user to record audio using his apple watch.


I am testing both on simulator and on real device too. Recording in simulator works fine. However for some reason when testing on real device (watch) watch is never asking for microphone permissions (dialog is not shown) that means that it seems that audio is being recorded but it is not.


I have tried 2 possible approaches:

1. use presentAudioRecorderController to use built-in audio recorder

2. use AVAudioSession + AVAudioRecorder to handle recording manually. I


// When using option 2 I am also explicitly asking for permission:

let recordingSession = AVAudioSession.sharedInstance()
do {
            try recordingSession.setCategory(.playAndRecord, mode: .default, policy: .default, options: [])
            try recordingSession.setActive(true)
            recordingSession.requestRecordPermission { (hasPermission) in
                if hasPermission {
                   print("accepted")
               }
            }
        }
catch {
    print("Couldn't set Audio session category")
}


However in any of those approaches app never asks for permission. Also I have NSMicrophoneUsageDescription key in both app info.plists (iphone & watch extension)


Device specs:

iPhone X running iOS 13.1.3

watch series 3 (38mm) running watchOS 5.3.2


Thanks for your help.

Replies

What is the value of recordingSession.recordPermission? The documentation for requestRecordPermission says that it doesn't prompt if it doesn't need to, so maybe it doesn't need to. (Maybe it never needed to, if permission was granted on the iPhone. I don't know if the watch and phone permissions are coordinated like that, but maybe they are.)

It is: '

AVAudioSessionRecordPermissionUndetermined
' that means that it should ask for permission.


Also as a workaround i tried to ask for permissions on iphone (directly in iphone app) that works and phone asks for permissions. However even if I grant them, watch still returns

AVAudioSessionRecordPermissionUndetermined

Sounds like you have exactly what you need for a bug report.


It's possible that it's the documentation is wrong, rather than the APIs. Most of those authorization APIs expect your code to ask for authorization explicitly, if the current state is "not determined".


Either way, a bug report should be your next step.