Skip to main content

How To Use a Capacitor Plugin

Ionic Portals uses Capacitor under the hood, meaning that you can use existing Capacitor Core Plugins in your Portals. These plugins allow Portals to use native functionality without much setup on either the native or web developers part.

Native Usage#

In order to use a Capacitor Plugin, you need to install the plugin as a dependency in your Podfile.

pod 'IonicPortals', '~> 0.2.2'pod 'CapacitorStorage', '~> 1.2.0'

Make sure that the versions in your Podfile and package.json match! Otherwise you could run into errors.

After installing the dependency inject the Plugin to the Portal's bridge. You can do this in the viewDidLoad function.

override func viewDidLoad() {    // Inject the plugin into the native bridge    apiPlugin = bridge?.plugin(withName: "MyPlugin") as? MyPlugin        // now call super which will start the initial load    super.viewDidLoad()}

Published Plugins#

In CocoaPods, the Capacitor plugins are prepended with Capacitor. For example, the @capacitor/storage plugin on npm is named CapacitorStorage on CocoaPods. The following Plugins are available in CocoaPods.


The Action Sheet API provides access to native Action Sheets, which come up from the bottom of the screen and display actions a user can take.


The AppLauncher API allows to open other apps


The Browser API provides the ability to open an in-app browser and subscribe to browser events.


The Camera API provides the ability to take a photo with the camera or choose an existing one from the photo album.


The Clipboard API enables copy and pasting to/from the system clipboard.


The Device API exposes internal information about the device, such as the model and operating system version, along with user information such as unique ids.


The Dialog API provides methods for triggering native dialog windows for alerts, confirmations, and input prompts


The Filesystem API provides a NodeJS-like API for working with files on the device.


The Geolocation API provides simple methods for getting and tracking the current position of the device using GPS, along with altitude, heading, and speed information if available.


The Haptics API provides physical feedback to the user through touch or vibration.


The Keyboard API provides keyboard display and visibility control, along with event tracking when the keyboard shows and hides.


The Local Notifications API provides a way to schedule device notifications locally (i.e. without a server sending push notifications).


The Network API provides network and connectivity information.


The Push Notifications API provides access to native push notifications.


The Screen Reader API provides access to TalkBack/VoiceOver/etc. and provides simple text-to-speech capabilities for visual accessibility.


The Share API provides methods for sharing content in any sharing-enabled apps the user may have installed.


The Splash Screen API provides methods for showing or hiding a Splash image.


The StatusBar API Provides methods for configuring the style of the Status Bar, along with showing or hiding it.


The Storage API provides a simple key/value persistent store for lightweight data.


The Text Zoom API provides the ability to change Web View text size for visual accessibility.


The Toast API provides a notification pop up for displaying important information to a user. Just like real toast!

Web Usage#

Web Developers need to install the web dependency of the plugins from npm. The packages are listed under the @capacitor scope. To install a plugin, run npm i @capacitor/<plugin_name> at the root of your web project.


Make sure that the versions in your Podfile, build.gradle, and package.json all match! Otherwise you will run into errors

For more information on how to use Capacitor Plugins in your web application, check out the Capacitor Plugin docs.