My app is running into an issue where Chrome is giving me the error message that chrome.downloads is undefined.
In my attempt to download an image, here is a simple example provided...
Here is the manifest:
{
"manifest_version": 2,
"name": "Downloader",
"minimum_chrome_version": "38",
"permissions": ["downloads", "<all_urls>"],
"app": {
"background": {
"scripts": ["background.js"]
}
}
}
The HTML code snippet looks like this:
<body>
<button id="download">Download</button>
<script src="main.js"></script>
</body>
For background.js:
chrome.app.runtime.onLaunched.addListener(function(launchData) {
chrome.app.window.create(
'index.html',
{
id: 'mainWindow',
bounds: {width: 800, height: 600}
}
);
});
And for main.js:
window.onload = function() {
document.querySelector("#download").addEventListener("click",
function () {
chrome.downloads.download({
url: "http://upload.wikimedia.org/wikipedia/commons/6/6e/Moonbeam_UFO.JPG",
filename: "ufo.jpg"
});
}
);
};
I have searched for similar issues when developing extensions, but nothing specific to using it in an app. Can anyone provide guidance on how to resolve this?
Thank you