@capacitor/core
- Version 3.5.1
- Published
- 219 kB
- 1 dependency
- MIT license
Install
npm i @capacitor/core
yarn add @capacitor/core
pnpm add @capacitor/core
Overview
Capacitor: Cross-platform apps with JavaScript and the web
Index
Variables
Functions
Classes
Interfaces
Enums
Type Aliases
Variables
variable Capacitor
const Capacitor: CapacitorGlobal;
variable CapacitorPlatforms
const CapacitorPlatforms: CapacitorPlatformsInstance;
Deprecated
Set
CapacitorCustomPlatform
on the window object prior to runtime executing in the web app instead
variable Plugins
const Plugins: PluginRegistry;
Deprecated
Provided for backwards compatibility for Capacitor v2 plugins. Capacitor v3 plugins should import the plugin directly. This "Plugins" export is deprecated in v3, and will be removed in v4.
variable registerPlugin
const registerPlugin: RegisterPlugin;
variable WebView
const WebView: WebViewPlugin;
Functions
function addPlatform
addPlatform: (name: string, platform: CapacitorPlatform) => void;
Deprecated
Set
CapacitorCustomPlatform
on the window object prior to runtime executing in the web app instead
function registerWebPlugin
registerWebPlugin: (plugin: WebPlugin) => void;
Provided for backwards compatibility. Use the registerPlugin() API instead, and provide the web plugin as the "web" implmenetation. For example
export const Example = registerPlugin('Example', { web: () => import('./web').then(m => new m.Example()) })
Deprecated
Deprecated in v3, will be removed from v4.
function setPlatform
setPlatform: (name: string) => void;
Deprecated
Set
CapacitorCustomPlatform
on the window object prior to runtime executing in the web app instead
Classes
class CapacitorException
class CapacitorException extends Error {}
constructor
constructor(message: string, code?: ExceptionCode);
property code
readonly code?: ExceptionCode;
property message
readonly message: string;
class WebPlugin
class WebPlugin implements Plugin {}
Base class web plugins should extend.
constructor
constructor(config?: WebPluginConfig);
property config
config?: WebPluginConfig;
Deprecated
WebPluginConfig deprecated in v3 and will be removed in v4.
property listeners
protected listeners: { [eventName: string]: ListenerCallback[] };
property windowListeners
protected windowListeners: { [eventName: string]: WindowListenerHandle };
method addListener
addListener: ( eventName: string, listenerFunc: ListenerCallback) => Promise<PluginListenerHandle> & PluginListenerHandle;
method hasListeners
protected hasListeners: (eventName: string) => boolean;
method notifyListeners
protected notifyListeners: (eventName: string, data: any) => void;
method registerWindowListener
protected registerWindowListener: ( windowEventName: string, pluginEventName: string) => void;
method removeAllListeners
removeAllListeners: () => Promise<void>;
method unavailable
protected unavailable: (msg?: string) => CapacitorException;
method unimplemented
protected unimplemented: (msg?: string) => CapacitorException;
Interfaces
interface CancellableCallback
interface CancellableCallback {}
CancellableCallback is a simple wrapper that a method will return to make it easy to cancel any repeated callback the method might have set up. For example: a geolocation watch.
Deprecated
property cancel
cancel: (...args: any[]) => any;
The cancel function for this method
Deprecated
interface CapacitorGlobal
interface CapacitorGlobal {}
property addListener
addListener?: ( pluginName: string, eventName: string, callback: PluginCallback) => PluginListenerHandle;
Add a listener for a plugin event.
property convertFileSrc
convertFileSrc: (filePath: string) => string;
Utility function to convert a file path into a usable src depending on the native WebView implementation value and environment.
property DEBUG
DEBUG?: boolean;
property Exception
Exception: typeof CapacitorException;
The Exception class used when generating plugin Exceptions from bridge calls.
property getPlatform
getPlatform: () => string;
Gets the name of the platform, such as
android
,ios
, orweb
.
property isLoggingEnabled
isLoggingEnabled?: boolean;
property isNative
isNative?: boolean;
Deprecated
Use
isNativePlatform()
instead
property isNativePlatform
isNativePlatform: () => boolean;
Boolean if the platform is native or not.
android
andios
would returntrue
, otherwisefalse
.
property isPluginAvailable
isPluginAvailable: (name: string) => boolean;
Used to check if a platform is registered and available.
property platform
platform?: string;
Deprecated
Use
getPlatform()
instead
property pluginMethodNoop
pluginMethodNoop: ( target: any, key: PropertyKey, pluginName: string) => Promise<never>;
Called when a plugin method is not available. Defaults to console logging a warning. Provided for backwards compatibility.
Deprecated
Deprecated in v3, will be removed from v4
property Plugins
Plugins: PluginRegistry;
Deprecated
Plugins should be imported instead. Deprecated in v3 and Capacitor.Plugins property definition will not be exported in v4.
property registerPlugin
registerPlugin: RegisterPlugin;
property removeListener
removeListener?: ( pluginName: string, callbackId: string, eventName: string, callback: PluginCallback) => void;
Remove a listener to a plugin event.
interface Plugin
interface Plugin {}
method addListener
addListener: ( eventName: string, listenerFunc: (...args: any[]) => any) => Promise<PluginListenerHandle>;
method removeAllListeners
removeAllListeners: () => Promise<void>;
interface PluginConfig
interface PluginConfig {}
Deprecated
interface PluginListenerHandle
interface PluginListenerHandle {}
property remove
remove: () => Promise<void>;
interface PluginRegistry
interface PluginRegistry {}
Deprecated
index signature
[pluginName: string]: { [prop: string]: any;};
interface PluginResultData
interface PluginResultData {}
index signature
[key: string]: any;
interface PluginResultError
interface PluginResultError {}
property message
message: string;
interface WebPluginConfig
interface WebPluginConfig {}
Deprecated
Deprecated in v3, removing in v4.
interface WebViewPath
interface WebViewPath {}
property path
path: string;
interface WebViewPlugin
interface WebViewPlugin extends Plugin {}
method getServerBasePath
getServerBasePath: () => Promise<WebViewPath>;
method persistServerBasePath
persistServerBasePath: () => Promise<void>;
method setServerBasePath
setServerBasePath: (options: WebViewPath) => Promise<void>;
Enums
enum ExceptionCode
enum ExceptionCode { Unimplemented = 'UNIMPLEMENTED', Unavailable = 'UNAVAILABLE',}
member Unavailable
Unavailable = 'UNAVAILABLE'
API is not available.
This means the API can't be used right now because: - it is currently missing a prerequisite, such as network connectivity - it requires a particular platform or browser version
member Unimplemented
Unimplemented = 'UNIMPLEMENTED'
API is not implemented.
This usually means the API can't be used because it is not implemented for the current platform.
Type Aliases
type CallbackID
type CallbackID = string;
Deprecated
type ISODateString
type ISODateString = string;
Deprecated
type ListenerCallback
type ListenerCallback = (err: any, ...args: any[]) => void;
type PermissionState
type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';
type PluginCallback
type PluginCallback = (data: PluginResultData, error?: PluginResultError) => void;
type PluginImplementations
type PluginImplementations = { [platform: string]: (() => Promise<any>) | any;};
A map of plugin implementations.
Each key should be the lowercased platform name as recognized by Capacitor, e.g. 'android', 'ios', and 'web'. Each value must be an instance of a plugin implementation for the respective platform.
Package Files (8)
Dependencies (1)
Dev Dependencies (8)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@capacitor/core
.
- Markdown[](https://www.jsdocs.io/package/@capacitor/core)
- HTML<a href="https://www.jsdocs.io/package/@capacitor/core"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 879 ms. - Missing or incorrect documentation? Open an issue for this package.