0

I'm using Ionic 4 and all my IOS diagnostic permissions are working..

But on android if I request access to anything (lets say CAMERA for example). It returns a DENIE_ALWAYS response. If I go into the settings>app settings> permissions It is saying that the app doesn't need any permissions. I've verified the permissions exist in the androidManifest.xml. But I am unable to ever prompt to user for permissions.

Any help on this would be appreciated.

Example code

   this.diagnostic.getCameraAuthorizationStatus()
    .then( async (status) => {
      debugger;
      if (status === this.diagnostic.permissionStatus.GRANTED
        || status === this.diagnostic.permissionStatus.GRANTED_WHEN_IN_USE) {
        this.appSettings.camera.enabled = true;
        this.updateAppSettings();
      } else if (status === this.diagnostic.permissionStatus.NOT_REQUESTED) {
        this.diagnostic.requestCameraAuthorization()
          .then((res) => {
           // HERE IS ALWAYS DENIE_ALWAYS WITHOUT EVER PROMPTING USER
            debugger;
            if (res === this.diagnostic.permissionStatus.GRANTED
              || res === this.diagnostic.permissionStatus.GRANTED_WHEN_IN_USE) {
              this.appSettings.camera.enabled = true;
              this.updateAppSettings();
            } else {
              this.appSettings.camera.enabled = false;
              this.updateAppSettings();
            }
          });

1 Answer 1

0

I finally found the answer after hours of searching..

Under the platforms>android>AndroidManifest.xml you need to make sure this includes all your permissions

    <uses-permission android:name="android.permission.CAMERA" />

But for some reason this AndroidManifest wasn't the same that was being used under

platforms > android> app> src > main> AndroidManifest.xml

And a build wasn't updating that file either. So I copied the correct AndroidManifest.xml to that path and it started working.

This was way harder than it should have been.. I don't know why adding and removing the platform or rebuilding wouldn't updating that manifest..

4
  • i have tried to check the folder. But there is no AndroidManifest.xml file inside platforms > android. File exists at platforms > android> app> src > main> AndroidManifest.xml This file is not containing the permission but node_modules > cordova-android > bin > templates > project > AndroidManifest.xml is containing the permission
    – bvakiti
    Oct 23, 2019 at 1:59
  • @vbharath it's been months since I figured this out.. I just remember it being a nightmare. It all came down to the permissions not being in the right place at the right time.
    – caden311
    Oct 23, 2019 at 16:01
  • @caden311 Did you find the reason why the permissions are not getting added in manifest file? Jun 17, 2020 at 17:40
  • @SanjaySharma this was quite a while ago. But if I remember correctly It was some weird quark. After removing and re-adding on a different machine it seemed to work correctly. I don't know how it got in this state originally.
    – caden311
    Jun 18, 2020 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.