Ionic Capacitor Camera working on browser but not in devapp

Hi,

I just wrote a simple app using Capacitor to capture an image and display in the app and it’s working fine on the web browser on my laptop but just the image piece doesn’t work on devapp. Not sure how to fix it. Any help is appreciated.

Here is some code I used:

export class UploadPage {
yourImage: SafeResourceUrl;

constructor(private sanitizer: DomSanitizer) { }

async captureImage() {
const capturedImage = await Plugins.Camera.getPhoto(
{
quality: 90,
allowEditing: false,
source: CameraSource.Camera,
resultType: CameraResultType.DataUrl
}
);

this.yourImage = this.sanitizer.bypassSecurityTrustResourceUrl(capturedImage && (capturedImage.dataUrl));

}

}

Only cordova supported…bummer!

But if u feel like it, maybe use this repo to make your own with cordova AND capacitor (the latter you have to add yourself - not maintaining the repo right now)

So do you mean that if I write code using Capacitor using say the Camera API, it won’t work in devapp but when I push to the App/Play Store it will work?

Yes that is the proper conclusion, providing u coded well

What prevents you from deploying through cable on a device or emulator?

I am new to mobile development and also Ionic development. Could you point me to some links on how to do this for iphone and android?

Plse specify what u r looking for

Angular knowledge
Ionic cli
Cordova
Capacitor
Setting up environments
Deploying to native
Pwa

There is just too much and i cannot tell what u know and dont know

So I have built out a sample Ionic app using Angular using Capacitor to upload/display images from a camera source. It works in my browser, I am able to capture images and display it in the web page inside the Ionic app but I haven’t been able to try it out on the device because this doesn’t work on devapp. I am trying to see this work on a device preferably iOS but if not I can work with Android as well.

Well, maybe try getting it on an android device using studio?

That’s the last resort. Any way I can do it for iOS? I have to borrow an Android device for that. I own an Apple iPhone so i’m trying to get it to work on that.

Sure, although I haven’t done it as i dont have a mac. And I believe u need a developer license from Apple

https://capacitor.ionicframework.com/docs/ios

1 Like