Closed JCFowler closed 5 years ago
@JCFowler give this a shot in your code:
switch (AVAudioSession.sharedInstance().recordPermission) {
case AVAudioSessionRecordPermission.Granted:
// hooray proceed with recorder
break;
case AVAudioSessionRecordPermission.Denied:
// prompt user they need to allow the permission in setitngs
break;
case AVAudioSessionRecordPermission.Undetermined:
// This is the initial state before a user has made any choice
// You can use this spot to request permission here if you want
break;
}
Do that before interacting with the TNSRecorder 👍
@NathanWalker Awesome!!! This is exactly what I was looking for!! I'm surprised that all my google searching yesterday, I couldn't find a solution like this. Thanks a lot Nathan!
Just incase anyone else will find this post, In order to use AVAudioSession, you need to add the iOS reference to your project. You can follow this guide to do that: https://docs.nativescript.org/core-concepts/accessing-native-apis-with-javascript#intellisense-and-access-to-the-native-apis-via-typescript
This plugin works perfectly on Android, but iOS i'm having a few problems. When the user either denies permission to record, or accepts permission and the goes into settings and turns microphone off for the app, the app just hangs on the start() method for iOS. All I get back in the log is this:
NativeScript-Audio - TNSRecorder setCategoryError: null
It doesn't reject the promise, or finishes the promise, so it just gets hung up on the method.
Also I noticed that TNSRecorder.CAN_RECORD(): will always return true on iOS.
My question is, is there a way to check permission for iOS before the start() call? Or is there something I'm missing on the iOS side to make this a lot easier?
Thank you!