Settings page opens in background after installation on firefox mobile

Hi. We’re working on the firefox addon and also tried to post it for firefox mobile. There is an issue, when we install the addon, addon settings page was opened in background and user cannot complete its initial setup. We’re using this code to open the settings page on install. it works like a charm for desktop firefox.

browser.runtime.onInstalled.addListener((object) => {
      if (object.reason === 'install') {
        browser.runtime.openOptionsPage();
      }
    });

Any ideas how can we fix that behavior for mobile addon?

Unfortunately there is currently a bug with runtime.openOptionsPage() on Android where this method does not display the options page as expected. The issue is being tracked in bug 1795449.

As a temporary workaround, you may be able to open a new tab with the URL of your options page:

browser.tabs.create({
  url: browser.runtime.getURL("path/to/options.html");
});

I’m on my phone and therefore couldn’t test the code snippet I shared, but I think it should work without modification. Apologies in advance for any errors.

1 Like