A PhoneGap application demonstrating
Build this project for Android. This code does not work in web serve as it depends on WebIntents.
phonegap build android
Run the code for android to generate an APK.
phonegap run android
Created a new phonegap project for hello-world template
phonegap create my-app --template hello-world
Added a new plugin for WebIntent
phonegap plugin add https://github.com/cordova-misc/cordova-webintent.git
Copy the JS file from node_modules/cordova-webintent/www to your local www. This file needs to be referenced in your HTML
cp node_modules/cordova-webintent/www/webintent.js www/
Edit your index.html
...
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="webintent.js"></script>
...
The hello-world template is the default when you create a new application using the phonegap-cli.
phonegap create my-app
Create an app using this template specifically:
phonegap create my-app --template hello-world
To see a list of other available PhoneGap templates:
phonegap template list
Minimum SDK version supported on the target device. Maximum version is blank by default.
This template sets the minimum to 14.
<preference name="android-minSdkVersion" value="14" />
This template defaults to wide open access.
<access origin="*" />
It is strongly encouraged that you restrict access to external resources in your application before releasing to production.
For more information on whitelist configuration, see the Cordova Whitelist Guide and the Cordova Whitelist Plugin documentation
The default CSP is similarly open:
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
Much like the access tag above, you are strongly encouraged to use a more restrictive CSP in production.
A good starting point declaration might be:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: 'unsafe-inline' https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *" />
For more information on the Content Security Policy, see the section on CSP in the Cordova Whitelist Plugin documentation.
Another good resource for generating a good CSP declaration is CSP is Awesome