remoorejr / cordova-plugin-camera-with-exif

Cordova Camera Plugin that will return an image as well as the EXIF data (including GPS location) on iOS and Android devices.
Apache License 2.0
38 stars 53 forks source link

How do we install this in an ionic 3 app? #34

Closed v-ken closed 6 years ago

v-ken commented 6 years ago

Since there isn't an @ionic-native/camera-with-exif version of this, how do we install this in an ionic 3 app?

remoorejr commented 6 years ago

Unknown, I don't use Ionic. Anyone ?

v-ken commented 6 years ago

I found out how to do it:

  1. Remove cordova-plugin-camera if it was previously installed
$ npm uninstall --save @ionic-native/camera
$ ionic cordova plugin remove cordova-plugin-camera
  1. Ensure that both cordova-plugin-camera and @ionic-native/camera are removed from package.json.

  2. Remove any references to the old Camera object from all your source files.

  3. Install the cordova-plugin-camera-with-exif plugin

    $ cordova plugin add cordova-plugin-camera-with-exif
  4. Use it as follow:

    
    // Declare the navigator instance
    // The plugin will be injected into this instance
    declare var navigator: any;

// Using the camera const cameraOptions = { quality: 40, destinationType: destinationType, encodingType: navigator.camera.EncodingType.JPEG, mediaType: mediaType, sourceType: sourceType, correctOrientation: true }

launchCamera() { function onSuccess(result) { // convert JSON string to JSON Object var thisResult = JSON.parse(result);

   // convert json_metadata JSON string to JSON Object
   var metadata = JSON.parse(thisResult.json_metadata);
}

function onFail(message) {
    alert('Failed because: ' + message);
}

navigator.camera.getPicture(onSuccess, onFail, cameraOptions);

}


6. Remove and re-add platforms

$ ionic cordova platform remove ios $ ionic cordova platform add ios

7. Build target

$ ionic cordova build ios

remoorejr commented 6 years ago

Thanks!