Last Photo Taken

PhoneGap plugin to retrieve the last photo taken.
Jonathan Aquino0.0.20
platforms: ios
$ cordova plugin add com.ning.last-photo-taken

com.ning.last-photo-taken

This plugin provides an API for taking pictures and for choosing images from the system's image library. It only works in iOS - if someone can submit a pull request to make it work in Android, that would be appreciated.

cordova plugin add com.ning.last-photo-taken

navigator.LastPhotoTaken.getLastPhoto

Retrieves the last photo taken by the user. The onSuccess callback is passed the URI for the image file. The onError callback is passed an error message. Works on iOS only.

navigator.LastPhotoTaken.getLastPhoto(onSuccess, onError);

Description

The getLastPhoto function retrieves the last photo taken by the user, at its original size, and at its current orientation. The user may be prompted to give access to photos on the device. The URI returned is for a temporary jpeg file created in NSTemporaryDirectory.

Supported Platforms

  • iOS

Example

If the device is running iOS, retrieve the URI for the last photo taken:

// May need to install the device plugin:
// https://github.com/apache/cordova-plugin-device/blob/master/doc/index.md
if (device.platform === 'iOS') {
  navigator.LastPhotoTaken.getLastPhoto(function (imageUri) {
    alert('imageUri: ' + imageUri);
  }, function (errorMessage) {
    alert(errorMessage);
  });
}