Filesystem.requestPermissions() doesn't work!

Hi all,

I want to let user download a created image to local, but if user accidentally click the wrong button “deny”, then next time, the image won’t be downloaded. To avoid this, I want to let my program ask the user every time which the the write permission is denied, then it will prompt a query to let user allow the write permission.

I tried the following code:

    let permission = await Filesystem.checkPermissions()

    if (permission.publicStorage !== "granted") {

      permission = await Filesystem.requestPermissions() // Why this doesn't work????

      if (permission.publicStorage !== "granted") {
        return
      }
    }

However, this function await Filesystem.requestPermissions() doesn’t work at all, it didn’t prompt anything…

Do you have any idea about it?

If you look at the source to the Filesystem plugin, there is no “PluginMethod” annotation assigned to any method named “checkPermissions”. Instead, the Filesystem plugin tries to request permission only when you actually try to access a file in the filesystem the requires permissions.

Furthermore, you will see that it only every posts the request-permission dialog to the end-user when you access the “DOCUMENTS” directory or the “EXTERNAL_STORAGE” directory. If you use any of the other directories, the permissions aren’t needed and therefore you won’t see the dialog.

Hope this helps.

2 Likes