Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default browser of cordova browser platform?

Tags:

cordova

I don't have chrome installed and I mainly use other browsers for development (opera, yandex etc). But the command:

cordova run browser

uses chrome by default, so it fails with " The system can not find the file chrome.". Can I change which browser cordova uses?

like image 591
uylmz Avatar asked Jun 28 '16 11:06

uylmz


People also ask

What browser does Cordova use?

1. I figured out that Cordova is not using the Chrome App as browser. Instead it is using the browser integrated in the "Android System WebView" app, which is updatable in Google Play Store. Actually it is Chrome, but a different version from the Chrome App.

How do I add a browser platform to Cordova?

Before you begin working with the Browser platform, there are a few things you should know. First, you have to actually add the platform. That means running cordova platform add browser . And if you want the latest, then you need to specify cordova platform add [email protected] .

Can Cordova run in browser?

Apache Cordova applications leverage HTML, CSS and JavaScript to create mobile applications that run across multiple device platforms including Android, iOS, and Windows.


2 Answers

Test the following command:

cordova run browser --target=firefox

like image 142
Rodrigo Lourenço da Silva Avatar answered Sep 18 '22 19:09

Rodrigo Lourenço da Silva


The only way to change the default Chrome browser is using the --target option.

As you can see Chrome is the default browser for the run command.

Internally, the cordovaServe.launchBrowser function is called with cli arguments.

This function is defined in the cordova-serve/serve.js file and you can find its body in the cordova-serve/src/browser.js file where you can find the complete list of supported browsers for each platform:

var browsers = {
    'win32': {
        'ie': 'iexplore',
        'chrome': 'chrome --user-data-dir=%TEMP%\\' + dataDir,
        'safari': 'safari',
        'opera': 'opera',
        'firefox': 'firefox',
        'edge': 'microsoft-edge'
    },
    'darwin': {
        'chrome': '"Google Chrome" --args' + chromeArgs,
        'safari': 'safari',
        'firefox': 'firefox',
        'opera': 'opera'
    },
    'linux' : {
        'chrome': 'google-chrome' + chromeArgs ,
        'chromium': 'chromium-browser' + chromeArgs,
        'firefox': 'firefox',
        'opera': 'opera'
    }
};

I hope that this answer will help you to learn a bit more about cordova and the way it works.

like image 30
lifeisfoo Avatar answered Sep 17 '22 19:09

lifeisfoo