ionic-team / tutorial-photo-gallery-angular

Photo Gallery Tutorial: Ionic Angular and Capacitor

Home Page:https://ionicframework.com/docs/angular/your-first-app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to access camera on mobile when running app through browser

casperchia opened this issue · comments

Hi, I've been following your tutorial for this app and I've managed to get it to run just fine on desktop Chrome using ionic serve. I've also tried running them within web browsers on both android and iOS devices but the camera doesn't launch on mobile - nothing happens when you click on the camera button. Will it only work on mobile if deployed and run as mobile apps? Or am I missing something here?

Thanks!

The entire app will work on the web, iOS, and Android.

Under the hood, the Camera plugin uses the getUserMedia API - which requires either HTTPS or localhost. It works with ionic serve because that's localhost, but my guess is that you're hosting the app somewhere on HTTP maybe?

Thanks @dotNetkow, that worked!

Running ionic serve with the --ssl flag did the trick.