Search code examples
javascriptandroidfirefoxoffline-storage

Can not activate navigator.storage.persist in Firefox for Android


StorageManager has an API to make offline storages persistent which make them not to suffer from purging when there is not enough free space on user's drive. https://developer.mozilla.org/ru/docs/Web/API/StorageManager/persist

I want to use persistant offline storage for my website. Persistant mode can be activated using this code:

navigator.storage.persist.then(
  function(persist_enabled) {console.log(persist_enabled)}
)

When this command is executed in Desktop FireFox version the browser prompts a permission and if a user allowed it persist_enabled is "true".

But when I run this command in Android Firefox version there is no permission prompt and the result is always "false".

Is there some condition I must to satisfy to turn this feature on on Adroid Firefox?

Update 2020.09.29

Firefox support team said that it is a bug. The permission prompt must be popped up but it's not. We should wait for a fix. https://github.com/mozilla-mobile/android-components/issues/3153


Solution

  • There are bad news for current date (checked on 9'th september 2020)

    According to "Can i use" site (https://caniuse.com/mdn-api_storagemanager) this feature is not supported by default in Firefox 79 for Android. It must be enabled via internal configuration.

    So it's not possible to use this feature for a regular site for now as users probably would not enable it.

    Upd. 2020.12.11 There was a bug in Firefox for Android. The prompt should popup but it's not. Here is a related issue in github: https://github.com/mozilla-mobile/fenix/issues/14875 The problem is solved now.