germanattanasio / speech-ios-sdk

DEPRECATED - use https://github.com/watson-developer-cloud/ios-sdk
https://github.com/watson-developer-cloud/ios-sdk
Other
34 stars 15 forks source link

[STT] No error when mic access was denied #34

Closed nacho4d closed 8 years ago

nacho4d commented 8 years ago

The first time recognize: method is called, iOS will request microphone access to the user: "My App" Would like to Access the Microphone. [Don't Allow] [Allow] . If the user presses Don't Allow this SDK does not return an error to the host application.

The socket connection is already stablished, hence it depends on the "inactivity_timeout" parameter to fail.

The bug can be easily reproduced by resetting the settings:

General > Reset > Reset Location & Privacy

I suspect something like below is needed before starting the connection:

[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
    if (granted) {
        // Permission granted
    } else {
        // Permission denied
    }
}];

http://stackoverflow.com/questions/24981333/ios-check-if-application-has-access-to-microphone

mihui commented 8 years ago

Yes, this is right, and we need to find a proper way to produce an error. Additionally, I'm looking into iOS 6 compatibility issues, so this validation would be nicer:

if([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission:)]) {
    [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
        if (granted) {
            // Permission granted
        } else {
            // Permission denied
        }
    }];
}
nacho4d commented 8 years ago

Since above changes were in a PR that was closed I have made another PR.

nacho4d commented 8 years ago

I merged the PR, closing this.