SFSpeechRecognizer.AuthorizationStatus Property

Definition

The current status of user permission for speech recognition.

public static Speech.SFSpeechRecognizerAuthorizationStatus AuthorizationStatus { [Foundation.Export("authorizationStatus")] get; }
member this.AuthorizationStatus : Speech.SFSpeechRecognizerAuthorizationStatus

Property Value

The default value for this is NotDetermined.

Attributes

Remarks

As with other facilities involving privacy, the user must positively permit the app to access speech recognition.

Apps that use speech recognition must add the following key, with appropriate descriptions, in their info.plist file:

<key>NSSpeechRecognitionUsageDescription</key>
<string>Speech recognition will be used to determine which words you speak into this device's microphone.</string>          

If an application does not have this key, the operating system will execute a "silent" shutdown at runtime, with no exception or ability to log the mistake.

The value of the info.plist string is presented to the user in response to the RequestAuthorization(Action<SFSpeechRecognizerAuthorizationStatus>) method:

if (SFSpeechRecognizer.AuthorizationStatus != SFSpeechRecognizerAuthorizationStatus.Authorized)
{
	SFSpeechRecognizer.RequestAuthorization((status) => 
	{
	   switch (status)
	   {
		   case SFSpeechRecognizerAuthorizationStatus.Authorized:
			   InvokeOnMainThread(() => prepareButton.Enabled = true);
			   break;
		   case SFSpeechRecognizerAuthorizationStatus.Restricted:
		   case SFSpeechRecognizerAuthorizationStatus.NotDetermined:
		   case SFSpeechRecognizerAuthorizationStatus.Denied:
				 InvokeOnMainThread(() => prepareButton.Enabled = false);
			   break;
	   }
    });
}

Applies to