I'm currently building my first Phonegap/Cordova app and there are a few things that I cannot get to work. To save time I decided to use Adobe`s Build Service (Version 3.3.0 - also tried 3.5.0).
1. Camera I tried several ways but nothing seemed to work. I want the app to open the camera. This should launch it and save the result in a base64 code:
JS
function capturePhoto(){
navigator.camera.getPicture(uploadPhoto,null,{sourceType:1,quality:60});
}
function uploadPhoto(data){
// this is where you would send the image file to server
cameraPic.src = "data:image/jpeg;base64," + data;
// Successful upload to the server
navigator.notification.alert(
'Your Photo has been uploaded', // message
okay, // callback
'Photo Uploaded', // title
'OK' // buttonName
);
// upload has failed Fail
/*
if (failedToUpload){
navigator.notification.alert(
'Your Photo has failed to upload',
failedDismissed,
'Photo Not Uploaded',
'OK'
);
}
*/
}
function okay(){
// Do something
}
BUTTON
<a href="#" data-role="button" data-inline="true" onclick="capturePhoto();">Photo</a>
2. Offline
When the App discovers that the device is offline the user should get redirected. This is what I have:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("offline", onOffline, false);
function onOffline()
{
window.location = "noi.html";
}
}
I also tried to put the onOffline function outside the onDeviceReady () function...
I`m looking forward to get your help.
Thanks, Max