Edit

Share via


SFSpeechRecognizerAuthorizationStatus Enum

Definition

Enumeration of the permission status of speech recognition.

[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 10, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public enum SFSpeechRecognizerAuthorizationStatus
type SFSpeechRecognizerAuthorizationStatus = 
Inheritance
SFSpeechRecognizerAuthorizationStatus
Attributes

Fields

Name Value Description
NotDetermined 0

Permission has not been presented.

Denied 1

The user has denied permission for speech recognition.

Restricted 2
Authorized 3

The user has allowed speech recognition.

Remarks

Applications that use speech recognition must have an entry in their info.plist file with a key of NSSpeechRecognitionUsageDescription and a string value. The string value will be displayed in a standard system dialog after the developer calls RequestAuthorization(Action<SFSpeechRecognizerAuthorizationStatus>).

<key>NSMicrophoneUsageDescription</key>
<string>Your microphone will be used to record your speech when you press the "Start Recording" button.</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>Speech recognition will be used to determine which words you speak into this device's microphone.</string>          

For instance:

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:
				prepareButton.Enabled = false;
				break;
		}
	});
}          

Applies to