Camera API not working - cameraModal.present is not a function
See original GitHub issueHi.
I’ve try the Capacitor Camera API… Simple to settup but in fact it not realy work. Here the returned error from an Ionic 4 + Angular 6 application.
Following code bug:
import { Component, OnInit } from '@angular/core';
import { Plugins, CameraResultType, FilesystemDirectory } from '@capacitor/core';
const { Camera, Filesystem } = Plugins;
@Component({
selector: 'app-tab-three',
templateUrl: './tab-three.component.html',
styleUrls: ['./tab-three.component.css']
})
export class TabThreeComponent implements OnInit {
constructor() { }
ngOnInit() {
}
takePhoto() {
const options = {
resultType: CameraResultType.Uri
};
Camera.getPhoto(options).then(
(photo) => {
console.log(photo);
}, (err) => {
console.log(err);
}
);
}
}
Error:
core.js:1598 ERROR Error: Uncaught (in promise): TypeError: cameraModal.present is not a function
TypeError: cameraModal.present is not a function
at CameraPluginWeb.<anonymous> (camera.js:49)
at step (tslib.es6.js:91)
at Object.next (tslib.es6.js:72)
at fulfilled (tslib.es6.js:62)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
at Object.onInvoke (core.js:4062)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
at zone.js:872
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at CameraPluginWeb.<anonymous> (camera.js:49)
at step (tslib.es6.js:91)
at Object.next (tslib.es6.js:72)
at fulfilled (tslib.es6.js:62)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
at Object.onInvoke (core.js:4062)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
at zone.js:872
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at resolvePromise (zone.js:814)
at zone.js:724
at fulfilled (tslib.es6.js:62)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
at Object.onInvoke (core.js:4062)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
at zone.js:872
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4053)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Ionic 4 - Camera - Runtime Error - Object(...) is not a function
I'm creating an Ionic app with camera function. I used for this the doc from ionic-framework Ionic native camera.
Read more >Using the Camera API in a PWA with Capacitor - Josh Morony
In this tutorial, we will walk through how to use the Camera API in a PWA with Capacitor.
Read more >Cant "Use Photo" with Capacitor Camera Plugin - Ionic Forum
Uri seems to get through, meaning the console.log after taking the photo gets logged. The only options not working are CameraResultType.Base64 ...
Read more >Using the Camera API in a PWA with Capacitor - Morioh
In this tutorial, we will walk through how to use the Camera API in a PWA with Capacitor. We will be using an...
Read more >Requesting Authorization for Media Capture on iOS
For example, if photo or video recording isn't the main focus of your app, check for camera permission only when the user invokes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You need to have this script include for now in your
index.html
:https://github.com/ionic-team/capacitor/blob/master/example/src/index.html#L14
worked for me as well. but creeps me out that it’s not part of stable build since this came up a year ago.
makes me question, how stable this whole stuff overall is.