Hi, I got a strange bug. When I develop on my local browser, CameraResultType is defined, and my code works exactly as I want.
But I run it in capacitor on android 10 (Galaxy a51), this variable is undefined.
The console says : "TypeError: Cannot read property 'base64' of undefined"
I don’t know because how can it work on my browser but not in the app.
async function initIA() {
const {CameraResultType} = await Capacitor.Plugins
console.log(CameraResultType);
const Camera = Capacitor.Plugins.Camera;
const image = await Camera.getPhoto({
quality: 80,
allowEditing: true,
resultType: CameraResultType.base64
})
.then(CameraPhoto => {
const ImgFromHtml = document.getElementById("previewIA")
ImgFromHtml.src = `data:image/png;base64, ${CameraPhoto.base64String}`
DetectFromAI(ImgFromHtml)
})
To import Capacitor, I don’t use import { Plugins, CameraResultType } from '@capacitor/core'
But <script src="capacitor.js"></script>
What npx cap doctor
return :
Capacitor Doctor
Latest Dependencies:
@capacitor/cli: 2.4.7
@capacitor/core: 2.4.7
@capacitor/android: 2.4.7
@capacitor/electron: 2.4.7
@capacitor/ios: 2.4.7
Installed Dependencies:
@capacitor/ios not installed
@capacitor/cli 2.4.7
@capacitor/android 2.4.7
@capacitor/core 2.4.7
@capacitor/electron not installed
[success] Android looking great! 👌
Thanks to anyone reading or answering
Have a great day