Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23981] Windows: Using Ti.Media.showCamera with saveToPhotoGallery throws access denied

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionWon't Fix
Resolution Date2016-10-20T23:55:41.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sn/a
ComponentsWindows
Labelsqe-6.0.0
ReporterEwan Harris
AssigneeKota Iguchi
Created2016-10-04T17:27:00.000+0000
Updated2016-10-20T23:55:41.000+0000

Description

Description

When using Ti.Media.showCamera and setting saveToPhotoGallery to true an error will be thrown after the user has taken a photo. This is fixed by adding the following capabilities
<Capability Name="picturesLibrary" />
<Capability Name="videosLibrary" />
function showCamera() {
    Titanium.Media.showCamera({
        success : function(event) {
            // called when media returned from the camera
            Ti.API.debug('Photo taken successfully');
        },
        cancel : function() {
            // called when user cancels taking a picture
            Ti.API.debug('Photo cancelled.');
        },
        error : function(error) {
            Ti.API.debug('Photo errored.');
            // called when there's an error
            var a = Titanium.UI.createAlertDialog({
                title : "Camera"
            });
            a.setMessage(JSON.stringify(error));
            a.show();
            console.log(JSON.stringify(error));
        },
        saveToPhotoGallery : true
    });
}
if (Ti.Media.hasCameraPermissions()) {
    showCamera();
} else {
    Ti.Media.requestCameraPermissions(function(e) {
        if (e.success === true) {
            showCamera();
        } else {
            alert("Access denied, error: " + e.error);
        }
    });
}

Steps to reproduce

Add the code above to an existing app.js

Build for Windows appc run -p windows -T wp-device

Take a photo

Tap the tick to save the photo

Actual result

Error is thrown

Expected result

Error should not be thrown

Comments

  1. Kota Iguchi 2016-10-20

    I would resolve this as "won't fix", because it is difficult to detect if target property (saveToPhotoGallery) is actually true (or not) at compile time. We need to manually set required permission in this case.

JSON Source