1
votes

I am using @ionic-native/android-permissions. My code in app.component.ts:

this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.RECORD_AUDIO).then(
          (result)=>{   
       if(!result.hasPermission)
       {
         this.androidPermissions.requestPermissions(
           [this.androidPermissions.PERMISSION.RECORD_AUDIO, 
             this.androidPermissions.PERMISSION.GET_ACCOUNTS]
            ).then(()=>{
             // this.rootPage = HomePage;
             window.location.reload();
            });

   }
     });

It is working when I do :

ionic cordova run android

or

ionic cordova build android

or

ionic cordova build android --release

But the app is not asking for permission if I add --prod. i.e. :

ionic cordova run android --prod

or

ionic cordova build android --prod --release

So the device mic is not working for the app.

1
the code seems correct. have you added the plugin correctly as stated in the docs? is the java code part of the apk?Stefan
I don't think it's a coding issue. Because the app is working perfectly with notmal build. But for prod built I'm facing issue. Seems like its a bug in Ionic. Just wanted to check if someone have any solution.Arijit
it is on the plugin/cordova side, so not at ionic...Stefan
Any update on this? I'm facing the same error :(MrRobot

1 Answers

0
votes

I had this issue, and i solved it by adding permissions to config.xml then, popup will show and ask client for permissions. add permissions to config.xml

<platform name="android">
....
<config-file parent="/manifest" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-feature android:name="android.hardware.microphone" android:required="true" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
</config-file>
....
</platform>