### Install @capacitor/screen-orientation Source: https://github.com/ionic-team/capacitor-plugins/blob/main/screen-orientation/README.md Install the plugin and sync Capacitor. ```bash npm install @capacitor/screen-orientation npx cap sync ``` -------------------------------- ### Install @capacitor/share Source: https://github.com/ionic-team/capacitor-plugins/blob/main/share/README.md Commands to install the plugin and sync the project. ```bash npm install @capacitor/share npx cap sync ``` -------------------------------- ### Install @capacitor/dialog Source: https://github.com/ionic-team/capacitor-plugins/blob/main/dialog/README.md Commands to install the plugin and sync the native project. ```bash npm install @capacitor/dialog npx cap sync ``` -------------------------------- ### Install Capacitor Network Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/network/README.md Install the network plugin and sync Capacitor. ```bash npm install @capacitor/network npx cap sync ``` -------------------------------- ### Install Text Zoom Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/text-zoom/README.md Install the plugin package and sync the project with Capacitor. ```bash npm install @capacitor/text-zoom npx cap sync ``` -------------------------------- ### Example Usage Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md TypeScript examples demonstrating how to use the StatusBar API methods. ```APIDOC ## Example ```typescript import { StatusBar, Style } from '@capacitor/status-bar'; // iOS only window.addEventListener('statusTap', function () { console.log('statusbar tapped'); }); // Display content under transparent status bar StatusBar.setOverlaysWebView({ overlay: true }); const setStatusBarStyleDark = async () => { await StatusBar.setStyle({ style: Style.Dark }); }; const setStatusBarStyleLight = async () => { await StatusBar.setStyle({ style: Style.Light }); }; const hideStatusBar = async () => { await StatusBar.hide(); }; const showStatusBar = async () => { await StatusBar.show(); }; ``` ``` -------------------------------- ### Install Capacitor Camera Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/camera/README.md Commands to install the plugin and synchronize the project. ```bash npm install @capacitor/camera npx cap sync ``` -------------------------------- ### Install Capacitor Clipboard Source: https://github.com/ionic-team/capacitor-plugins/blob/main/clipboard/README.md Install the @capacitor/clipboard package and sync Capacitor. ```bash npm install @capacitor/clipboard npx cap sync ``` -------------------------------- ### Install Motion Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/motion/README.md Commands to install the plugin and sync it with the Capacitor project. ```bash npm install @capacitor/motion npx cap sync ``` -------------------------------- ### Install Screen Reader Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/screen-reader/README.md Commands to install the plugin and sync the project. ```bash npm install @capacitor/screen-reader npx cap sync ``` -------------------------------- ### Install monorepo dependencies Source: https://github.com/ionic-team/capacitor-plugins/blob/main/CONTRIBUTING.md Initial command to install project dependencies. ```shell npm install ``` -------------------------------- ### Install Capacitor Browser Source: https://github.com/ionic-team/capacitor-plugins/blob/main/browser/README.md Commands to install the plugin and synchronize native project files. ```bash npm install @capacitor/browser npx cap sync ``` -------------------------------- ### Install Action Sheet Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/action-sheet/README.md Commands to install the plugin and synchronize the native project files. ```bash npm install @capacitor/action-sheet npx cap sync ``` -------------------------------- ### Install Capacitor Status Bar Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Commands to install the plugin and sync the project. ```bash npm install @capacitor/status-bar npx cap sync ``` -------------------------------- ### Install Capacitor Toast Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/toast/README.md Install the plugin using npm and then sync Capacitor. ```bash npm install @capacitor/toast npx cap sync ``` -------------------------------- ### Install Capacitor App Launcher Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app-launcher/README.md Install the AppLauncher plugin using npm and then synchronize your Capacitor project. ```bash npm install @capacitor/app-launcher npx cap sync ``` -------------------------------- ### Install Capacitor App Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Install the @capacitor/app plugin and sync the native platforms. ```bash npm install @capacitor/app npx cap sync ``` -------------------------------- ### Install Push Notifications Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/push-notifications/README.md Install the push notifications plugin and sync Capacitor. ```bash npm install @capacitor/push-notifications npx cap sync ``` -------------------------------- ### Install Capacitor Device Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/device/README.md Commands to install the package and synchronize the native project. ```bash npm install @capacitor/device npx cap sync ``` -------------------------------- ### Install Capacitor Splash Screen Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/splash-screen/README.md Commands to install the plugin and sync native project files. ```bash npm install @capacitor/splash-screen npx cap sync ``` -------------------------------- ### Install Capacitor Preferences Source: https://github.com/ionic-team/capacitor-plugins/blob/main/preferences/README.md Install the plugin using npm and sync Capacitor to include native dependencies. ```bash npm install @capacitor/preferences npx cap sync ``` -------------------------------- ### Install @capacitor/status-bar Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Instructions for installing the Capacitor Status Bar plugin and syncing native projects. ```APIDOC ## Install ```bash npm install @capacitor/status-bar npx cap sync ``` ``` -------------------------------- ### Install Local Notifications Plugin Source: https://github.com/ionic-team/capacitor-plugins/blob/main/local-notifications/README.md Install the plugin using npm and sync Capacitor to apply changes. ```bash npm install @capacitor/local-notifications npx cap sync ``` -------------------------------- ### Install with local dependencies Source: https://github.com/ionic-team/capacitor-plugins/blob/main/CONTRIBUTING.md Executes the toggle script to link local dependencies. ```shell npm run toggle-local ``` -------------------------------- ### Configure Status Bar Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Examples for setting status bar properties in Capacitor configuration files. ```json { "plugins": { "StatusBar": { "overlaysWebView": false, "style": "DARK", "backgroundColor": "#ffffffff" } } } ``` ```ts /// import { CapacitorConfig } from '@capacitor/cli'; const config: CapacitorConfig = { plugins: { StatusBar: { overlaysWebView: false, style: "DARK", backgroundColor: "#ffffffff", }, }, }; export default config; ``` -------------------------------- ### Open a URL in the Browser Source: https://github.com/ionic-team/capacitor-plugins/blob/main/browser/README.md Example of using the Browser plugin to open a specific URL. ```typescript import { Browser } from '@capacitor/browser'; const openCapacitorSite = async () => { await Browser.open({ url: 'http://capacitorjs.com/' }); }; ``` -------------------------------- ### Set up Push Notification Listeners and Register Device Source: https://github.com/ionic-team/capacitor-plugins/blob/main/push-notifications/README.md This example demonstrates how to add listeners for various push notification events and register the device for receiving notifications. It includes checking and requesting user permissions. ```typescript import { PushNotifications } from '@capacitor/push-notifications'; const addListeners = async () => { await PushNotifications.addListener('registration', token => { console.info('Registration token: ', token.value); }); await PushNotifications.addListener('registrationError', err => { console.error('Registration error: ', err.error); }); await PushNotifications.addListener('pushNotificationReceived', notification => { console.log('Push notification received: ', notification); }); await PushNotifications.addListener('pushNotificationActionPerformed', notification => { console.log('Push notification action performed', notification.actionId, notification.inputValue); }); } const registerNotifications = async () => { let permStatus = await PushNotifications.checkPermissions(); if (permStatus.receive === 'prompt') { permStatus = await PushNotifications.requestPermissions(); } if (permStatus.receive !== 'granted') { throw new Error('User denied permissions!'); } await PushNotifications.register(); } const getDeliveredNotifications = async () => { const notificationList = await PushNotifications.getDeliveredNotifications(); console.log('delivered notifications', notificationList); } ``` -------------------------------- ### Install SwiftLint Source: https://github.com/ionic-team/capacitor-plugins/blob/main/CONTRIBUTING.md Required for macOS users to ensure iOS code linting. ```shell brew install swiftlint ``` -------------------------------- ### Use Dialog methods Source: https://github.com/ionic-team/capacitor-plugins/blob/main/dialog/README.md Examples of triggering alert, confirm, and prompt dialogs using the Dialog API. ```typescript import { Dialog } from '@capacitor/dialog'; const showAlert = async () => { await Dialog.alert({ title: 'Stop', message: 'this is an error', }); }; const showConfirm = async () => { const { value } = await Dialog.confirm({ title: 'Confirm', message: `Are you sure you'd like to press the red button?`, }); console.log('Confirmed:', value); }; const showPrompt = async () => { const { value, cancelled } = await Dialog.prompt({ title: 'Hello', message: `What's your name?`, }); console.log('Name:', value); console.log('Cancelled:', cancelled); }; ``` -------------------------------- ### Get App Information Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Retrieve information about the application. ```typescript getInfo() => Promise ``` -------------------------------- ### Retrieve Device and Battery Information Source: https://github.com/ionic-team/capacitor-plugins/blob/main/device/README.md Example usage of the Device API to fetch and log device and battery details. ```typescript import { Device } from '@capacitor/device'; const logDeviceInfo = async () => { const info = await Device.getInfo(); console.log(info); }; const logBatteryInfo = async () => { const info = await Device.getBatteryInfo(); console.log(info); }; ``` -------------------------------- ### Share content using Share API Source: https://github.com/ionic-team/capacitor-plugins/blob/main/share/README.md Examples of sharing text, URLs, local files, and multiple files using the Share plugin. ```typescript import { Share } from '@capacitor/share'; await Share.share({ title: 'See cool stuff', text: 'Really awesome thing you need to see right meow', url: 'http://ionicframework.com/', dialogTitle: 'Share with buddies', }); // Share text only await Share.share({ text: 'Really awesome thing you need to see right meow', }); // Share url only await Share.share({ url: 'http://ionicframework.com/', }); // Share local file using url parameter const photo = await Camera.getPhoto(options); await Share.share({ url: photo.path, }); // Share multiple files using files parameter const { photos } = await Camera.pickImages(options); await Share.share({ files: photos.map(photo => photo.path!), }); ``` -------------------------------- ### Reset environment and dependencies Source: https://github.com/ionic-team/capacitor-plugins/blob/main/CONTRIBUTING.md Clears node_modules and package-lock files to resolve installation errors. ```shell npx lerna exec 'rm -fr package-lock.json && rm -fr node_modules' rm -fr node_modules ``` -------------------------------- ### Get App Launch URL Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Retrieve the URL that was used to launch the application, if any. ```typescript getLaunchUrl() => Promise ``` -------------------------------- ### Display Action Sheet Source: https://github.com/ionic-team/capacitor-plugins/blob/main/action-sheet/README.md Example of triggering an action sheet with multiple options and a destructive style button. ```typescript import { ActionSheet, ActionSheetButtonStyle } from '@capacitor/action-sheet'; const showActions = async () => { const result = await ActionSheet.showActions({ title: 'Photo Options', message: 'Select an option to perform', options: [ { title: 'Upload', }, { title: 'Share', }, { title: 'Remove', style: ActionSheetButtonStyle.Destructive, }, ], }); console.log('Action Sheet result:', result); }; ``` -------------------------------- ### Example PrivacyInfo.xcprivacy Configuration Source: https://github.com/ionic-team/capacitor-plugins/blob/main/preferences/README.md This XML configuration is required for Apple's privacy manifest, specifying the usage of UserDefaults. Ensure this is added to your PrivacyInfo.xcprivacy file. ```xml NSPrivacyAccessedAPITypes NSPrivacyAccessedAPIType NSPrivacyAccessedAPICategoryUserDefaults NSPrivacyAccessedAPITypeReasons CA92.1 ``` -------------------------------- ### GET /device/info Source: https://github.com/ionic-team/capacitor-plugins/blob/main/device/README.md Retrieves comprehensive information about the current device, including hardware model, operating system details, and platform identification. ```APIDOC ## GET /device/info ### Description Retrieves information about the device, such as the model, platform, and operating system version. ### Method GET ### Response #### Success Response (200) - **name** (string) - The name of the device. - **model** (string) - The device model. - **platform** ('ios' | 'android' | 'web') - The device platform. - **operatingSystem** (OperatingSystem) - The operating system of the device. - **osVersion** (string) - The version of the device OS. - **iOSVersion** (number) - The iOS version number (iOS only). - **androidSDKVersion** (number) - The Android SDK version number (Android only). - **manufacturer** (string) - The manufacturer of the device. - **isVirtual** (boolean) - Whether the app is running in a simulator/emulator. ``` -------------------------------- ### Open a Twitter package (Android only) Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app-launcher/README.md On Android, you can open an app directly using its package name. This example attempts to launch the Twitter app. ```typescript import { AppLauncher } from '@capacitor/app-launcher'; // Android only const openTwitterPackage = async () => { const { completed } = await AppLauncher.openUrl({ url: 'com.twitter.android' }); console.log('openUrl package completed: ', completed); }; ``` -------------------------------- ### Basic Preferences API Usage Source: https://github.com/ionic-team/capacitor-plugins/blob/main/preferences/README.md Demonstrates setting, getting, and removing a string value from persistent storage. Use JSON.stringify and JSON.parse for non-string data types. ```typescript import { Preferences } from '@capacitor/preferences'; const setName = async () => { await Preferences.set({ key: 'name', value: 'Max', }); }; const checkName = async () => { const { value } = await Preferences.get({ key: 'name' }); console.log(`Hello ${value}!`); }; const removeName = async () => { await Preferences.remove({ key: 'name' }); }; ``` -------------------------------- ### Open a Twitter URL Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app-launcher/README.md Use `openUrl` to launch an app associated with the given URL scheme. This example attempts to open the Twitter timeline. ```typescript import { AppLauncher } from '@capacitor/app-launcher'; const openTwitterUrl = async () => { const { completed } = await AppLauncher.openUrl({ url: 'twitter://timeline' }); console.log('openUrl completed: ', completed); }; ``` -------------------------------- ### Listen to App Events and Get Launch URL Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Listen for app state changes, URL opens, and restored results. Also retrieves the app's launch URL. ```typescript import { App } from '@capacitor/app'; App.addListener('appStateChange', ({ isActive }) => { console.log('App state changed. Is active?', isActive); }); App.addListener('appUrlOpen', data => { console.log('App opened with URL:', data); }); App.addListener('appRestoredResult', data => { console.log('Restored state:', data); }); const checkAppLaunchUrl = async () => { const { url } = await App.getLaunchUrl(); console.log('App opened with URL: ' + url); }; ``` -------------------------------- ### Capture Photo with Capacitor Camera Source: https://github.com/ionic-team/capacitor-plugins/blob/main/camera/README.md Example of using the Camera API to take a photo and display it in an image element. ```typescript import { Camera, CameraResultType } from '@capacitor/camera'; const takePicture = async () => { const image = await Camera.getPhoto({ quality: 90, allowEditing: true, resultType: CameraResultType.Uri }); // image.webPath will contain a path that can be set as an image src. // You can access the original file using image.path, which can be // passed to the Filesystem API to read the raw data of the image, // if desired (or pass resultType: CameraResultType.Base64 to getPhoto) var imageUrl = image.webPath; // Can be set to the src of an image now imageElement.src = imageUrl; }; ``` -------------------------------- ### Configure Foreground Notification Presentation Options (JSON) Source: https://github.com/ionic-team/capacitor-plugins/blob/main/push-notifications/README.md Set presentation options for push notifications in the foreground by adding the PushNotifications plugin configuration to your `capacitor.config.json` file. This example includes all available options. ```json { "plugins": { "PushNotifications": { "presentationOptions": ["badge", "sound", "alert", "banner", "list"] } } } ``` -------------------------------- ### Check if a Twitter URL can be opened Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app-launcher/README.md Use `canOpenUrl` to check if the specified URL scheme is supported by an installed app. This example checks for the Twitter timeline URL. ```typescript import { AppLauncher } from '@capacitor/app-launcher'; const checkCanOpenTwitterUrl = async () => { const { value } = await AppLauncher.canOpenUrl({ url: 'twitter://timeline' }); console.log('Can open url: ', value); }; ``` -------------------------------- ### Check if a Twitter package can be opened (Android only) Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app-launcher/README.md On Android, you can check if an app can be opened using its package name. This example checks for the Twitter app package. ```typescript import { AppLauncher } from '@capacitor/app-launcher'; // Android only const checkCanOpenTwitterPackage = async () => { const { value } = await AppLauncher.canOpenUrl({ url: 'com.twitter.android' }); console.log('Can open package: ', value); }; ``` -------------------------------- ### Share API Overview Source: https://github.com/ionic-team/capacitor-plugins/blob/main/share/README.md The Share API allows your application to share content with other apps installed on the user's device. It supports sharing text, URLs, and files, leveraging native sharing capabilities on iOS and Android, and the Web Share API on the web. ```APIDOC ## Share API The Share API provides methods for sharing content in any sharing-enabled apps the user may have installed. It works on iOS, Android, and the Web (using the new [Web Share API](https://web.dev/web-share/)), though web support is currently spotty. ### Install ```bash npm install @capacitor/share npx cap sync ``` ### Android Configuration By default, Capacitor apps only allow sharing files from the cache folder. To make other Android folders shareable, they must be added to the `android/app/src/main/res/xml/file_paths.xml` file. Refer to the [FileProvider docs](https://developer.android.com/reference/androidx/core/content/FileProvider) for available locations. ## API Reference ### canShare() Checks if the sharing functionality is supported on the current platform. #### Method ```typescript canShare(): Promise ``` #### Returns - **Promise<CanShareResult>**: A promise that resolves with an object containing a `value` property indicating whether sharing is supported. #### Since 1.1.0 ### share(...) Displays a share modal to allow users to share content with other applications. #### Method ```typescript share(options: ShareOptions): Promise ``` #### Parameters ##### Path Parameters This method does not have path parameters. ##### Query Parameters This method does not have query parameters. ##### Request Body - **options** (ShareOptions) - Required - An object containing the content to share. #### Request Example ```typescript import { Share } from '@capacitor/share'; // Share title, text, and URL await Share.share({ title: 'See cool stuff', text: 'Really awesome thing you need to see right meow', url: 'http://ionicframework.com/', dialogTitle: 'Share with buddies', // Android only }); // Share text only await Share.share({ text: 'Really awesome thing you need to see right meow', }); // Share URL only await Share.share({ url: 'http://ionicframework.com/', }); // Share local file using url parameter (e.g., a photo) const photo = await Camera.getPhoto(options); await Share.share({ url: photo.path, }); // Share multiple files using files parameter (iOS and Android only) const { photos } = await Camera.pickImages(options); await Share.share({ files: photos.map(photo => photo.path!), }); ``` #### Response ##### Success Response (200) - **activityType** (string) - Identifier of the app that received the share action. Can be an empty string in some cases. On web it will be undefined. #### Response Example ```json { "activityType": "com.apple.UIKit.activity.PostToTwitter" } ``` #### Since 1.0.0 ### Interfaces #### CanShareResult | Prop | Type | Description | | --------- | ------- | ----------------------------------- | | **`value`** | boolean | Whether sharing is supported or not. | #### ShareResult | Prop | Type | Description | | ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------ | | **`activityType`** | string | Identifier of the app that received the share action. Can be an empty string in some cases. On web it will be undefined. | #### ShareOptions | Prop | Type | Description | | ----------------- | -------- | ----------------------------------------------------------------------------------- | | **`title`** | string | Set a title for any message. This will be the subject if sharing to email. | | **`text`** | string | Set some text to share. | | **`url`** | string | Set a URL to share, can be http, https or file:// URL. | | **`files`** | string[] | Array of file:// URLs of the files to be shared. Only supported on iOS and Android. | | **`dialogTitle`** | string | Set a title for the share modal. This option is only supported on Android. | ``` -------------------------------- ### getAppLanguage() Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Get the app specific language locale code. ```APIDOC ## getAppLanguage() ### Description Get the app specific language locale code. ### Method GET ### Endpoint /getAppLanguage ### Response #### Success Response (200) - **AppLanguageCode** (string) - The app specific language locale code. ``` -------------------------------- ### show() Source: https://github.com/ionic-team/capacitor-plugins/blob/main/toast/README.md Displays a toast notification on the screen with specified options. ```APIDOC ## show() ### Description Shows a Toast on the screen. ### Parameters #### Request Body - **text** (string) - Required - Text to display on the Toast - **duration** ('short' | 'long') - Optional - Duration of the Toast, either 'short' (2000ms) or 'long' (3500ms). Default: 'short' - **position** ('top' | 'center' | 'bottom') - Optional - Position of the Toast. On Android 12 and newer all toasts are shown at the bottom. Default: 'bottom' ### Request Example { "text": "Hello!", "duration": "short", "position": "bottom" } ### Response #### Success Response (200) - **void** - Returns a promise that resolves when the toast is shown. ``` -------------------------------- ### Configuration Options Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Overview of available configuration options for the StatusBar plugin, including their types, descriptions, defaults, and version support. ```APIDOC ## Configuration These config values are available: | Prop | Type | Description | | --------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | **`overlaysWebView`** | boolean | Whether the statusbar is overlaid or not. Not available on Android 15+. | **`style`** | string | Style of the text of the status bar. | **`backgroundColor`** | string | Color of the background of the statusbar in hex format, #RRGGBB. Doesn't work if `overlaysWebView` is true. Not available on Android 15+. ### Examples In `capacitor.config.json`: ```json { "plugins": { "StatusBar": { "overlaysWebView": false, "style": "DARK", "backgroundColor": "#ffffffff" } } } ``` In `capacitor.config.ts`: ```ts /// import { CapacitorConfig } from '@capacitor/cli'; const config: CapacitorConfig = { plugins: { StatusBar: { overlaysWebView: false, style: "DARK", backgroundColor: "#ffffffff", }, }, }; export default config; ``` ``` -------------------------------- ### Write and Read from Clipboard Source: https://github.com/ionic-team/capacitor-plugins/blob/main/clipboard/README.md Demonstrates how to write a string to the system clipboard and read data from it. Ensure the necessary imports are included. ```typescript import { Clipboard } from '@capacitor/clipboard'; const writeToClipboard = async () => { await Clipboard.write({ string: "Hello World!" }); }; const checkClipboard = async () => { const { type, value } = await Clipboard.read(); console.log(`Got ${type} from clipboard: ${value}`); }; ``` -------------------------------- ### Get Status Bar Info Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Retrieves the current state information of the status bar. ```typescript getInfo() => Promise ``` -------------------------------- ### Open Browser Method Source: https://github.com/ionic-team/capacitor-plugins/blob/main/browser/README.md Opens a browser window with the provided configuration options. ```typescript open(options: OpenOptions) => Promise ``` -------------------------------- ### Get Current Zoom Level Source: https://github.com/ionic-team/capacitor-plugins/blob/main/text-zoom/README.md Retrieve the current zoom level as a decimal value. ```typescript get() => Promise ``` -------------------------------- ### Get Current App State Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Retrieve the current state of the application (e.g., active or inactive). ```typescript getState() => Promise ``` -------------------------------- ### Get Current Screen Orientation Source: https://github.com/ionic-team/capacitor-plugins/blob/main/screen-orientation/README.md Retrieve the current screen orientation. Available since 4.0.0. ```typescript orientation() ``` -------------------------------- ### getLaunchUrl() Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Retrieves the URL used to launch the application, if applicable. ```APIDOC ## getLaunchUrl() ### Description Get the URL the app was launched with, if any. ### Method Promise ### Response #### Success Response (200) - **AppLaunchUrl** (object) - The URL object or undefined if the app was not launched via a URL. ``` -------------------------------- ### Link local plugin and core packages Source: https://github.com/ionic-team/capacitor-plugins/blob/main/CONTRIBUTING.md Configures an app to use local paths for Capacitor plugins and core packages. ```shell cd my-app/ npm install ../path/to/capacitor-plugins/ npm install ../path/to/capacitor/core npm install ../path/to/capacitor/android npm install ../path/to/capacitor/ios ``` -------------------------------- ### migrate() Source: https://github.com/ionic-team/capacitor-plugins/blob/main/preferences/README.md Migrates data from the Capacitor 2 Storage plugin. ```APIDOC ## migrate() ### Description Migrate data from the Capacitor 2 Storage plugin. This action is non-destructive. ``` -------------------------------- ### Get Preferred Zoom Level Source: https://github.com/ionic-team/capacitor-plugins/blob/main/text-zoom/README.md Retrieve the user's preferred zoom level as a decimal value. ```typescript getPreferred() => Promise ``` -------------------------------- ### addListener('networkStatusChange', ...) Source: https://github.com/ionic-team/capacitor-plugins/blob/main/network/README.md Listen for changes in the network connection. ```APIDOC ## addListener('networkStatusChange', ...) ### Description Listen for changes in the network connection. ### Parameters #### Request Body - **eventName** ('networkStatusChange') - Required - The event name to listen for. - **listenerFunc** (ConnectionStatusChangeListener) - Required - Callback to receive the status change notifications. ### Response #### Success Response (200) - **remove** (Function) - A function to remove the listener. ``` -------------------------------- ### Get Delivered Notifications Source: https://github.com/ionic-team/capacitor-plugins/blob/main/push-notifications/README.md Retrieves a list of notifications that are currently displayed on the device's notification screen. ```typescript getDeliveredNotifications() => Promise ``` -------------------------------- ### API Methods Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Reference for all available methods in the StatusBar API, including descriptions and parameters. ```APIDOC ## API * [`setStyle(...)`](#setstyle) * [`setBackgroundColor(...)`](#setbackgroundcolor) * [`show(...)`](#show) * [`hide(...)`](#hide) * [`getInfo()`](#getinfo) * [`setOverlaysWebView(...)`](#setoverlayswebview) * [`addListener('statusBarVisibilityChanged', ...)`](#addlistenerstatusbarvisibilitychanged-) * [`addListener('statusBarOverlayChanged', ...)`](#addlistenerstatusbaroverlaychanged-) * [Interfaces](#interfaces) * [Type Aliases](#type-aliases) * [Enums](#enums) ``` -------------------------------- ### Toggle local Capacitor dependencies Source: https://github.com/ionic-team/capacitor-plugins/blob/main/CONTRIBUTING.md Switches plugins to use a local copy of Capacitor. ```shell npm install npm run toggle-local ``` -------------------------------- ### Get App Language Code Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Retrieves the app-specific language locale code. Returns a Promise that resolves with an AppLanguageCode. ```typescript getAppLanguage() => Promise ``` -------------------------------- ### getInfo() Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Retrieves information about the current application. ```APIDOC ## getInfo() ### Description Return information about the app. ### Method Promise ### Response #### Success Response (200) - **AppInfo** (object) - An object containing application metadata. ``` -------------------------------- ### addListener('resume') Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Listen for when the app or activity are resumed. ```APIDOC ## addListener('resume') ### Description Listen for when the app or activity are resumed. ### Method POST ### Endpoint /addListener ### Parameters #### Request Body - **eventName** ('resume') - Required - The event to listen for. - **listenerFunc** (function) - Required - The callback function to execute. ``` -------------------------------- ### Get Pending Local Notifications Source: https://github.com/ionic-team/capacitor-plugins/blob/main/local-notifications/README.md Retrieve a list of all currently pending local notifications. Returns a Promise resolving to PendingResult. ```typescript getPending() => Promise ``` -------------------------------- ### Get Current Network Status Source: https://github.com/ionic-team/capacitor-plugins/blob/main/network/README.md Asynchronously retrieve the current network connection status. This requires the Network API to be imported. ```typescript import { Network } from '@capacitor/network'; const logCurrentNetworkStatus = async () => { const status = await Network.getStatus(); console.log('Network status:', status); }; ``` -------------------------------- ### show Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Shows the status bar. ```APIDOC ## show ### Description Show the status bar. On iOS, it is recommended to use Animation.None on the first call to avoid potential glitches. ### Parameters #### Request Body - **options** (AnimationOptions) - Optional - The animation configuration. ``` -------------------------------- ### ShowActionsOptions Interface Source: https://github.com/ionic-team/capacitor-plugins/blob/main/action-sheet/README.md Configuration options for displaying an action sheet, including title, message, and button options. ```APIDOC ## ShowActionsOptions ### Description Defines the configuration for the Action Sheet display. ### Parameters - **title** (string) - Required - The title of the Action Sheet. - **message** (string) - Optional - A message to show under the title. Supported on iOS only. - **options** (ActionSheetButton[]) - Required - Options the user can choose from. - **cancelable** (boolean) - Optional - If true, the Action Sheet is canceled when clicked outside. Default: false. ``` -------------------------------- ### Configure Foreground Notification Presentation Options (TypeScript) Source: https://github.com/ionic-team/capacitor-plugins/blob/main/push-notifications/README.md Configure push notification presentation options in the foreground using TypeScript in your `capacitor.config.ts` file. Ensure you have the necessary type references. ```typescript /// import { CapacitorConfig } from '@capacitor/cli'; const config: CapacitorConfig = { plugins: { PushNotifications: { presentationOptions: ["badge", "sound", "alert", "banner", "list"], }, }, }; export default config; ``` -------------------------------- ### keys() Source: https://github.com/ionic-team/capacitor-plugins/blob/main/preferences/README.md Returns the list of known keys in preferences. ```APIDOC ## keys() ### Description Return the list of known keys in preferences. ### Response #### Success Response (200) - **keys** (string[]) - The known keys in preferences. ``` -------------------------------- ### Get Network Status Function Signature Source: https://github.com/ionic-team/capacitor-plugins/blob/main/network/README.md The getStatus function queries the current network connection status and returns a Promise resolving to a ConnectionStatus object. ```typescript getStatus() => Promise ``` -------------------------------- ### Listen for app URL open events Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Handles custom URL schemes and Universal/App Links. Use this to respond to deep links. ```typescript addListener(eventName: 'appUrlOpen', listenerFunc: URLOpenListener) => Promise ``` -------------------------------- ### Get Current Zoom Level Source: https://github.com/ionic-team/capacitor-plugins/blob/main/text-zoom/README.md Retrieves the current text zoom level of the web view. The zoom level is returned as a decimal value, where 1.0 represents 100% zoom. ```APIDOC ## GET /text-zoom/get ### Description Get the current zoom level. ### Method GET ### Endpoint /text-zoom/get ### Response #### Success Response (200) - **value** (number) - The current zoom level (represented as a decimal). ### Response Example ```json { "value": 1.2 } ``` ``` -------------------------------- ### addListener('screenOrientationChange', ...) Source: https://github.com/ionic-team/capacitor-plugins/blob/main/screen-orientation/README.md Listens for screen orientation changes. ```APIDOC ## addListener('screenOrientationChange', ...) ### Description Listens for screen orientation changes. ### Parameters #### Path Parameters - **eventName** (string) - Required - Must be 'screenOrientationChange' - **listenerFunc** (function) - Required - Callback function receiving ScreenOrientationResult ``` -------------------------------- ### Get Preferred Zoom Level Source: https://github.com/ionic-team/capacitor-plugins/blob/main/text-zoom/README.md Retrieves the user's preferred text zoom level. This reflects the system's accessibility settings. The zoom level is returned as a decimal value. ```APIDOC ## GET /text-zoom/getPreferred ### Description Get the preferred zoom level. ### Method GET ### Endpoint /text-zoom/getPreferred ### Response #### Success Response (200) - **value** (number) - The preferred zoom level (represented as a decimal). ### Response Example ```json { "value": 1.5 } ``` ``` -------------------------------- ### Check sharing support Source: https://github.com/ionic-team/capacitor-plugins/blob/main/share/README.md Method to verify if the current environment supports sharing. ```typescript canShare() => Promise ``` -------------------------------- ### iOS Configuration Note Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Information regarding iOS specific configuration, including `UIViewControllerBasedStatusBarAppearance` and `Info.plist` settings. ```APIDOC ## iOS Note This plugin requires "View controller-based status bar appearance" (`UIViewControllerBasedStatusBarAppearance`) set to `YES` in `Info.plist`. Read about [Configuring iOS](https://capacitorjs.com/docs/ios/configuration) for help. The status bar visibility defaults to visible and the style defaults to `Style.Default`. You can change these defaults by adding `UIStatusBarHidden` and/or `UIStatusBarStyle` in `Info.plist`. ``` -------------------------------- ### register() Source: https://github.com/ionic-team/capacitor-plugins/blob/main/push-notifications/README.md Registers the application to receive push notifications. This method should be called after requesting permissions. It triggers a 'registration' event with the push token or 'registrationError' if an issue occurs. ```APIDOC ## register() ### Description Register the app to receive push notifications. This method will trigger the 'registration' event with the push token or 'registrationError' if there was a problem. It does not prompt the user for notification permissions, use `requestPermissions()` first. ### Method ```typescript register() => Promise ``` ### Since 1.0.0 ``` -------------------------------- ### addListener('appStateChange') Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Listen for changes in the app or the activity states. ```APIDOC ## addListener('appStateChange') ### Description Listen for changes in the app or the activity states. ### Method POST ### Endpoint /addListener ### Parameters #### Request Body - **eventName** ('appStateChange') - Required - The event to listen for. - **listenerFunc** (StateChangeListener) - Required - The callback function to execute. ``` -------------------------------- ### Show a Toast Notification Source: https://github.com/ionic-team/capacitor-plugins/blob/main/toast/README.md Import the Toast API and use the `show` method to display a message. Requires PWA Elements for web. ```typescript import { Toast } from '@capacitor/toast'; const showHelloToast = async () => { await Toast.show({ text: 'Hello!', }); }; ``` -------------------------------- ### AppLaunchUrl Properties Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Properties related to the URL used to open the app. ```APIDOC ## AppLaunchUrl ### Description Properties related to the URL used to open the app. ### Parameters #### Request Body - **`url`** (string) - Required - The url used to open the app. ``` -------------------------------- ### orientation() Source: https://github.com/ionic-team/capacitor-plugins/blob/main/screen-orientation/README.md Returns the current screen orientation. ```APIDOC ## orientation() ### Description Returns the current screen orientation. ### Method GET ### Response #### Success Response (200) - **type** (OrientationType) - The current orientation type. ``` -------------------------------- ### StyleOptions Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Options for setting the style of the status bar text. ```APIDOC ## StyleOptions ### Description Options for setting the style of the status bar text. ### Parameters #### Request Body - **style** (Style) - Required - Style of the text of the status bar. ### Request Example ```json { "style": "DARK" } ``` ### Response #### Success Response (200) - **style** (Style) - The current status bar style. #### Response Example ```json { "style": "DARK" } ``` ``` -------------------------------- ### ConfirmOptions Interface Source: https://github.com/ionic-team/capacitor-plugins/blob/main/dialog/README.md Configuration options for the confirm dialog. ```APIDOC ## ConfirmOptions ### Description Configuration object for the confirm dialog. ### Parameters - **title** (string) - Optional - Title of the dialog. - **message** (string) - Optional - Message to show on the dialog. - **okButtonTitle** (string) - Optional - Text to use on the positive action button. Default: "OK". - **cancelButtonTitle** (string) - Optional - Text to use on the negative action button. Default: "Cancel". ``` -------------------------------- ### openUrl Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app-launcher/README.md Opens an external application using the provided URL scheme or package name. ```APIDOC ## openUrl ### Description Open an app with the given URL. On iOS, the URL should be a known URL scheme. On Android, the URL can be a known URL scheme or an app package name. ### Parameters #### Request Body - **url** (string) - Required - The URL scheme or package name to open. ### Response #### Success Response (200) - **completed** (boolean) - Returns true if the operation was successful. ``` -------------------------------- ### addListener('statusBarOverlayChanged') Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Registers a listener for status bar overlay changes. ```APIDOC ## addListener('statusBarOverlayChanged') ### Description Listen for status bar overlay changes. Fired when setOverlaysWebView gets called. ### Parameters #### Request Body - **eventName** (string) - Required - 'statusBarOverlayChanged' - **listenerFunc** (OverlayChangeListener) - Required - The callback function. ``` -------------------------------- ### ImageOptions Configuration Source: https://github.com/ionic-team/capacitor-plugins/blob/main/camera/README.md Defines the configuration object used to customize image capture and selection behavior. ```APIDOC ## ImageOptions Configuration ### Description Configuration object for controlling image capture and selection settings. ### Request Body - **quality** (number) - Optional - The quality of image to return as JPEG, from 0-100 (Android/iOS only). - **allowEditing** (boolean) - Optional - Whether to allow the user to crop or make small edits. - **resultType** (CameraResultType) - Optional - How the data should be returned ('Base64', 'DataUrl', or 'Uri'). - **saveToGallery** (boolean) - Optional - Whether to save the photo to the gallery (Default: false). - **width** (number) - Optional - The desired maximum width of the saved image. - **height** (number) - Optional - The desired maximum height of the saved image. - **correctOrientation** (boolean) - Optional - Whether to automatically rotate the image to correct orientation (Default: true). - **source** (CameraSource) - Optional - The source to get the photo from (Default: CameraSource.Prompt). - **direction** (CameraDirection) - Optional - The camera direction (iOS and Web only, Default: CameraDirection.Rear). - **presentationStyle** ('fullscreen' | 'popover') - Optional - The presentation style of the Camera (iOS only, Default: 'fullscreen'). ### Request Example { "quality": 90, "allowEditing": true, "resultType": "Uri", "saveToGallery": false, "width": 800, "height": 600, "correctOrientation": true, "source": "CameraSource.Camera", "direction": "CameraDirection.Rear", "presentationStyle": "fullscreen" } ``` -------------------------------- ### iOS Custom URL Scheme Configuration Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Configure Info.plist on iOS to allow opening the app from a custom scheme. ```xml CFBundleURLTypes CFBundleURLName com.getcapacitor.capacitor CFBundleURLSchemes mycustomscheme ``` -------------------------------- ### set(options: SetOptions) Source: https://github.com/ionic-team/capacitor-plugins/blob/main/preferences/README.md Sets a value in preferences for a given key. ```APIDOC ## set(options: SetOptions) ### Description Set the value in preferences for a given key. ### Parameters #### Request Body - **options** (SetOptions) - Required - Object containing the key and value to set. ``` -------------------------------- ### Splash Screen Configuration Options Source: https://github.com/ionic-team/capacitor-plugins/blob/main/splash-screen/README.md These configuration values are available for the Splash Screen plugin. Update the source file JSDoc comments and rerun docgen to update the docs below. ```APIDOC ## Splash Screen Configuration ### Description Configuration options for the Capacitor Splash Screen plugin. ### Parameters #### Request Body - **`launchShowDuration`** (number) - Optional - How long to show the launch splash screen when autoHide is enabled (in ms). Default: `500`. - **`launchAutoHide`** (boolean) - Optional - Whether to auto hide the splash after launchShowDuration. Default: `true`. - **`launchFadeOutDuration`** (number) - Optional - Duration for the fade out animation of the launch splash screen (in ms). Only available for Android, when using the Android 12 Splash Screen API. Default: `200`. - **`backgroundColor`** (string) - Optional - Color of the background of the Splash Screen in hex format, #RRGGBB or #RRGGBBAA. Doesn't work if `useDialog` is true or on launch when using the Android 12 API. - **`androidSplashResourceName`** (string) - Optional - Name of the resource to be used as Splash Screen. Doesn't work on launch when using the Android 12 API. Only available on Android. Default: `splash`. - **`androidScaleType`** (string) - Optional - The [ImageView.ScaleType](https://developer.android.com/reference/android/widget/ImageView.ScaleType) used to scale the Splash Screen image. Doesn't work if `useDialog` is true or on launch when using the Android 12 API. Only available on Android. Possible values: `'CENTER' | 'CENTER_CROP' | 'CENTER_INSIDE' | 'FIT_CENTER' | 'FIT_END' | 'FIT_START' | 'FIT_XY' | 'MATRIX'`. Default: `FIT_XY`. - **`showSpinner`** (boolean) - Optional - Show a loading spinner on the Splash Screen. Doesn't work if `useDialog` is true or on launch when using the Android 12 API. - **`androidSpinnerStyle`** (string) - Optional - Style of the Android spinner. Doesn't work if `useDialog` is true or on launch when using the Android 12 API. Possible values: `'horizontal' | 'small' | 'large' | 'inverse' | 'smallInverse' | 'largeInverse'`. Default: `large`. ### Request Example ```json { "launchShowDuration": 1000, "launchAutoHide": true, "backgroundColor": "#FFFFFF", "androidScaleType": "CENTER_INSIDE" } ``` ### Response This configuration does not have a success response body as it is applied during the app's initialization. ``` -------------------------------- ### getState() Source: https://github.com/ionic-team/capacitor-plugins/blob/main/app/README.md Retrieves the current state of the application. ```APIDOC ## getState() ### Description Gets the current app state. ### Method Promise ### Response #### Success Response (200) - **AppState** (object) - An object representing the current state of the app. ``` -------------------------------- ### Request Permissions and Listen for Motion Source: https://github.com/ionic-team/capacitor-plugins/blob/main/motion/README.md Request device motion permissions and set up listeners for accelerometer data. ```typescript import { PluginListenerHandle } from '@capacitor/core'; import { Motion } from '@capacitor/motion'; let accelHandler: PluginListenerHandle; myButton.addEventListener('click', async () => { try { await DeviceMotionEvent.requestPermission(); } catch (e) { // Handle error return; } // Once the user approves, can start listening: accelHandler = await Motion.addListener('accel', event => { console.log('Device motion event:', event); }); }); // Stop the acceleration listener const stopAcceleration = () => { if (accelHandler) { accelHandler.remove(); } }; // Remove all listeners const removeListeners = () => { Motion.removeAllListeners(); }; ``` -------------------------------- ### addListener('registration', ...) Source: https://github.com/ionic-team/capacitor-plugins/blob/main/push-notifications/README.md Adds a listener for the 'registration' event, which is triggered when a push notification token is successfully obtained. ```APIDOC ## addListener('registration', ...) ### Description Adds a listener for the 'registration' event. This event is triggered when the app successfully registers for push notifications and receives a token. ### Method ```typescript addListener(type: 'registration', listenerFunc: (token: Token) => void) => Promise & PluginListenerHandle ``` ### Parameters #### Path Parameters - **`type`** ('registration') - Required - The type of event to listen for. - **`listenerFunc`** ((token: Token) => void) - Required - The callback function to execute when the event is triggered. ### Since 1.0.0 ``` -------------------------------- ### PluginListenerHandle Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Handle for managing plugin listeners. ```APIDOC ## PluginListenerHandle ### Description Handle for managing plugin listeners. ### Methods #### remove Removes the listener. ### Response #### Success Response (200) - **remove** (Promise) - A promise that resolves when the listener is removed. #### Response Example ```json { "remove": "() => Promise" } ``` ``` -------------------------------- ### getInfo Source: https://github.com/ionic-team/capacitor-plugins/blob/main/status-bar/README.md Retrieves information about the current status bar state. ```APIDOC ## getInfo ### Description Get info about the current state of the status bar. ### Response #### Success Response (200) - **StatusBarInfo** (Object) - The current status bar information. ```