1

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

Dan Doyon
  • 6,710
  • 2
  • 31
  • 40
mczernin
  • 9
  • 1
  • 4

1 Answers1

0

@Don, this is pretty old. so I doubt you still have this problem, but others.

On #1, your did not use destinationType: Camera.DestinationType.DATA_URL, which should have been in your options. You used sourceType, which gets you the camera. The documentation is unclear on this. It implies that it will return a base64, but this is not so.

On #2, you need to use the plugin networkInformation, which you did not mention or use in the code posted. -- Jesse