Skip to content

Instantly share code, notes, and snippets.

@devzarghami
Last active May 28, 2020 06:58
Show Gist options
  • Save devzarghami/3fb34264b9e4140ca04492273ac325cf to your computer and use it in GitHub Desktop.
Save devzarghami/3fb34264b9e4140ca04492273ac325cf to your computer and use it in GitHub Desktop.
all config in cordova config file

Cordova Config For Build App

  • change app icon
  • open installed app from external link
  • security config to send xhhtp request in android < 9

Open Installed App By External Link - DeepLink

<platform name="android">
	<config-file parent="./application/activity/[@android:name='MainActivity']" target="AndroidManifest.xml">
		<intent-filter>
			<action android:name="android.intent.action.VIEW" />
			<category android:name="android.intent.category.DEFAULT" />
			<category android:name="android.intent.category.BROWSABLE" />
			<data android:host="example.com" android:scheme="http" />
			<data android:host="m.example.com" android:scheme="http" />
		</intent-filter>
	</config-file>
</platform>

Network Security Config ( if send request to server not work)

config.xml file
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"
 xmlns:android="http://schemas.android.com/apk/res/android">


<platform name="android">
	<edit-config xmlns:android="http://schemas.android.com/apk/res/android" file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
		<application android:networkSecurityConfig="@xml/network_security_config" />
	</edit-config>
	<resource-file src="network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
</platform>
network_security_config.xml file
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true"/>
</network-security-config>

or set bellow code in your index.html file

<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'"/>

App Icon

Easily generate image assets for PhoneGap/Cordova projects from this link

https://pgicons.abiro.com/

 <platform name="android">
	<allow-intent href="market:*" />
	<preference name="android-minSdkVersion" value="21"/>
	<icon src="assets/icon/mdpi.png" density="mdpi" />
	<icon src="assets/icon/hdpi.png" density="hdpi" />
	<icon src="assets/icon/xhdpi.png" density="xhdpi" />
	<icon src="assets/icon/xxhdpi.png" density="xxhdpi" />
	<icon src="assets/icon/xxxhdpi.png" density="xxxhdpi" />
</platform>

App Splash Screen

Easily generate image assets for PhoneGap/Cordova projects from this link

https://pgicons.abiro.com/

first add plugin: cordova plugin add cordova-plugin-splashscreen

<platform name="android">
	 <splash src="assets/splash/splash-port-hdpi.png" density="port-hdpi"/>
	 <splash src="assets/splash/splash-port-ldpi.png" density="port-ldpi"/>
	 <splash src="assets/splash/splash-port-mdpi.png" density="port-mdpi"/>
	 <splash src="assets/splash/splash-port-xhdpi.png" density="port-xhdpi"/>
	<splash src="assets/splash/splash-port-xxhdpi.png" density="port-xxhdpi"/>
	<splash src="assets/splash/splash-port-xxxhdpi.png" density="port-xxxhdpi"/>
</platform>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment