Hello everybody!
I’m very new with ionic, but I’m coming from cordova and react. So I tried to recreate a simple app with ionic-react. I now want to read a directory structure and manage files. I added the required permissions in the android manifest file. Problem is: in visual studio, using the ionic extension for debugging, the console says the permissions are not set and to add them in the manifest. ??? What’s more, the application running on a real device does not ask for any permission as it used to do with cordova. I’m running an android 6, so everything should be granted/asked from the manifest file, not at use time…
Any idea why the AndroidManifest.xml file seems to be ignored?
Thanks for your help!
Here the test code:
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
import { AndroidPermissions } from '@awesome-cordova-plugins/android-permissions/ngx';
export async function readDirectory(): Promise<string[]> {
const toto = new AndroidPermissions();
toto.checkPermission(toto.PERMISSION.READ_EXTERNAL_STORAGE).then((result) => console.log("READ_EXTERNAL_STORAGE", result)).catch(err => console.error(err));
toto.checkPermission(toto.PERMISSION.WRITE_EXTERNAL_STORAGE).then((result) => console.log("WRITE_EXTERNAL_STORAGE", result)).catch(err => console.error(err));
toto.requestPermissions([toto.PERMISSION.READ_EXTERNAL_STORAGE, toto.PERMISSION.WRITE_EXTERNAL_STORAGE]).then(async () => {
const content = await Filesystem.readdir({
path: "Downloads",
directory: Directory.ExternalStorage
});
console.log(content);
});
return [];
}
The ‘checkPermission’ result are ‘hasPermission’ However, the ‘readdir’ failed.