blob: bc6190a632417c2e67c1ded83a5663cdc8afdf9b [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<meta name="description" content="Take pictures with the device camera. ">
<title>
Camera - Apache Cordova
</title>
<link rel="SHORTCUT ICON" href="/favicon.ico"/>
<link rel="canonical" href="https://cordova.apache.org/docs/en/10.x/reference/cordova-plugin-camera/">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="/static/css/main.css">
<link rel="stylesheet" type="text/css" href="/static/css/lib/syntax.css">
<!-- Fonts -->
<!-- For attribution information, see www/attributions.html -->
<link href='https://fonts.googleapis.com/css?family=Raleway:700,400,300,700italic,400italic,300italic' rel='stylesheet' type='text/css'>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
var disqus_developer = 1; // this would set it to developer mode
</script>
<!-- JS -->
<script defer type="text/javascript" src="/static/js/lib/jquery-2.1.1.min.js"></script>
<script defer type="text/javascript" src="/static/js/lib/bootstrap.min.js"></script>
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '16']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body>
<header>
<a class="scroll-point pt-top" name="top"></a>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><img id="logo_top" src="/static/img/cordova-logo-newbrand.svg"/></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<div class="nav_bar_center">
<ul class="nav navbar-nav">
<li class="active">
<a href="/docs/en/latest/">Documentation</a>
</li>
<li >
<a href="/plugins">Plugins</a>
</li>
<li >
<a href="/blog" id="blog_button">Blog<span class="badge" id="new_blog_count"></span></a>
</li>
<li >
<a href="/contribute">Contribute</a>
</li>
<li >
<a href="/contribute/team.html">Team</a>
</li>
<li>
<a href="/#getstarted">Get Started</a>
</li>
<li>
<form class="navbar-form navbar-right" id="header-search-form" role="search">
<div class="input-group">
</div>
</form>
</li>
</ul>
</div>
</div><!--/.navbar-collapse -->
</div>
</nav>
<div id="_fixed_navbar_spacer" style="padding-top:50px"></div>
</header>
<div class="docs">
<!-- Table of Contents -->
<div class="hidden-xs hidden-sm site-toc-container">
<ul class="site-toc">
<li>
<span class="toc-section-heading">
Introduction
</span>
<ul class="site-toc">
<li>
<a class="" href="/docs/en/10.x/guide/overview/index.html">
Overview
</a>
</li>
</ul>
</li>
<li>
<span class="toc-section-heading">
Create apps
</span>
<ul class="site-toc">
<li>
<a class="" href="/docs/en/10.x/guide/cli/index.html">
Create your first app
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/cli/template.html">
Templates for apps
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/support/index.html">
Platform support
</a>
</li>
<li>
<span class="toc-section-heading">
Develop for platforms
</span>
<ul class="site-toc">
<li>
<a class="" href="/docs/en/10.x/guide/platforms/android/index.html">
Android
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/ios/index.html">
iOS
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/windows/index.html">
Windows
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/osx/index.html">
OS X
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/electron/index.html">
Electron
</a>
</li>
</ul>
</li>
<li>
<a class="" href="/docs/en/10.x/platform_plugin_versioning_ref/index.html">
Manage versions and platforms
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/platform_pinning/index.html">
Platform pinning
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/config_ref/images.html">
Customize icons
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/cordova/storage/storage.html">
Store data
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/appdev/privacy/index.html">
Manage privacy
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/appdev/security/index.html">
Manage security
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/appdev/allowlist/index.html">
Allow List
</a>
</li>
</ul>
</li>
<li>
<span class="toc-section-heading">
Create plugins
</span>
<ul class="site-toc">
<li>
<a class="" href="/docs/en/10.x/guide/hybrid/plugins/index.html">
Create a plugin
</a>
</li>
<li>
<span class="toc-section-heading">
Develop for platforms
</span>
<ul class="site-toc">
<li>
<a class="" href="/docs/en/10.x/guide/platforms/android/plugin.html">
Android
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/ios/plugin.html">
iOS
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/windows/plugin.html">
Windows
</a>
</li>
</ul>
</li>
<li>
<a class="" href="/docs/en/10.x/plugin_ref/plugman.html">
Use Plugman
</a>
</li>
</ul>
</li>
<li>
<span class="toc-section-heading">
Advanced Topics
</span>
<ul class="site-toc">
<li>
<a class="" href="/docs/en/10.x/guide/hybrid/webviews/index.html">
Embed Cordova in native apps
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/next/index.html">
Next Steps
</a>
</li>
</ul>
</li>
<li>
<span class="toc-section-heading">
Reference
</span>
<ul class="site-toc">
<li>
<a class="" href="/docs/en/10.x/config_ref/index.html">
Config.xml
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/cordova/events/events.html">
Events
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-cli/index.html">
CLI Reference
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/appdev/hooks/index.html">
Hooks
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/plugin_ref/spec.html">
Plugin.xml
</a>
</li>
<li>
<span class="toc-section-heading">
Plugin APIs
</span>
<ul class="site-toc">
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-battery-status/index.html">
Battery Status
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-camera/index.html">
Camera
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-device/index.html">
Device
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-dialogs/index.html">
Dialogs
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-file/index.html">
File
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-geolocation/index.html">
Geolocation
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-inappbrowser/index.html">
Inappbrowser
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-media/index.html">
Media
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-media-capture/index.html">
Media Capture
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-network-information/index.html">
Network Information
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-screen-orientation/index.html">
Screen Orientation
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-splashscreen/index.html">
Splashscreen
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-statusbar/index.html">
Statusbar
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-vibration/index.html">
Vibration
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<!-- Page content -->
<div class="page-content-container">
<div class="page-content">
<div class="content-header">
<!-- ToC Dropdown (for XS and SM sizes only) -->
<div class="toc-dropdown dropdown visible-xs-block visible-sm-block">
<button class="btn btn-default dropdown-toggle" type="button" id="tocDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Table of Contents
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a class="" href="/docs/en/10.x/guide/overview/index.html">
Overview
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/cli/index.html">
Create your first app
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/cli/template.html">
Templates for apps
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/support/index.html">
Platform support
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/android/index.html">
Android
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/ios/index.html">
iOS
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/windows/index.html">
Windows
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/osx/index.html">
OS X
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/electron/index.html">
Electron
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/platform_plugin_versioning_ref/index.html">
Manage versions and platforms
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/platform_pinning/index.html">
Platform pinning
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/config_ref/images.html">
Customize icons
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/cordova/storage/storage.html">
Store data
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/appdev/privacy/index.html">
Manage privacy
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/appdev/security/index.html">
Manage security
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/appdev/allowlist/index.html">
Allow List
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/hybrid/plugins/index.html">
Create a plugin
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/android/plugin.html">
Android
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/ios/plugin.html">
iOS
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/platforms/windows/plugin.html">
Windows
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/plugin_ref/plugman.html">
Use Plugman
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/hybrid/webviews/index.html">
Embed Cordova in native apps
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/next/index.html">
Next Steps
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/config_ref/index.html">
Config.xml
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/cordova/events/events.html">
Events
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-cli/index.html">
CLI Reference
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/guide/appdev/hooks/index.html">
Hooks
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/plugin_ref/spec.html">
Plugin.xml
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-battery-status/index.html">
Battery Status
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-camera/index.html">
Camera
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-device/index.html">
Device
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-dialogs/index.html">
Dialogs
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-file/index.html">
File
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-geolocation/index.html">
Geolocation
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-inappbrowser/index.html">
Inappbrowser
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-media/index.html">
Media
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-media-capture/index.html">
Media Capture
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-network-information/index.html">
Network Information
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-screen-orientation/index.html">
Screen Orientation
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-splashscreen/index.html">
Splashscreen
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-statusbar/index.html">
Statusbar
</a>
</li>
<li>
<a class="" href="/docs/en/10.x/reference/cordova-plugin-vibration/index.html">
Vibration
</a>
</li>
</ul>
</div>
<a class="edit hidden-xs hidden-sm" href="https://github.com/apache/cordova-plugin-camera/blob/master/README.md"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> </a>
<!-- Version dropdown -->
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="versionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
10.x
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="versionDropdown">
<!-- List versions available in this language -->
<li>
<a href="/docs/en/dev/" class="missing-page">
dev
</a>
</li>
<li>
<a href="/docs/en/latest/" class="missing-page">
12.x
(Latest)
</a>
</li>
<li>
<a href="/docs/en/11.x/" class="missing-page">
11.x
</a>
</li>
<li>
<a href="/docs/en/10.x/" class="missing-page">
<span class="selected">
10.x
</span>
</a>
</li>
<li>
<a href="/docs/en/9.x/" class="missing-page">
9.x
</a>
</li>
<li>
<a href="/docs/en/8.x/" class="missing-page">
8.x
</a>
</li>
<li>
<a href="/docs/en/7.x/" class="missing-page">
7.x
</a>
</li>
<li>
<a href="/docs/en/6.x/" class="missing-page">
6.x
</a>
</li>
<li>
<a href="/docs/en/5.4.0/" class="missing-page">
5.4.0
</a>
</li>
<li>
<a href="/docs/en/5.1.1/" class="missing-page">
5.1.1
</a>
</li>
<li>
<a href="/docs/en/5.0.0/" class="missing-page">
5.0.0
</a>
</li>
<li>
<a href="/docs/en/4.0.0/" class="missing-page">
4.0.0
</a>
</li>
<li>
<a href="/docs/en/3.6.0/" class="missing-page">
3.6.0
</a>
</li>
<li>
<a href="/docs/en/3.5.0/" class="missing-page">
3.5.0
</a>
</li>
<li>
<a href="/docs/en/3.4.0/" class="missing-page">
3.4.0
</a>
</li>
<li>
<a href="/docs/en/3.3.0/" class="missing-page">
3.3.0
</a>
</li>
<li>
<a href="/docs/en/3.2.0/" class="missing-page">
3.2.0
</a>
</li>
<li>
<a href="/docs/en/3.1.0/" class="missing-page">
3.1.0
</a>
</li>
<li>
<a href="/docs/en/3.0.0/" class="missing-page">
3.0.0
</a>
</li>
<li>
<a href="/docs/en/2.9.0/" class="missing-page">
2.9.0
</a>
</li>
<li>
<a href="/docs/en/2.8.0/" class="missing-page">
2.8.0
</a>
</li>
<li>
<a href="/docs/en/2.7.0/" class="missing-page">
2.7.0
</a>
</li>
<li>
<a href="/docs/en/2.6.0/" class="missing-page">
2.6.0
</a>
</li>
<li>
<a href="/docs/en/2.5.0/" class="missing-page">
2.5.0
</a>
</li>
<li>
<a href="/docs/en/2.4.0/" class="missing-page">
2.4.0
</a>
</li>
<li>
<a href="/docs/en/2.3.0/" class="missing-page">
2.3.0
</a>
</li>
<li>
<a href="/docs/en/2.2.0/" class="missing-page">
2.2.0
</a>
</li>
<li>
<a href="/docs/en/2.1.0/" class="missing-page">
2.1.0
</a>
</li>
<li>
<a href="/docs/en/2.0.0/" class="missing-page">
2.0.0
</a>
</li>
<li>
<a href="/docs/en/1.9.0/" class="missing-page">
1.9.0
</a>
</li>
<li>
<a href="/docs/en/1.8.1/" class="missing-page">
1.8.1
</a>
</li>
<li>
<a href="/docs/en/1.8.0/" class="missing-page">
1.8.0
</a>
</li>
<li>
<a href="/docs/en/1.7.0/" class="missing-page">
1.7.0
</a>
</li>
<li>
<a href="/docs/en/1.6.1/" class="missing-page">
1.6.1
</a>
</li>
<li>
<a href="/docs/en/1.6.0/" class="missing-page">
1.6.0
</a>
</li>
<li>
<a href="/docs/en/1.5.0/" class="missing-page">
1.5.0
</a>
</li>
</ul>
</div>
</div>
<!-- Show warnings for special versions -->
<!-- dev warning -->
<!-- outdated warning -->
<div class="alert docs-alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
This version of the documentation is outdated!
<a href="/docs/en/latest/">
Click here for the latest released version.
</a>
</div>
<!-- plugin version warning -->
<div class="alert alert-warning docs-alert" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
master.
<a href="https://github.com/apache/cordova-plugin-camera/releases">
</a>
</div>
<div id="page-toc-source">
<!-- WARNING: This file is generated. See fetch_docs.js. -->
<!---
# license: Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-->
<table>
<thead>
<tr>
<th style="text-align: center">AppVeyor</th>
<th style="text-align: center">Travis CI</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center"><a href="https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-camera"><img src="https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-camera?branch=master" alt="Build status" /></a></td>
<td style="text-align: center"><a href="https://travis-ci.org/apache/cordova-plugin-camera"><img src="https://travis-ci.org/apache/cordova-plugin-camera.svg?branch=master" alt="Build Status" /></a></td>
</tr>
</tbody>
</table>
<h1>cordova-plugin-camera</h1>
<p>This plugin defines a global <code>navigator.camera</code> object, which provides an API for taking pictures and for choosing images from
the system&#39;s image library.</p>
<p>Although the object is attached to the global scoped <code>navigator</code>, it is not available until after the <code>deviceready</code> event.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(navigator.camera);
}
</code></pre></div></div>
<h2>Installation</h2>
<p>This requires cordova 5.0+</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cordova plugin add cordova-plugin-camera Older versions of cordova can still install via the __deprecated__ id
cordova plugin add org.apache.cordova.camera It is also possible to install via repo url directly ( unstable )
cordova plugin add https://github.com/apache/cordova-plugin-camera.git
</code></pre></div></div>
<h2>How to Contribute</h2>
<p>Contributors are welcome! And we need your contributions to keep the project moving forward. You can[report bugs, improve the documentation, or <a href="https://github.com/apache/cordova-plugin-camera/pulls">contribute code</a>.</p>
<p>There is a specific <a href="http://wiki.apache.org/cordova/ContributorWorkflow">contributor workflow</a> we recommend. Start reading there. More information is available on <a href="http://wiki.apache.org/cordova">our wiki</a>.</p>
<p><strong>Have a solution?</strong> Send a <a href="https://github.com/apache/cordova-plugin-camera/pulls">Pull Request</a>.</p>
<p>In order for your changes to be accepted, you need to sign and submit an Apache <a href="http://www.apache.org/licenses/#clas">ICLA</a> (Individual Contributor License Agreement). Then your name will appear on the list of CLAs signed by <a href="https://people.apache.org/committer-index.html#unlistedclas">non-committers</a> or <a href="http://people.apache.org/committers-by-project.html#cordova">Cordova committers</a>.</p>
<p><strong>And don&#39;t forget to test and document your code.</strong></p>
<h3>iOS Quirks</h3>
<p>Since iOS 10 it&#39;s mandatory to provide an usage description in the <code>info.plist</code> if trying to access privacy-sensitive data. When the system prompts the user to allow access, this usage description string will displayed as part of the permission dialog box, but if you didn&#39;t provide the usage description, the app will crash before showing the dialog. Also, Apple will reject apps that access private data but don&#39;t provide an usage description.</p>
<p>This plugins requires the following usage descriptions:</p>
<ul>
<li><code>NSCameraUsageDescription</code> specifies the reason for your app to access the device&#39;s camera.</li>
<li><code>NSPhotoLibraryUsageDescription</code> specifies the reason for your app to access the user&#39;s photo library.</li>
<li><code>NSLocationWhenInUseUsageDescription</code> specifies the reason for your app to access the user&#39;s location information while your app is in use. (Set it if you have <code>CameraUsesGeolocation</code> preference set to <code>true</code>)</li>
<li><code>NSPhotoLibraryAddUsageDescription</code> specifies the reason for your app to get write-only access to the user&#39;s photo library</li>
</ul>
<p>To add these entries into the <code>info.plist</code>, you can use the <code>edit-config</code> tag in the <code>config.xml</code> like this:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge"&gt;
&lt;string&gt;need camera access to take pictures&lt;/string&gt;
&lt;/edit-config&gt;
</code></pre></div></div>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge"&gt;
&lt;string&gt;need photo library access to get pictures from there&lt;/string&gt;
&lt;/edit-config&gt;
</code></pre></div></div>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge"&gt;
&lt;string&gt;need location access to find things nearby&lt;/string&gt;
&lt;/edit-config&gt;
</code></pre></div></div>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;edit-config target="NSPhotoLibraryAddUsageDescription" file="*-Info.plist" mode="merge"&gt;
&lt;string&gt;need photo library access to save pictures there&lt;/string&gt;
&lt;/edit-config&gt;
</code></pre></div></div>
<hr />
<h1>API Reference <a name="reference"></a></h1>
<ul>
<li><a href="#module_camera">camera</a>
<ul>
<li><a href="#module_camera.getPicture">.getPicture(successCallback, errorCallback, options)</a></li>
<li><a href="#module_camera.cleanup">.cleanup()</a></li>
<li><a href="#module_camera.onError">.onError</a> : <code>function</code></li>
<li><a href="#module_camera.onSuccess">.onSuccess</a> : <code>function</code></li>
<li><a href="#module_camera.CameraOptions">.CameraOptions</a> : <code>Object</code></li>
</ul>
</li>
<li><a href="#module_Camera">Camera</a>
<ul>
<li><a href="#module_Camera.DestinationType">.DestinationType</a> : <code>enum</code></li>
<li><a href="#module_Camera.EncodingType">.EncodingType</a> : <code>enum</code></li>
<li><a href="#module_Camera.MediaType">.MediaType</a> : <code>enum</code></li>
<li><a href="#module_Camera.PictureSourceType">.PictureSourceType</a> : <code>enum</code></li>
<li><a href="#module_Camera.PopoverArrowDirection">.PopoverArrowDirection</a> : <code>enum</code></li>
<li><a href="#module_Camera.Direction">.Direction</a> : <code>enum</code></li>
</ul>
</li>
<li><a href="#module_CameraPopoverHandle">CameraPopoverHandle</a></li>
<li><a href="#module_CameraPopoverOptions">CameraPopoverOptions</a></li>
</ul>
<hr />
<p><a name="module_camera"></a></p>
<h2>camera</h2>
<p><a name="module_camera.getPicture"></a></p>
<h3>camera.getPicture(successCallback, errorCallback, options)</h3>
<p>Takes a photo using the camera, or retrieves a photo from the device&#39;s
image gallery. The image is passed to the success callback as a
Base64-encoded <code>String</code>, or as the URI for the image file.</p>
<p>The <code>camera.getPicture</code> function opens the device&#39;s default camera
application that allows users to snap pictures by default - this behavior occurs,
when <code>Camera.sourceType</code> equals <a href="#module_Camera.PictureSourceType"><code>Camera.PictureSourceType.CAMERA</code></a>.
Once the user snaps the photo, the camera application closes and the application is restored.</p>
<p>If <code>Camera.sourceType</code> is <code>Camera.PictureSourceType.PHOTOLIBRARY</code> or
<code>Camera.PictureSourceType.SAVEDPHOTOALBUM</code>, then a dialog displays
that allows users to select an existing image.</p>
<p>The return value is sent to the <a href="#module_camera.onSuccess"><code>cameraSuccess</code></a> callback function, in
one of the following formats, depending on the specified
<code>cameraOptions</code>:</p>
<ul>
<li>A <code>String</code> containing the Base64-encoded photo image.</li>
<li>A <code>String</code> representing the image file location on local storage (default).</li>
</ul>
<p>You can do whatever you want with the encoded image or URI, for
example:</p>
<ul>
<li>Render the image in an <code>&lt;img&gt;</code> tag, as in the example below</li>
<li>Save the data locally (<code>LocalStorage</code>, <a href="http://brianleroux.github.com/lawnchair/">Lawnchair</a>, etc.)</li>
<li>Post the data to a remote server</li>
</ul>
<p><strong>NOTE</strong>: Photo resolution on newer devices is quite good. Photos
selected from the device&#39;s gallery are not downscaled to a lower
quality, even if a <code>quality</code> parameter is specified. To avoid common
memory problems, set <code>Camera.destinationType</code> to <code>FILE_URI</code> rather
than <code>DATA_URL</code>.</p>
<p><strong>Supported Platforms</strong></p>
<ul>
<li>Android</li>
<li>Browser</li>
<li>iOS</li>
<li>Windows</li>
<li>OSX</li>
</ul>
<p>More examples <a href="#camera-getPicture-examples">here</a>. Quirks <a href="#camera-getPicture-quirks">here</a>.</p>
<p><strong>Kind</strong>: static method of <code>[camera](#module_camera)</code></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>successCallback</td>
<td><code>[onSuccess](#module_camera.onSuccess)</code></td>
<td>&#160;</td>
</tr>
<tr>
<td>errorCallback</td>
<td><code>[onError](#module_camera.onError)</code></td>
<td>&#160;</td>
</tr>
<tr>
<td>options</td>
<td><code>[CameraOptions](#module_camera.CameraOptions)</code></td>
<td>CameraOptions</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong></p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">navigator</span><span class="p">.</span><span class="nx">camera</span><span class="p">.</span><span class="nx">getPicture</span><span class="p">(</span><span class="nx">cameraSuccess</span><span class="p">,</span> <span class="nx">cameraError</span><span class="p">,</span> <span class="nx">cameraOptions</span><span class="p">);</span>
</code></pre></div></div>
<p><a name="module_camera.cleanup"></a></p>
<h3>camera.cleanup()</h3>
<p>Removes intermediate image files that are kept in temporary storage
after calling <a href="#module_camera.getPicture"><code>camera.getPicture</code></a>. Applies only when the value of
<code>Camera.sourceType</code> equals <code>Camera.PictureSourceType.CAMERA</code> and the
<code>Camera.destinationType</code> equals <code>Camera.DestinationType.FILE_URI</code>.</p>
<p><strong>Supported Platforms</strong></p>
<ul>
<li>iOS</li>
</ul>
<p><strong>Kind</strong>: static method of <code>[camera](#module_camera)</code><br />
<strong>Example</strong></p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">navigator</span><span class="p">.</span><span class="nx">camera</span><span class="p">.</span><span class="nx">cleanup</span><span class="p">(</span><span class="nx">onSuccess</span><span class="p">,</span> <span class="nx">onFail</span><span class="p">);</span>
<span class="kd">function</span> <span class="nx">onSuccess</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">"</span><span class="s2">Camera cleanup success.</span><span class="dl">"</span><span class="p">)</span>
<span class="p">}</span>
<span class="kd">function</span> <span class="nx">onFail</span><span class="p">(</span><span class="nx">message</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">alert</span><span class="p">(</span><span class="dl">'</span><span class="s1">Failed because: </span><span class="dl">'</span> <span class="o">+</span> <span class="nx">message</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>
<p><a name="module_camera.onError"></a></p>
<h3>camera.onError : <code>function</code></h3>
<p>Callback function that provides an error message.</p>
<p><strong>Kind</strong>: static typedef of <code>[camera](#module_camera)</code></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>message</td>
<td><code>string</code></td>
<td>The message is provided by the device&#39;s native code.</td>
</tr>
</tbody>
</table>
<p><a name="module_camera.onSuccess"></a></p>
<h3>camera.onSuccess : <code>function</code></h3>
<p>Callback function that provides the image data.</p>
<p><strong>Kind</strong>: static typedef of <code>[camera](#module_camera)</code></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>imageData</td>
<td><code>string</code></td>
<td>Base64 encoding of the image data, <em>or</em> the image file URI, depending on <a href="#module_camera.CameraOptions"><code>cameraOptions</code></a> in effect.</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong></p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// Show image</span>
<span class="c1">//</span>
<span class="kd">function</span> <span class="nx">cameraCallback</span><span class="p">(</span><span class="nx">imageData</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">image</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">myImage</span><span class="dl">'</span><span class="p">);</span>
<span class="nx">image</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="dl">"</span><span class="s2">data:image/jpeg;base64,</span><span class="dl">"</span> <span class="o">+</span> <span class="nx">imageData</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>
<p><a name="module_camera.CameraOptions"></a></p>
<h3>camera.CameraOptions : <code>Object</code></h3>
<p>Optional parameters to customize the camera settings.</p>
<ul>
<li><a href="#CameraOptions-quirks">Quirks</a></li>
</ul>
<p><strong>Kind</strong>: static typedef of <code>[camera](#module_camera)</code><br />
<strong>Properties</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>quality</td>
<td><code>number</code></td>
<td><code>50</code></td>
<td>Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera&#39;s resolution is unavailable.)</td>
</tr>
<tr>
<td>destinationType</td>
<td><code>[DestinationType](#module_Camera.DestinationType)</code></td>
<td><code>FILE_URI</code></td>
<td>Choose the format of the return value.</td>
</tr>
<tr>
<td>sourceType</td>
<td><code>[PictureSourceType](#module_Camera.PictureSourceType)</code></td>
<td><code>CAMERA</code></td>
<td>Set the source of the picture.</td>
</tr>
<tr>
<td>allowEdit</td>
<td><code>Boolean</code></td>
<td><code>false</code></td>
<td>Allow simple editing of image before selection.</td>
</tr>
<tr>
<td>encodingType</td>
<td><code>[EncodingType](#module_Camera.EncodingType)</code></td>
<td><code>JPEG</code></td>
<td>Choose the returned image file&#39;s encoding.</td>
</tr>
<tr>
<td>targetWidth</td>
<td><code>number</code></td>
<td>&#160;</td>
<td>Width in pixels to scale image. Must be used with <code>targetHeight</code>. Aspect ratio remains constant.</td>
</tr>
<tr>
<td>targetHeight</td>
<td><code>number</code></td>
<td>&#160;</td>
<td>Height in pixels to scale image. Must be used with <code>targetWidth</code>. Aspect ratio remains constant.</td>
</tr>
<tr>
<td>mediaType</td>
<td><code>[MediaType](#module_Camera.MediaType)</code></td>
<td><code>PICTURE</code></td>
<td>Set the type of media to select from. Only works when <code>PictureSourceType</code> is <code>PHOTOLIBRARY</code> or <code>SAVEDPHOTOALBUM</code>.</td>
</tr>
<tr>
<td>correctOrientation</td>
<td><code>Boolean</code></td>
<td>&#160;</td>
<td>Rotate the image to correct for the orientation of the device during capture.</td>
</tr>
<tr>
<td>saveToPhotoAlbum</td>
<td><code>Boolean</code></td>
<td>&#160;</td>
<td>Save the image to the photo album on the device after capture.</td>
</tr>
<tr>
<td>popoverOptions</td>
<td><code>[CameraPopoverOptions](#module_CameraPopoverOptions)</code></td>
<td>&#160;</td>
<td>iOS-only options that specify popover location in iPad.</td>
</tr>
<tr>
<td>cameraDirection</td>
<td><code>[Direction](#module_Camera.Direction)</code></td>
<td><code>BACK</code></td>
<td>Choose the camera to use (front- or back-facing).</td>
</tr>
</tbody>
</table>
<hr />
<p><a name="module_Camera"></a></p>
<h2>Camera</h2>
<p><a name="module_Camera.DestinationType"></a></p>
<h3>Camera.DestinationType : <code>enum</code></h3>
<p>Defines the output format of <code>Camera.getPicture</code> call.</p>
<p><strong>Kind</strong>: static enum property of <code>[Camera](#module_Camera)</code><br />
<strong>Properties</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>DATA_URL</td>
<td><code>number</code></td>
<td><code>0</code></td>
<td>Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI if possible</td>
</tr>
<tr>
<td>FILE_URI</td>
<td><code>number</code></td>
<td><code>1</code></td>
<td>Return file uri (content://media/external/images/media/2 for Android)</td>
</tr>
</tbody>
</table>
<p><a name="module_Camera.EncodingType"></a></p>
<h3>Camera.EncodingType : <code>enum</code></h3>
<p><strong>Kind</strong>: static enum property of <code>[Camera](#module_Camera)</code><br />
<strong>Properties</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>JPEG</td>
<td><code>number</code></td>
<td><code>0</code></td>
<td>Return JPEG encoded image</td>
</tr>
<tr>
<td>PNG</td>
<td><code>number</code></td>
<td><code>1</code></td>
<td>Return PNG encoded image</td>
</tr>
</tbody>
</table>
<p><a name="module_Camera.MediaType"></a></p>
<h3>Camera.MediaType : <code>enum</code></h3>
<p><strong>Kind</strong>: static enum property of <code>[Camera](#module_Camera)</code><br />
<strong>Properties</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>PICTURE</td>
<td><code>number</code></td>
<td><code>0</code></td>
<td>Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType</td>
</tr>
<tr>
<td>VIDEO</td>
<td><code>number</code></td>
<td><code>1</code></td>
<td>Allow selection of video only, ONLY RETURNS URL</td>
</tr>
<tr>
<td>ALLMEDIA</td>
<td><code>number</code></td>
<td><code>2</code></td>
<td>Allow selection from all media types</td>
</tr>
</tbody>
</table>
<p><a name="module_Camera.PictureSourceType"></a></p>
<h3>Camera.PictureSourceType : <code>enum</code></h3>
<p>Defines the output format of <code>Camera.getPicture</code> call.</p>
<p><strong>Kind</strong>: static enum property of <code>[Camera](#module_Camera)</code><br />
<strong>Properties</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>PHOTOLIBRARY</td>
<td><code>number</code></td>
<td><code>0</code></td>
<td>Choose image from the device&#39;s photo library (same as SAVEDPHOTOALBUM for Android)</td>
</tr>
<tr>
<td>CAMERA</td>
<td><code>number</code></td>
<td><code>1</code></td>
<td>Take picture from camera</td>
</tr>
<tr>
<td>SAVEDPHOTOALBUM</td>
<td><code>number</code></td>
<td><code>2</code></td>
<td>Choose image only from the device&#39;s Camera Roll album (same as PHOTOLIBRARY for Android)</td>
</tr>
</tbody>
</table>
<p><a name="module_Camera.PopoverArrowDirection"></a></p>
<h3>Camera.PopoverArrowDirection : <code>enum</code></h3>
<p>Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.</p>
<p><strong>Kind</strong>: static enum property of <code>[Camera](#module_Camera)</code><br />
<strong>Properties</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>ARROW_UP</td>
<td><code>number</code></td>
<td><code>1</code></td>
</tr>
<tr>
<td>ARROW_DOWN</td>
<td><code>number</code></td>
<td><code>2</code></td>
</tr>
<tr>
<td>ARROW_LEFT</td>
<td><code>number</code></td>
<td><code>4</code></td>
</tr>
<tr>
<td>ARROW_RIGHT</td>
<td><code>number</code></td>
<td><code>8</code></td>
</tr>
<tr>
<td>ARROW_ANY</td>
<td><code>number</code></td>
<td><code>15</code></td>
</tr>
</tbody>
</table>
<p><a name="module_Camera.Direction"></a></p>
<h3>Camera.Direction : <code>enum</code></h3>
<p><strong>Kind</strong>: static enum property of <code>[Camera](#module_Camera)</code><br />
<strong>Properties</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>BACK</td>
<td><code>number</code></td>
<td><code>0</code></td>
<td>Use the back-facing camera</td>
</tr>
<tr>
<td>FRONT</td>
<td><code>number</code></td>
<td><code>1</code></td>
<td>Use the front-facing camera</td>
</tr>
</tbody>
</table>
<hr />
<p><a name="module_CameraPopoverOptions"></a></p>
<h2>CameraPopoverOptions</h2>
<p>iOS-only parameters that specify the anchor element location and arrow
direction of the popover when selecting images from an iPad&#39;s library
or album.
Note that the size of the popover may change to adjust to the
direction of the arrow and orientation of the screen. Make sure to
account for orientation changes when specifying the anchor element
location.</p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>[x]</td>
<td><code>Number</code></td>
<td><code>0</code></td>
<td>x pixel coordinate of screen element onto which to anchor the popover.</td>
</tr>
<tr>
<td>[y]</td>
<td><code>Number</code></td>
<td><code>32</code></td>
<td>y pixel coordinate of screen element onto which to anchor the popover.</td>
</tr>
<tr>
<td>[width]</td>
<td><code>Number</code></td>
<td><code>320</code></td>
<td>width, in pixels, of the screen element onto which to anchor the popover.</td>
</tr>
<tr>
<td>[height]</td>
<td><code>Number</code></td>
<td><code>480</code></td>
<td>height, in pixels, of the screen element onto which to anchor the popover.</td>
</tr>
<tr>
<td>[arrowDir]</td>
<td><code>[PopoverArrowDirection](#module_Camera.PopoverArrowDirection)</code></td>
<td><code>ARROW_ANY</code></td>
<td>Direction the arrow on the popover should point.</td>
</tr>
<tr>
<td>[popoverWidth]</td>
<td><code>Number</code></td>
<td><code>0</code></td>
<td>width of the popover (0 or not specified will use apple&#39;s default width).</td>
</tr>
<tr>
<td>[popoverHeight]</td>
<td><code>Number</code></td>
<td><code>0</code></td>
<td>height of the popover (0 or not specified will use apple&#39;s default height).</td>
</tr>
</tbody>
</table>
<hr />
<p><a name="module_CameraPopoverHandle"></a></p>
<h2>CameraPopoverHandle</h2>
<p>A handle to an image picker popover.</p>
<p><strong>Supported Platforms</strong></p>
<ul>
<li>iOS</li>
</ul>
<p><strong>Example</strong></p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">navigator</span><span class="p">.</span><span class="nx">camera</span><span class="p">.</span><span class="nx">getPicture</span><span class="p">(</span><span class="nx">onSuccess</span><span class="p">,</span> <span class="nx">onFail</span><span class="p">,</span>
<span class="p">{</span>
<span class="na">destinationType</span><span class="p">:</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">DestinationType</span><span class="p">.</span><span class="nx">FILE_URI</span><span class="p">,</span>
<span class="na">sourceType</span><span class="p">:</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">PictureSourceType</span><span class="p">.</span><span class="nx">PHOTOLIBRARY</span><span class="p">,</span>
<span class="na">popoverOptions</span><span class="p">:</span> <span class="k">new</span> <span class="nx">CameraPopoverOptions</span><span class="p">(</span><span class="mi">300</span><span class="p">,</span> <span class="mi">300</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">PopoverArrowDirection</span><span class="p">.</span><span class="nx">ARROW_ANY</span><span class="p">,</span> <span class="mi">300</span><span class="p">,</span> <span class="mi">600</span><span class="p">)</span>
<span class="p">});</span>
<span class="c1">// Reposition the popover if the orientation changes.</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">onorientationchange</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">cameraPopoverHandle</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CameraPopoverHandle</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">cameraPopoverOptions</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">CameraPopoverOptions</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">PopoverArrowDirection</span><span class="p">.</span><span class="nx">ARROW_ANY</span><span class="p">,</span> <span class="mi">400</span><span class="p">,</span> <span class="mi">500</span><span class="p">);</span>
<span class="nx">cameraPopoverHandle</span><span class="p">.</span><span class="nx">setPosition</span><span class="p">(</span><span class="nx">cameraPopoverOptions</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>
<hr />
<h2><code>camera.getPicture</code> Errata</h2>
<h4>Example <a name="camera-getPicture-examples"></a></h4>
<p>Take a photo and retrieve the image&#39;s file location:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.FILE_URI });
function onSuccess(imageURI) {
var image = document.getElementById('myImage');
image.src = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}
</code></pre></div></div>
<p>Take a photo and retrieve it as a Base64-encoded image:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/**
* Warning: Using DATA_URL is not recommended! The DATA_URL destination
* type is very memory intensive, even with a low quality setting. Using it
* can result in out of memory errors and application crashes. Use FILE_URI
* instead.
*/
navigator.camera.getPicture(onSuccess, onFail, { quality: 25,
destinationType: Camera.DestinationType.DATA_URL
});
function onSuccess(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
</code></pre></div></div>
<h4>Preferences (iOS)</h4>
<ul>
<li>
<p><strong>CameraUsesGeolocation</strong> (boolean, defaults to false). For capturing JPEGs, set to true to get geolocation data in the EXIF header. This will trigger a request for geolocation permissions if set to true.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> &lt;preference name="CameraUsesGeolocation" value="false" /&gt;
</code></pre></div> </div>
</li>
</ul>
<h4>Android Quirks</h4>
<p>Android uses intents to launch the camera activity on the device to capture
images, and on phones with low memory, the Cordova activity may be killed. In this
scenario, the result from the plugin call will be delivered via the resume event.
See <a href="http://cordova.apache.org/docs/en/dev/guide/platforms/android/lifecycle.html">the Android Lifecycle guide</a>
for more information. The <code>pendingResult.result</code> value will contain the value that
would be passed to the callbacks (either the URI/URL or an error message). Check
the <code>pendingResult.pluginStatus</code> to determine whether or not the call was
successful.</p>
<h4>Browser Quirks</h4>
<p>Can only return photos as Base64-encoded image.</p>
<h4>iOS Quirks</h4>
<p>Including a JavaScript <code>alert()</code> in either of the callback functions
can cause problems. Wrap the alert within a <code>setTimeout()</code> to allow
the iOS image picker or popover to fully close before the alert
displays:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>setTimeout(function() {
// do your thing here!
}, 0);
</code></pre></div></div>
<h4>Windows quirks</h4>
<p>On Windows Phone 8.1 using <code>SAVEDPHOTOALBUM</code> or <code>PHOTOLIBRARY</code> as a source type causes application to suspend until file picker returns the selected image and
then restore with start page as defined in app&#39;s <code>config.xml</code>. In case when <code>camera.getPicture</code> was called from different page, this will lead to reloading
start page from scratch and success and error callbacks will never be called.</p>
<p>To avoid this we suggest using SPA pattern or call <code>camera.getPicture</code> only from your app&#39;s start page.</p>
<p>More information about Windows Phone 8.1 picker APIs is here: <a href="https://msdn.microsoft.com/en-us/library/windows/apps/dn720490.aspx">How to continue your Windows Phone app after calling a file picker</a></p>
<h2><code>CameraOptions</code> Errata <a name="CameraOptions-quirks"></a></h2>
<h4>Android Quirks</h4>
<ul>
<li>
<p>Any <code>cameraDirection</code> value results in a back-facing photo. (= You can only use the back camera)</p>
</li>
<li>
<p><strong><code>allowEdit</code> is unpredictable on Android and it should not be used!</strong> The Android implementation of this plugin tries to find and use an application on the user&#39;s device to do image cropping. The plugin has no control over what application the user selects to perform the image cropping and it is very possible that the user could choose an incompatible option and cause the plugin to fail. This sometimes works because most devices come with an application that handles cropping in a way that is compatible with this plugin (Google Photos), but it is unwise to rely on that being the case. If image editing is essential to your application, consider seeking a third party library or plugin that provides its own image editing utility for a more robust solution.</p>
</li>
<li>
<p><code>Camera.PictureSourceType.PHOTOLIBRARY</code> and <code>Camera.PictureSourceType.SAVEDPHOTOALBUM</code> both display the same photo album.</p>
</li>
<li>
<p>Ignores the <code>encodingType</code> parameter if the image is unedited (i.e. <code>quality</code> is 100, <code>correctOrientation</code> is false, and no <code>targetHeight</code> or <code>targetWidth</code> are specified). The <code>CAMERA</code> source will always return the JPEG file given by the native camera and the <code>PHOTOLIBRARY</code> and <code>SAVEDPHOTOALBUM</code> sources will return the selected file in its existing encoding.</p>
</li>
</ul>
<h4>iOS Quirks</h4>
<ul>
<li>When using <code>destinationType.FILE_URI</code>, photos are saved in the application&#39;s temporary directory. The contents of the application&#39;s temporary directory is deleted when the application ends.</li>
</ul>
<h2>Sample: Take Pictures, Select Pictures from the Picture Library, and Get Thumbnails <a name="sample"></a></h2>
<p>The Camera plugin allows you to do things like open the device&#39;s Camera app and take a picture, or open the file picker and select one. The code snippets in this section demonstrate different tasks including:</p>
<ul>
<li>Open the Camera app and <a href="#takePicture">take a Picture</a></li>
<li>Take a picture and <a href="#getThumbnails">return thumbnails</a> (resized picture)</li>
<li>Take a picture and <a href="#convert">generate a FileEntry object</a></li>
<li><a href="#selectFile">Select a file</a> from the picture library</li>
<li>Select a JPEG image and <a href="#getFileThumbnails">return thumbnails</a> (resized image)</li>
<li>Select an image and <a href="#convert">generate a FileEntry object</a></li>
</ul>
<h2>Take a Picture <a name="takePicture"></a></h2>
<p>Before you can take a picture, you need to set some Camera plugin options to pass into the Camera plugin&#39;s <code>getPicture</code> function. Here is a common set of recommendations. In this example, you create the object that you will use for the Camera options, and set the <code>sourceType</code> dynamically to support both the Camera app and the file picker.</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nx">setOptions</span><span class="p">(</span><span class="nx">srcType</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="p">{</span>
<span class="c1">// Some common settings are 20, 50, and 100</span>
<span class="na">quality</span><span class="p">:</span> <span class="mi">50</span><span class="p">,</span>
<span class="na">destinationType</span><span class="p">:</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">DestinationType</span><span class="p">.</span><span class="nx">FILE_URI</span><span class="p">,</span>
<span class="c1">// In this app, dynamically set the picture source, Camera or photo gallery</span>
<span class="na">sourceType</span><span class="p">:</span> <span class="nx">srcType</span><span class="p">,</span>
<span class="na">encodingType</span><span class="p">:</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">EncodingType</span><span class="p">.</span><span class="nx">JPEG</span><span class="p">,</span>
<span class="na">mediaType</span><span class="p">:</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">MediaType</span><span class="p">.</span><span class="nx">PICTURE</span><span class="p">,</span>
<span class="na">allowEdit</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="na">correctOrientation</span><span class="p">:</span> <span class="kc">true</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">options</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>
<p>Typically, you want to use a FILE_URI instead of a DATA_URL to avoid most memory issues. JPEG is the recommended encoding type for Android.</p>
<p>You take a picture by passing in the options object to <code>getPicture</code>, which takes a CameraOptions object as the third argument. When you call <code>setOptions</code>, pass <code>Camera.PictureSourceType.CAMERA</code> as the picture source.</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nx">openCamera</span><span class="p">(</span><span class="nx">selection</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">srcType</span> <span class="o">=</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">PictureSourceType</span><span class="p">.</span><span class="nx">CAMERA</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="nx">setOptions</span><span class="p">(</span><span class="nx">srcType</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">func</span> <span class="o">=</span> <span class="nx">createNewFileEntry</span><span class="p">;</span>
<span class="nb">navigator</span><span class="p">.</span><span class="nx">camera</span><span class="p">.</span><span class="nx">getPicture</span><span class="p">(</span><span class="kd">function</span> <span class="nx">cameraSuccess</span><span class="p">(</span><span class="nx">imageUri</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">displayImage</span><span class="p">(</span><span class="nx">imageUri</span><span class="p">);</span>
<span class="c1">// You may choose to copy the picture, save it somewhere, or upload.</span>
<span class="nx">func</span><span class="p">(</span><span class="nx">imageUri</span><span class="p">);</span>
<span class="p">},</span> <span class="kd">function</span> <span class="nx">cameraError</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">debug</span><span class="p">(</span><span class="dl">"</span><span class="s2">Unable to obtain picture: </span><span class="dl">"</span> <span class="o">+</span> <span class="nx">error</span><span class="p">,</span> <span class="dl">"</span><span class="s2">app</span><span class="dl">"</span><span class="p">);</span>
<span class="p">},</span> <span class="nx">options</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>
<p>Once you take the picture, you can display it or do something else. In this example, call the app&#39;s <code>displayImage</code> function from the preceding code.</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nx">displayImage</span><span class="p">(</span><span class="nx">imgUri</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">elem</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">imageFile</span><span class="dl">'</span><span class="p">);</span>
<span class="nx">elem</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="nx">imgUri</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>
<p>To display the image on some platforms, you might need to include the main part of the URI in the Content-Security-Policy <code>&lt;meta&gt;</code> element in index.html. For example, on Windows 10, you can include <code>ms-appdata:</code> in your <code>&lt;meta&gt;</code> element. Here is an example.</p>
<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">"Content-Security-Policy"</span> <span class="na">content=</span><span class="s">"default-src 'self' data: gap: ms-appdata: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"</span><span class="nt">&gt;</span>
</code></pre></div></div>
<h2>Take a Picture and Return Thumbnails (Resize the Picture) <a name="getThumbnails"></a></h2>
<p>To get smaller images, you can return a resized image by passing both <code>targetHeight</code> and <code>targetWidth</code> values with your CameraOptions object. In this example, you resize the returned image to fit in a 100px by 100px box (the aspect ratio is maintained, so 100px is either the height or width, whichever is greater in the source).</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nx">openCamera</span><span class="p">(</span><span class="nx">selection</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">srcType</span> <span class="o">=</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">PictureSourceType</span><span class="p">.</span><span class="nx">CAMERA</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="nx">setOptions</span><span class="p">(</span><span class="nx">srcType</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">func</span> <span class="o">=</span> <span class="nx">createNewFileEntry</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">selection</span> <span class="o">==</span> <span class="dl">"</span><span class="s2">camera-thmb</span><span class="dl">"</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">options</span><span class="p">.</span><span class="nx">targetHeight</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span>
<span class="nx">options</span><span class="p">.</span><span class="nx">targetWidth</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span>
<span class="p">}</span>
<span class="nb">navigator</span><span class="p">.</span><span class="nx">camera</span><span class="p">.</span><span class="nx">getPicture</span><span class="p">(</span><span class="kd">function</span> <span class="nx">cameraSuccess</span><span class="p">(</span><span class="nx">imageUri</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Do something</span>
<span class="p">},</span> <span class="kd">function</span> <span class="nx">cameraError</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">debug</span><span class="p">(</span><span class="dl">"</span><span class="s2">Unable to obtain picture: </span><span class="dl">"</span> <span class="o">+</span> <span class="nx">error</span><span class="p">,</span> <span class="dl">"</span><span class="s2">app</span><span class="dl">"</span><span class="p">);</span>
<span class="p">},</span> <span class="nx">options</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>
<h2>Select a File from the Picture Library <a name="selectFile"></a></h2>
<p>When selecting a file using the file picker, you also need to set the CameraOptions object. In this example, set the <code>sourceType</code> to <code>Camera.PictureSourceType.SAVEDPHOTOALBUM</code>. To open the file picker, call <code>getPicture</code> just as you did in the previous example, passing in the success and error callbacks along with CameraOptions object.</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nx">openFilePicker</span><span class="p">(</span><span class="nx">selection</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">srcType</span> <span class="o">=</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">PictureSourceType</span><span class="p">.</span><span class="nx">SAVEDPHOTOALBUM</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="nx">setOptions</span><span class="p">(</span><span class="nx">srcType</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">func</span> <span class="o">=</span> <span class="nx">createNewFileEntry</span><span class="p">;</span>
<span class="nb">navigator</span><span class="p">.</span><span class="nx">camera</span><span class="p">.</span><span class="nx">getPicture</span><span class="p">(</span><span class="kd">function</span> <span class="nx">cameraSuccess</span><span class="p">(</span><span class="nx">imageUri</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Do something</span>
<span class="p">},</span> <span class="kd">function</span> <span class="nx">cameraError</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">debug</span><span class="p">(</span><span class="dl">"</span><span class="s2">Unable to obtain picture: </span><span class="dl">"</span> <span class="o">+</span> <span class="nx">error</span><span class="p">,</span> <span class="dl">"</span><span class="s2">app</span><span class="dl">"</span><span class="p">);</span>
<span class="p">},</span> <span class="nx">options</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>
<h2>Select an Image and Return Thumbnails (resized images) <a name="getFileThumbnails"></a></h2>
<p>Resizing a file selected with the file picker works just like resizing using the Camera app; set the <code>targetHeight</code> and <code>targetWidth</code> options.</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nx">openFilePicker</span><span class="p">(</span><span class="nx">selection</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">srcType</span> <span class="o">=</span> <span class="nx">Camera</span><span class="p">.</span><span class="nx">PictureSourceType</span><span class="p">.</span><span class="nx">SAVEDPHOTOALBUM</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="nx">setOptions</span><span class="p">(</span><span class="nx">srcType</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">func</span> <span class="o">=</span> <span class="nx">createNewFileEntry</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">selection</span> <span class="o">==</span> <span class="dl">"</span><span class="s2">picker-thmb</span><span class="dl">"</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// To downscale a selected image,</span>
<span class="c1">// Camera.EncodingType (e.g., JPEG) must match the selected image type.</span>
<span class="nx">options</span><span class="p">.</span><span class="nx">targetHeight</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span>
<span class="nx">options</span><span class="p">.</span><span class="nx">targetWidth</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span>
<span class="p">}</span>
<span class="nb">navigator</span><span class="p">.</span><span class="nx">camera</span><span class="p">.</span><span class="nx">getPicture</span><span class="p">(</span><span class="kd">function</span> <span class="nx">cameraSuccess</span><span class="p">(</span><span class="nx">imageUri</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Do something with image</span>
<span class="p">},</span> <span class="kd">function</span> <span class="nx">cameraError</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">debug</span><span class="p">(</span><span class="dl">"</span><span class="s2">Unable to obtain picture: </span><span class="dl">"</span> <span class="o">+</span> <span class="nx">error</span><span class="p">,</span> <span class="dl">"</span><span class="s2">app</span><span class="dl">"</span><span class="p">);</span>
<span class="p">},</span> <span class="nx">options</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>
<h2>Take a picture and get a FileEntry Object <a name="convert"></a></h2>
<p>If you want to do something like copy the image to another location, or upload it somewhere using the FileTransfer plugin, you need to get a FileEntry object for the returned picture. To do that, call <code>window.resolveLocalFileSystemURL</code> on the file URI returned by the Camera app. If you need to use a FileEntry object, set the <code>destinationType</code> to <code>Camera.DestinationType.FILE_URI</code> in your CameraOptions object (this is also the default value).</p>
<blockquote>
<p><em>Note</em> You need the <a href="https://www.npmjs.com/package/cordova-plugin-file">File plugin</a> to call <code>window.resolveLocalFileSystemURL</code>.</p>
</blockquote>
<p>Here is the call to <code>window.resolveLocalFileSystemURL</code>. The image URI is passed to this function from the success callback of <code>getPicture</code>. The success handler of <code>resolveLocalFileSystemURL</code> receives the FileEntry object.</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nx">getFileEntry</span><span class="p">(</span><span class="nx">imgUri</span><span class="p">)</span> <span class="p">{</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">resolveLocalFileSystemURL</span><span class="p">(</span><span class="nx">imgUri</span><span class="p">,</span> <span class="kd">function</span> <span class="nx">success</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Do something with the FileEntry object, like write to it, upload it, etc.</span>
<span class="c1">// writeFile(fileEntry, imgUri);</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">"</span><span class="s2">got file: </span><span class="dl">"</span> <span class="o">+</span> <span class="nx">fileEntry</span><span class="p">.</span><span class="nx">fullPath</span><span class="p">);</span>
<span class="c1">// displayFileData(fileEntry.nativeURL, "Native URL");</span>
<span class="p">},</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="c1">// If don't get the FileEntry (which may happen when testing</span>
<span class="c1">// on some emulators), copy to a new FileEntry.</span>
<span class="nx">createNewFileEntry</span><span class="p">(</span><span class="nx">imgUri</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">}</span>
</code></pre></div></div>
<p>In the example shown in the preceding code, you call the app&#39;s <code>createNewFileEntry</code> function if you don&#39;t get a valid FileEntry object. The image URI returned from the Camera app should result in a valid FileEntry, but platform behavior on some emulators may be different for files returned from the file picker.</p>
<blockquote>
<p><em>Note</em> To see an example of writing to a FileEntry, see the <a href="https://www.npmjs.com/package/cordova-plugin-file">File plugin README</a>.</p>
</blockquote>
<p>The code shown here creates a file in your app&#39;s cache (in sandboxed storage) named <code>tempFile.jpeg</code>. With the new FileEntry object, you can copy the image to the file or do something else like upload it.</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nx">createNewFileEntry</span><span class="p">(</span><span class="nx">imgUri</span><span class="p">)</span> <span class="p">{</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">resolveLocalFileSystemURL</span><span class="p">(</span><span class="nx">cordova</span><span class="p">.</span><span class="nx">file</span><span class="p">.</span><span class="nx">cacheDirectory</span><span class="p">,</span> <span class="kd">function</span> <span class="nx">success</span><span class="p">(</span><span class="nx">dirEntry</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// JPEG file</span>
<span class="nx">dirEntry</span><span class="p">.</span><span class="nx">getFile</span><span class="p">(</span><span class="dl">"</span><span class="s2">tempFile.jpeg</span><span class="dl">"</span><span class="p">,</span> <span class="p">{</span> <span class="na">create</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> <span class="na">exclusive</span><span class="p">:</span> <span class="kc">false</span> <span class="p">},</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">fileEntry</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Do something with it, like write to it, upload it, etc.</span>
<span class="c1">// writeFile(fileEntry, imgUri);</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">"</span><span class="s2">got file: </span><span class="dl">"</span> <span class="o">+</span> <span class="nx">fileEntry</span><span class="p">.</span><span class="nx">fullPath</span><span class="p">);</span>
<span class="c1">// displayFileData(fileEntry.fullPath, "File copied to");</span>
<span class="p">},</span> <span class="nx">onErrorCreateFile</span><span class="p">);</span>
<span class="p">},</span> <span class="nx">onErrorResolveUrl</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>
</div>
</div>
<div class="row">
<div class="blue-divider"></div>
<footer>
<div class="container-fluid">
<div class="row">
<div class="col-sm-9">
<h1>More Resources</h1>
<div class="row">
<div class="col-sm-4">
<h2>General</h2>
<ul class="nav">
<li>
<a target="_blank" href="https://projects.apache.org/project.html?cordova">Apache Project Page</a>
</li>
<li>
<a href="https://www.apache.org/dyn/closer.cgi/cordova">Source Distribution</a>
</li>
<li>
<a target="_blank" href="https://www.apache.org/licenses">License</a>
</li>
<li>
<a href="/artwork">Artwork</a>
</li>
</ul>
</div>
<div class="col-sm-4">
<h2>Development</h2>
<ul class="nav">
<li><a target="_blank" href="https://github.com/apache?utf8=%E2%9C%93&amp;q=cordova-">Source Code</a></li>
<li><a target="_blank" href="https://github.com/apache/cordova#filing-a-bug">Issue Tracker</a></li>
<li><a target="_blank" href="https://stackoverflow.com/questions/tagged/cordova">Stack Overflow</a></li>
<li><a href="/contact">Mailing List</a></li>
<li><a href="/contribute/nightly_builds.html">Nightly builds</a></li>
</ul>
</div>
<div class="col-sm-4">
<h2>Apache Software Foundation</h2>
<ul class="nav">
<li>
<a target="_blank" href="https://www.apache.org/">About ASF</a>
</li>
<li>
<a target="_blank" href="https://www.apache.org/events/current-event">Events</a>
</li>
<li>
<a target="_blank" href="https://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a>
</li>
<li>
<a target="_blank" href="https://www.apache.org/foundation/thanks.html">Thanks</a>
</li>
<li>
<a target="_blank" href="https://www.apache.org/security/">Security</a>
</li>
<li>
<a target="_blank" href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy policy</a>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-3">
<h1>Contribute</h1>
<p style="padding-top:20px"><strong>Help Cordova move forward!</strong></p>
<p>Report bugs, improve the docs, or contribute to the code.</p>
<a href="/contribute" class="btn btn-lg btn-primary">
Learn More
</a>
<p style="padding-top:20px"> <a href="https://twitter.com/apachecordova" class="twitter-follow-button" data-show-count="false">Follow @apachecordova</a></p>
</div>
</div>
<p class="copyright_text">
Copyright &copy; 2024 <a href="https://apache.org">The Apache Software Foundation</a>, Licensed under the <a target="_blank" href="https://www.apache.org/licenses/">Apache License, Version 2.0</a>.<br/>
Apache and the Apache feather logos are <a target="_blank" href="https://www.apache.org/foundation/marks/list/">trademarks</a> of The Apache Software Foundation.
<br/>
<p>See the <a href="/attributions/">attributions page</a> for other copyright & trademark notices.</p>
</p>
</div>
</footer>
</div>
</div>
</div>
<script defer type="text/javascript" src="/static/js/lib/toc.min.js"></script>
<script defer type="text/javascript" src="/static/js/docs.js"></script>
<script defer type="text/javascript" src="/static/js/index.js"></script>
<script defer type="text/javascript" src="/static/js/twitter.js"></script>
</body>
</html>