Created
September 25, 2016 22:33
-
-
Save gaelfoppolo/e4ba47215ca46411f71eadcf6ccf6841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func askForSpeechRecognitionPermissions() { | |
SFSpeechRecognizer.requestAuthorization { authStatus in | |
var enabled: Bool = false | |
var message: String? | |
switch authStatus { | |
case .authorized: | |
enabled = true | |
case .denied: | |
enabled = false | |
message = "User denied access to speech recognition" | |
case .restricted: | |
enabled = false | |
message = "Speech recognition restricted on this device" | |
case .notDetermined: | |
enabled = false | |
message = "Speech recognition not yet authorized" | |
} | |
/* The callback may not be called on the main thread. Add an operation to the main queue if you want to perform action on UI. */ | |
OperationQueue.main.addOperation { | |
// here you can perform UI action, e.g. enable or disable a record button | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment