My requirement is to check if the app has microphone access granted or not. If not then get the access. My app is built using Cordova. I have used https://github.com/edimuj/cordova-plugin-audioinput and https://github.com/dpa99c/cordova-diagnostic-plugin they work for Android and iOS devices except for XIAOMI devices. In XIAOMI devices I always get the permission has granted already but that is not true. Is there any Cordova plugin I can use which works in XIAOMI devices also?
Sample code using the audio input plugin
// First check whether we already have permission to access the microphone.
window.audioinput.checkMicrophonePermission(function(hasPermission) {
if (!hasPermission) {
// Ask the user for permission to access the microphone
window.audioinput.getMicrophonePermission(function(hasPermission) {
if (!hasPermission) {
scope.showMicrophoneDeniedMsg = true;
}
});
}
});
Sample code using the diagnostic plugin
cordova.plugins.diagnostic.getMicrophoneAuthorizationStatus(function(status) {
if (status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
console.log("Microphone use is authorized");
} else {
console.log("Microphone use is denied");
cordova.plugins.diagnostic.requestMicrophoneAuthorization(function(status) {
if (status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
console.log("Microphone use is authorized");
}
}, function(error) {
console.error(error);
console.log("Microphone use is denied 1");
});
}
}, function(error) {
console.error("The following error occurred: " + error);
});