I have a detecting permission code for firtly microphone and then speechrecognation for open new view. But the code below created error like " This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes."
Could anyone have any idea?
if (@available(iOS 10.0, *)) {
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
if (granted) {
// [self detechUserSpeechPermission];
// [self configureSpeechToTextView];
[SFSpeechRecognizer requestAuthorization:^(SFSpeechRecognizerAuthorizationStatus status) {
switch (status) {
case SFSpeechRecognizerAuthorizationStatusAuthorized:
[self configureSpeechToTextView];
break;
case SFSpeechRecognizerAuthorizationStatusDenied:
[self warnUserForSpeechPermission];
break;
case SFSpeechRecognizerAuthorizationStatusNotDetermined:
[self warnUserForSpeechPermission];
break;
case SFSpeechRecognizerAuthorizationStatusRestricted:
[self warnUserForSpeechPermission];
break;
default: break;
} }];
}
else {
[self warnUserForMicrophonePermission];
}
}];
} else {
NSLog(@"low ios version");
}
try to call methods at main thread like below code:
dispatch_async(dispatch_get_main_queue(), ^{
[self configureSpeechToTextView];
});