user4526265
user4526265

Reputation:

Cordova camera will only open iOS moments, not camera roll

I'm building an app using Ionic with AngularJS. I'm using the ngCordova library for access to device APIs.

Here's my code for users to select an image from their gallery:

document.addEventListener("deviceready", function () {
  $scope.chooseFromGallery = function () {
    var options = {
      sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
      targetWidth: 1000,
      targetHeight: 1000,
      allowEdit: true
    };
    $cordovaCamera.getPicture(options)
      .then(function (imageURI) {
        $scope.postData.imageUri = imageURI;
      }, function (error) {
        console.log(error);
      })
  }
});

This works fine, but only opens the 'moments' part of the user's gallery. Which only shows images taken by the phone itself, not saved ones. It also splits them up by date and location. Edit: It seems to show some photos saved to the phone, but not all. I have no idea why.

How can I make it default to the users's camera roll that shows a continuous grid of all images stored on the phone, arranged by date. I can find anything that describes what I need in the docs to add to the options object that is passed to the getPicture method. Docs link

Thanks :)

Upvotes: 2

Views: 318

Answers (1)

jcesarmobile
jcesarmobile

Reputation: 53301

Use Camera.PictureSourceType.PHOTOLIBRARY

The doc says that SAVEDPHOTOALBUM is the same that PHOTOLIBRARY, but it's not, SAVEDPHOTOALBUM only shows pictures taken by the camera, and PHOTOLIBRARY show all images on the device

Upvotes: 1

Related Questions