uses-permission WRITE_EXTERNAL_STORAGE in ionic3

Viewed 3695

I am just stuck.
I wanted to Download MP3 file to my app.
I am able to download the same in browser while working on it,
As we know, there we need to provide WRITE_EXTERNAL_STORAGE permission. To do so what I did is as below-

  1. Opened platforms/android/AndroidManifest.xml
  2. added

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    But its not working for me. Let me share my Machine Setup-

    cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.12.0
    ionic (Ionic CLI) : 3.12.0
    

    global packages:

    cordova (Cordova CLI) : 7.0.1 
    

    local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.0
    

    I try for this https://ionicframework.com/docs/native/android-permissions/

Also try https://github.com/dpa99c/cordova-custom-config-example/blob/master/config.xml

There is a way for cordova and another way to provide permissions How do I add "uses-permissions" tags to AndroidManifest.xml for a Cordova project? I am unable to write it.

Help me plz...

1 Answers

open your ts file and write this code

checkPermissions(){
        this.androidPermissions.requestPermissions(
           [
             this.androidPermissions.PERMISSION.CAMERA,  
             this.androidPermissions.PERMISSION.GET_ACCOUNTS, 
             this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE, 
             this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE
           ]
        );
    }

this resolved my problem.

Related