Android Cordova-在小米设备中使用麦克风

Android Cordova-在小米设备中使用麦克风,android,cordova,cordova-plugins,microphone,xiaomi,Android,Cordova,Cordova Plugins,Microphone,Xiaomi,我的要求是检查应用程序是否允许麦克风访问。如果没有,则获取访问权限。我的应用程序是使用Cordova构建的。除了小米设备外,我使用过Android和iOS设备,它们也适用。在小米设备中,我总是得到已经授予的许可,但事实并非如此。有没有我可以在小米设备上使用的Cordova插件 使用音频输入插件的示例代码 // First check whether we already have permission to access the microphone. window.audioinput.che

我的要求是检查应用程序是否允许麦克风访问。如果没有,则获取访问权限。我的应用程序是使用Cordova构建的。除了小米设备外,我使用过Android和iOS设备,它们也适用。在小米设备中,我总是得到已经授予的许可,但事实并非如此。有没有我可以在小米设备上使用的Cordova插件

使用音频输入插件的示例代码

// 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;
            }
        });
    }
});
使用诊断插件的示例代码

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);
});

找到了问题所在。我直接在config.xml中添加插件,就像

<plugin name="cordova-plugin-audioinput" spec="1.0.1"/>

现在我分别添加了iOS和Android

<platform name="ios">
    <plugin name="cordova-plugin-audioinput" spec="1.0.1"/>
</platform>

<platform name="android">
    <plugin name="cordova-plugin-audioinput" spec="1.0.1"/>
</platform>

工作起来很有魅力