question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Camera API not working - cameraModal.present is not a function

See original GitHub issue

Hi.

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:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mlynchcommented, Jun 7, 2018

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

1reaction
davidseekcommented, Jun 11, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found