Search code examples
javascriptcapacitor

Using Capacitor Plugins as Script Include (not with bundle/module loader)


The Capacitor JS documentation handily documents how the core can be included without using a bundle/module loader on this page, but what is fails to do is then provide an example of how to then implement a plugin.

For example, here's how the Capacitor docs show how to use the Camera plugin:

import { Plugins } from '@capacitor/core';

const { Camera } = Plugins;

const photo = await Camera.getPhoto({
  quality: 100,
  resultType: CameraResultType.Uri,
  allowEditing: true,
  saveToGallery: true
});

If I'm using the <script src="capacitor.js"></script> version of including capacitor, what's the non-module version of the above?

Thanks


Solution

  • Capacitor.Plugins.Camera.getPhoto({
      quality: 100,
      resultType: CameraResultType.Uri,
      allowEditing: true,
      saveToGallery: true
    })