Skip to content

IOS app for NS 7 crashes after user confirm photo #250

Open
@andreasteffanoni

Description

@andreasteffanoni

Environment
"nativescript": "^7.0.8",
"@nativescript/core": "^7.0.7",
"@nativescript/ios": "7.0.0",
"@nativescript/camera": "^5.0.0",

In a plain JS app, when taking a picture, the iOS version of the app crashes with the message " NativeScriptError: TypeError: Cannot read property 'creationDate' of undefined". The crash happens after taking the photo, when the user confirms the picture. The android version works without issues. The app was working fine before upgrading to NS 7.

To Reproduce

import { Application, ImageSource, fromObject, Utils } from '@nativescript/core';
import { isAvailable, requestPermissions, takePicture } from '@nativescript/camera';

var options = { width: 300, height: 300, keepAspectRatio: true, saveToGallery: true, cameraFacing: "rear", quickCapture: true }
takePicture(options)
    .then(function(imageAsset)
    {           
             // Code never reach this point
    }).catch(function (err) { console.log(err.message); });

Inspecting the camera plugin code, the error happens in line 54:

        var fetchResult = PHAsset.fetchAssetsWithOptions(fetchOptions);
        if (fetchResult.count > 0) {
               var asset = fetchResult[0];
               var dateDiff = asset.creationDate.valueOf() - currentDate_1.valueOf();   <---- line of error

Debugging, fetchResult.count is > 0 but asset is undefined (thus the error).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions