GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Getting Started
  • Setup
  • FAQ
  • Plugins
  • App Launcher
  • App
  • Browser
  • Camera
  • Clipboard
  • Device
  • Dialog
  • Filesystem
  • Geolocation
  • Google Maps

This view

  • Original page
  • New address

GeezerVison is showing ionicframework.com — Capacitor Plugins | Ionic Framework

Getting started with Capacitor is fairly straight forward for Ionic developers. Adding plugins to your project is no different than adding any dependencies you may need to a project.

Install​

To install a plugin, find the plugin you want to use and install it using your package manager, like npm:

# Install the Capacitor Plugins
$ npm install @capacitor/camera

Usage​

Once installed, plugins can be imported into a component and you can call the native functionality directly from your code.

Using the Camera plugin as an example, first install it:

  • JavaScript
  • Angular
  • Vue
  • React
import { Camera, CameraResultType } from '@capacitor/camera';

const takePicture = async () => {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.Uri
});
const imageUrl = image.webPath;
imageElement.src = imageUrl;
};
import { Component } from '@angular/core';
import { Camera, CameraResultType } from '@capacitor/camera';

@Component({...})
export class CameraComponent{
public imageSrc: string | undefined = '';

async takePicture() {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.Uri
});
const imageUrl = image.webPath;
this.imageSrc = imageUrl;
};
}

<template>
...
</template>

<script setup lang="typescript">
import { ref } from 'vue';
import { Camera, CameraResultType } from '@capacitor/camera';
const imageSrc = ref<string | undefined>('');

const takePicture = async () => {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.Uri
});
const imageUrl = image.webPath;
imageSrc.value = imageUrl;
};

</script>

import { Camera, CameraResultType } from '@capacitor/camera';
import { useState } from 'react';

export function CameraComponent() {
const [imageSrc, setImageSrc] = useState<string | undefined>('');

const takePicture = async () => {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.Uri
});
const imageUrl = image.webPath;
setImageSrc(imageUrl);
};
return (...)
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.