sparrowcode / PermissionsKit

Universal API for request permission and get its statuses.
https://x.com/sparrowcode_ios
MIT License
5.64k stars 462 forks source link

VoiceRecognition permission ? #35

Closed francoisdeberry closed 5 years ago

francoisdeberry commented 7 years ago

Hey !

Love your work, sincerely ! I need to ask the user for voice recognition (Speech Kit) API, could you add it ?

Thanks !

francoisdeberry commented 7 years ago

Oh ! Would it too much to ask for activity sensors permission too ? (accelerometer, pedometer etc.). It's an all-in-one permission for all sensors :)

ivanvorobei commented 7 years ago

Soon I added it. If you can create swift file with implement SPPermission protocol - it happen faster

francoisdeberry commented 7 years ago

Something like this ? The following is for SpeechRecognition permission.

import Speech

class SPSpeechRecognitionPermission: SPPermissionInterface {

func isAuthorized() -> Bool {
    if SFSpeechRecognizer.authorizationStatus() == .authorized {
        return true
    } else {
        return false
    }
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {

    SFSpeechRecognizer.requestAuthorization {
        status in
        DispatchQueue.main.async {
            complectionHandler()
        }
    }
}

}

About CoreMotion, there is no authorizationStatus method yet (Beta method) Apple (code example) launch a queryActivityStarting and check for error in the completion block to do this. I dunno if your system can handle an async response query inside its check method ?

ivanvorobei commented 7 years ago

Thanks for you, soon I added it in pod

turk-jk commented 6 years ago

any update ?

francoisdeberry commented 6 years ago

Hi Turk, I don't think that it has been integrated by the author yet. I personally forked the project and made a huge redesign but it's not quite PR-ready and I don't have time to clean it... If it's just the voice recognition you're looking for, it's not the hardest one to manually add. If I remember correctly, you just have to add the corresponding interface and some assets and you're up and running. GL