Cordova (tools) - config XML explanation

Config. What is XML and what is its function

Config.xml is a global configuration file of cordova project It can control some global configurations of the whole project To facilitate the use of cordova CLI, config XML is put here, which is actually under the project root directory


It should be noted that before version 3.3.1-0.2.0, the file existed in APP / www / config XML, and it is still supported here. When using CLI to build a project, the file version is passively copied to different platform subdirectories.

Config. For a new project XML file

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="" xmlns:cdv="">
        A sample Apache Cordova application that responds to the deviceready event.
    <author email="" href="">
        Apache Cordova Team
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />


config. The root element of the XML document

Here are the widget properties




Required field, identification of the application


The field must be the version of the application. This version number corresponds to the actual version number of the project


Android version settings


Default language ID for iOS settings


bundleVersion version setting of ios version


bundleVersion version number setting of mac version


window - bundle settings


Package name of Windows package


Required field, direct default Just fine. Don't worry


Required field, direct default Just fine. Don't worry

In addition to attributes, the following tags can also be included to control the corresponding functions





Specify the name of the application. This name appears on the screen of the device. For example, the mobile phone screen will display this app called HelloCordova


Specify app description information (displayed on the app store)


Contact information (displayed on the app store)

email(string) - required, email: href(string) - required, author's home page


The start page of the application. The default value is index HTML

src(string) - required, page path


The * can be used to represent any specific domain name, and the * can also be defined as a white list.

origin(string) - required, url


It is used for top-level navigation jump and is applicable to WebView. For detailed usage, refer to Cordova plugin whitelist

href(string) - required, URL


It is used for application control and allows the system to be opened. If it is not filled in, it is open by default

href(string) - required, URL


For restoring versions

name(string) - the name of the platform to be recovered. spec(string) - the platform version to be recovered


Specify the details of which plug-ins are preparing to restore. When a plug-in is added using the -- save flag, this element is automatically added to the project's config xml.


Set the name / value properties of various option pairs. The name of each preference is case sensitive. Many preferences are unique and specific platforms, and for the detailed meaning of each representative, please refer to the official documents. Too many are not listed one by one

The following table lists all specific names


It is used to specify some plug-in parameters, such as what package to retrieve from the plug-in code, and determine whether the plug-in code is initialized during the initialization of web page view.


When using the CLI to build applications, it is sometimes necessary to specify platform specific preferences or other elements. Use the element to specify that it should only appear in a platform specific - config Configuration in XML file.


When some behaviors of cordova occur, call the custom script, such as < hook type = "after_plugin_install" SRC = "scripts / afterpluginstall. JS" / > after the plug-in installation is completed, execute afterpluginstall js

<preference name="DisallowOverscroll" value="true"/>
<preference name="Fullscreen" value="true" />
<preference name="BackgroundColor" value="0xff0000ff"/>
<preference name="HideKeyboardFormAccessoryBar" value="true"/>
<preference name="Orientation" value="landscape" />

<!-- iOS only preferences -->
<preference name="EnableViewportScale" value="true"/>
<preference name="MediaPlaybackAllowsAirPlay" value="false"/>
<preference name="MediaPlaybackRequiresUserAction" value="true"/>
<preference name="AllowInlineMediaPlayback" value="true"/>
<preference name="BackupWebStorage" value="local"/>
<preference name="TopActivityIndicator" value="white"/>
<preference name="SuppressesIncrementalRendering" value="true"/>
<preference name="GapBetweenPages" value="0"/>
<preference name="PageLength" value="0"/>
<preference name="PaginationBreakingMode" value="page"/>
<preference name="PaginationMode" value="unpaginated"/>
<preference name="UIWebViewDecelerationSpeed" value="fast" />
<preference name="ErrorUrl" value="myErrorPage.html"/>
<preference name="OverrideUserAgent" value="Mozilla/5.0 My Browser" />
<preference name="AppendUserAgent" value="My Browser" />
<preference name="target-device" value="universal" />
<preference name="deployment-target" value="7.0" />
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />
<preference name="SuppressesLongPressGesture" value="true" />
<preference name="Suppresses3DTouchGesture" value="true" />

<!-- Android only preferences -->
<preference name="KeepRunning" value="false"/>
<preference name="LoadUrlTimeoutValue" value="10000"/>
<preference name="InAppBrowserStorageEnabled" value="true"/>
<preference name="LoadingDialog" value="My Title,My Message"/>
<preference name="ErrorUrl" value="myErrorPage.html"/>
<preference name="ShowTitle" value="true"/>
<preference name="LogLevel" value="VERBOSE"/>
<preference name="AndroidLaunchMode" value="singleTop"/>
<preference name="DefaultVolumeStream" value="call" />
<preference name="OverrideUserAgent" value="Mozilla/5.0 My Browser" />
<preference name="AppendUserAgent" value="My Browser" />

<!-- Windows only preferences -->
<preference name="windows-phone-target-version" value="8.1" />
<preference name="windows-target-version" value="8.1" />
<preference name="Windows.Universal" value="10.0.10240.0" />
<preference name="WindowsDefaultUriPrefix" value="ms-appx://" />
<preference name="Windows.Mobile-MaxVersionTested" value="10.0.10031.0" />
<preference name="Windows.Universal-MinVersion" value="" />
<preference name="WindowsStoreIdentityName" value="Cordova.Example.ApplicationDataSample" />
<preference name="WindowsStorePublisherName" value="CN=Contoso Corp, O=Contoso Corp, L=Redmond, S=Washington, C=US" />
<preference name="WindowsToastCapable" value="true" />
<preference name="uap-target-min-version" value="10.0.10586.0" />

<!-- BlackBerry only preferences -->
<preference name="ChildBrowser" value="disable"/>
<preference name="PopupBlocker" value="enable"/>
<preference name="WebSecurity" value="disable"/>

<!-- OS X only preferences -->
<preference name="HideMousePointer" value="5"/>
<preference name="OSXLocalStoragePath" value="~/.myapp/database"/>
<preference name="WindowSize" value="800x400"/>
<preference name="EnableWebGL" value="true"/>

Added by keeps21 on Wed, 09 Mar 2022 02:56:39 +0200