iOS Security Prompt and Camera Behind


#1

Hi All,

I have managed to get through the saga of getting an iOS app built and onto the an iPAD through xcode, but seem to have an issue with the Camera plugin. When i click the button to take a picture or upload the picture the code eblow is used. The iOS security prompt seems to pop up behind the app; if i press home and then switch back to the app it displays over the top. Once allowed the same happens with the actual camera; it load behind the app and only by pressing home and switching back does it them pring the preview/captcher screen infront of the app.

I did a search on here and google and couldn’t find the answer but apologies if I have missed something.

Thanks in advance!

takePicture(idx, itemId, type) {
        let newImage = new ItemImage();
        newImage.itemId = itemId;
        newImage.imageId = this.items[idx].images.length;
        let srcType = this.camera.PictureSourceType.PHOTOLIBRARY;
        if (type == 'lib') {
            srcType = this.camera.PictureSourceType.PHOTOLIBRARY;
        }
        if (type == 'cam') {
            srcType = this.camera.PictureSourceType.CAMERA;
        }
        this.camera.getPicture({
            quality: 100,
            sourceType: srcType,
            //destinationType: this.camera.DestinationType.DATA_URL,
            encodingType: this.camera.EncodingType.JPEG,
            mediaType: this.camera.MediaType.PICTURE,
            saveToPhotoAlbum: false,
            correctOrientation: true
        }).then((imageData) => {
            // imageData is a base64 encoded string
            if (this.platform.is('android') && type === 'lib') {
                this.filePath.resolveNativePath(imageData)
                    .then(filePath => {
                        let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);
                        let currentName = imageData.substring(imageData.lastIndexOf('/') + 1, imageData.lastIndexOf('?'));
                        this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
                    });
            } else {
                var currentName = imageData.substr(imageData.lastIndexOf('/') + 1);
                var correctPath = imageData.substr(0, imageData.lastIndexOf('/') + 1);
                this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
            }
            if (type == 'lib') {
                newImage.imageData = this.lastImage;
            } else {
                newImage.imageData = "data:image/jpeg;base64," + imageData;
            }
            
            this.items[idx].images.push(newImage);
        }, (err) => {
            console.log(err);
        });
    }

#2

Anyone? If anyone has successfully got camera working without this issue and have their code on github or similar happy to do the ‘leg work’ to work out the difference in implementation. Thanks


#3

Has no one else had this issue? Any examples of working apps I could look at?