Menu

1 / 2

Capacitor Has a Free API That Most Developers Dont Know About

DEV Community: ionic·Alex Spinov·5 months ago
#BDBTP0me
#dev#capacitor#native#import#photo
Reading 0:00
15s threshold

Capacitor by Ionic lets you build cross-platform mobile apps using web technologies. Unlike Cordova, it gives you full native API access with a modern plugin system.

Native APIs from JavaScript

import { Camera , CameraResultType } from " @capacitor/camera " ; import { Geolocation } from " @capacitor/geolocation " ; import { LocalNotifications } from " @capacitor/local-notifications " ; import { Share } from " @capacitor/share " ;

// Take a photo const photo = await Camera . getPhoto ({ quality : 90 , resultType : CameraResultType . Uri , allowEditing : true });

// Get location const position = await Geolocation . getCurrentPosition (); console . log ( position . coords . latitude , position . coords . longitude );

// Local notification await LocalNotifications . schedule ({ notifications : [{ title : " Reminder " , body : " Check your tasks " , id : 1 , schedule : { at : new Date ( Date . now () + 60000 ) } }] });

// Share await Share . share ({ title : " Check this out " , text : " Amazing app!…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.