Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › displayCameraPicker – App Crash

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17551

    Alexander

    Hi Felgo Team,

    I’m experiencing an issue with the nativeUtils.displayCameraPicker which crashes the app on iOS devices when used for the first time (on version 2.13.2).

    1. Camera opens
    2. Permission requested (and approved)
    3. Photo Taken
    4. Photo Selected
    5. Crash (Presuming no access to camera reel given.

    When I open the imagePicker, I am prompted for Access permission. When approved, the camera then works. The crash is repeatable if you uninstall the app, re-install and follow the steps again

    Is there any way to have the camera prompt for the PhotoLibrary permission as well before the photo is taken?

        Connections {
            target: nativeUtils
    
            onCameraPickerFinished: {
                if (accepted && path) {
                    console.log(path)
                }
            }
    
            onImagePickerFinished: {
                if (accepted && path) {
                    console.log(path)
                }
            }
    
            onAlertSheetFinished: {
                if (index === 0) {
                    nativeUtils.displayCameraPicker("Take a Photo")
                } else if (index === 1) {
                    nativeUtils.displayImagePicker("Select a Photo")
                }
            }
        }

     

    #17554

    Günther
    Felgo Team

    Hi Alexander,

    the dialog to request access to the Photo Gallery should pop up after choosing a photo with the image picker.
    As soon as the photo is chosen, you are asked for the permission and can then use the selected photo in your QML code.

    Can you make sure that your apps Project-Info.plist contains the following entries:

        <key>NSPhotoLibraryUsageDescription</key>
        <string>App would like to access the library.</string>
        <key>NSCameraUsageDescription</key>
        <string>App would like to access the camera.</string>

    In case you have these settings present, and still experience the crash, please let me know:

    • Which device are you using for testing?
    • Does the issue only happen on this device or also with e.g. another iOS device or the simulator?
    • Can you provide a simple example QML that allows to reproduce the crash?

    Best,
    Günther

    #17556

    Alexander

    Hi Günther,

    • Device: iPhone 6, iOS 11.0.3
    • The issue happens with other iOS devices as well
    • I can’t reproduce on the simulator as it doesn’t allow camera access
    • The Keys for Photo Library and Camera are present.

    I get the prompt to use the camera, and approve that. After that I take the photo. Then when I tap choose to use that photo…Crash.

    I will attempt to setup a new project for reproducing and sharing.

    #17557

    Alexander

    Hi Günther,

    I’ve managed to verify this is still a problem on iDevices, though appears to be iOS 11 related (my iOS 10 devices had no issues).

    • iPad Pro, iOS 11.1.2
    • Xcode Version 9.1 (9B55)
    • Qt 5.9.2
    • Felgo 2.14

    I managed to find the issue by building the app in Qt Creator and running it from Xcode on the device. It appears that a new security key was added for iOS 11 (NSPhotoLibraryAddUsageDescription) and it needs to be set in the info.plist

    The below is enough to reproduce it.

    import Felgo 3.0
    import QtQuick 2.0
    import Felgo 3.0
    App {
        NavigationStack {
            Page {
                title: qsTr("Main Page")
                MouseArea {
                    anchors.fill: parent
                    onClicked: nativeUtils.displayCameraPicker("Take a Photo")
                }
            }
        }
        Connections {
            target: nativeUtils
            onCameraPickerFinished: {
                console.log(accepted, path)
            }
        }
    }
    

     

    #17605

    Günther
    Felgo Team

    Hi Alexander,

    thanks for the example and the info about NSPhotoLibraryAddUsageDescription entry!

    So if I understood correctly, everything work on all devices when adding this key – or does the app still crash somewhere?

    Best,
    Günther

    #17616

    Alexander

    Hi Günther,

    That is correct. Adding the NSPhotoLibraryAddUsageDescription solved my problems and my app hasn’t crashed since.

    With regards,

Viewing 6 posts - 1 through 6 (of 6 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded