Microphone on iOS check if permission given

I can’t find any way of checking if the user has given the app permission to use the microphone. I’m recording like this:

audio.clip = Microphone.Start("Built-in Microphone", true, LOOPLENGTH, AudioSettings.outputSampleRate);
audio.loop = true;
while (!(Microphone.GetPosition("Built-in Microphone") > 0)) {
} audio.Play();

which works fine. but if the user has not granted permission then there doesn’t seem to be any way of checking, in order to behave differently (or show an alert, etc)

I’ve tried checking if Microphone.Start returns null, but when permission is turned off it still returns non-null.

I’ve also tried checking Microphone.IsRecording, but that seems to return true even when permission is turned off as well.

edit:

i ended up using a (very) hacky workaround, checking the power of the mic input every update and assuming permission is denied if it’s zero:

samples = new float[SAMPLECOUNT];

audio.GetOutputData(samples, 0);

double rmsCalc = 0;
for (int i = 0; i < SAMPLECOUNT; i++) {
	rmsCalc += Mathf.Pow(samples*, 2);*

}
rmsCalc = Math.Sqrt(rmsCalc/(double)SAMPLECOUNT);

if (rmsCalc < 0.0000000000000000000000000000000000000001f) {

  • micOff = true;*
    }
    else {
  • micOff = false; *
    }

https://forum.unity3d.com/threads/ios-app-never-asks-for-microphone-permissions.450307/

Application.HasUserAuthorization(UserAuthorization.Microphone);
Turns out that the docs are supposed to incorrect on this issue. Should work for iOS.