Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23656] Windows: Implement Ti.Media.requestCameraPermissions/hasCameraPermissionsmethods to match iOS and Android behaviour

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-08-01T04:26:16.000+0000
Affected Version/sRelease 5.4.0
Fix Version/sRelease 6.0.0
ComponentsWindows
Labelsparity, qe-5.4.0
ReporterEwan Harris
AssigneeGary Mathews
Created2016-07-19T18:31:17.000+0000
Updated2016-10-05T10:53:35.000+0000

Description

Description

As part of TIMOB-19479 the media permissions was rewritten to be consistent across iOS and Android and use Ti.Media.requestCameraPermissions/hasCameraPermissions. Windows should move to match iOS and Android. A code sample can be found below
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();
            },
            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

Run the code above on Windows Platform appc run -p windows

Actual result

The app will throw an error as the methods are not implemented

Expected result

You should be prompted to allow camera access

Comments

  1. Gary Mathews 2016-07-26

    master: https://github.com/appcelerator/titanium_mobile_windows/pull/790
  2. Kota Iguchi 2016-07-27

    [~eharris] In the ticket description, Actual and Expect results are inverted, right?

    Actual result

    The app will throw an error as the methods are not implemented

    Expected result

    You should be prompted to allow camera access
  3. Ewan Harris 2016-07-27

    [~kota] yup, sorry about that! Updated
  4. Kota Iguchi 2016-08-01

    Note for QE: - Calling requestCameraPermissions() callbacks success=true when there's webcam capability configured in {tiapp.xml}}. It should be configured in tiapp.xml because there's no way to request camera permission at runtime on Windows.
  5. Ewan Harris 2016-10-05

    Verified using: OS: Microsoft Windows 10 Pro 10.0.14393 Appc core: 6.0.0-56 Appc NPM: 4.2.8-7 Ti SDK: 6.0.0.v20161004202820 Appc Studio: 4.8.0.201609292239 Code in description now works as expected Closing ticket

JSON Source