For some reason at IOS 13, on IPHONE XR, when i use that code to get a picture:
const options: CameraOptions = {
quality: 50,
targetWidth: 400,
targetHeight: 400,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
allowEdit: true
}
this.camera.getPicture(options).then((imageData) => {
if(imageData){
//Image data is coming null so he dont join here
let base64Image = `data:image/jpeg;base64,${imageData}`;
}
}).catch((err) => {
let alert = this.alertCtrl.create({
title: 'error',
subTitle: `Um erro foi encontrado: ${err}`,
buttons: ['OK']
});
alert.present();
});
For some reason IMAGEDATA is coming null, and i cant get image, only at iphone xr, but if i use code to get image from gallery works fine, its only with CAMERA at iphone XR;
We are using capacitor plugins: I think capacitor plugin is more reliable and
it can be used with cordova plugin.
import { Plugins, CameraResultType, CameraSource } from ‘@capacitor/core’;
:::
async imageAdd() {
if (this.auth.platform.is('ios') || this.auth.platform.is('android')) {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
saveToGallery: true,
source: CameraSource.Photos,
resultType: CameraResultType.Uri
});
// image.webPath will contain a path that can be set as an image src.
// You can access the original file using image.path, which can be
// passed to the Filesystem API to read the raw data of the image,
// if desired (or pass resultType: CameraResultType.Base64 to getPhoto)
// var imageUrl = image.webPath;
// Can be set to the src of an image now
//this.hotdealImgSrc = imageUrl;
this.auth.uploadImage(image.path, 'goods').then((res: any) => {
this.attachments.push(res);
this.images.push(res.id);
});
}