@capacitor/core

  • Version 7.0.1
  • Published
  • 347 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

variable Capacitor

const Capacitor: CapacitorGlobal;

    variable CapacitorCookies

    const CapacitorCookies: CapacitorCookiesPlugin;

      variable CapacitorHttp

      const CapacitorHttp: CapacitorHttpPlugin;

        variable registerPlugin

        const registerPlugin: RegisterPlugin;

          variable WebView

          const WebView: WebViewPlugin;

            Functions

            function buildRequestInit

            buildRequestInit: (options: HttpOptions, extra?: RequestInit) => RequestInit;
            • Build the RequestInit object based on the options passed into the initial request

              Parameter options

              The Http plugin options

              Parameter extra

              Any extra RequestInit values

            Classes

            class CapacitorException

            class CapacitorException extends Error {}

              constructor

              constructor(message: string, code?: ExceptionCode, data?: ExceptionData);

                property code

                readonly code?: ExceptionCode;

                  property data

                  readonly data?: ExceptionData;

                    property message

                    readonly message: string;

                      class WebPlugin

                      class WebPlugin implements Plugin {}
                      • Base class web plugins should extend.

                      property listeners

                      protected listeners: { [eventName: string]: ListenerCallback[] };

                        property retainedEventArguments

                        protected retainedEventArguments: { [eventName: string]: any[] };

                          property windowListeners

                          protected windowListeners: { [eventName: string]: WindowListenerHandle };

                            method addListener

                            addListener: (
                            eventName: string,
                            listenerFunc: ListenerCallback
                            ) => Promise<PluginListenerHandle>;

                              method hasListeners

                              protected hasListeners: (eventName: string) => boolean;

                                method notifyListeners

                                protected notifyListeners: (
                                eventName: string,
                                data: any,
                                retainUntilConsumed?: boolean
                                ) => 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 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, or web.

                                              property isLoggingEnabled

                                              isLoggingEnabled?: boolean;

                                                property isNativePlatform

                                                isNativePlatform: () => boolean;
                                                • Boolean if the platform is native or not. android and ios would return true, otherwise false.

                                                property isPluginAvailable

                                                isPluginAvailable: (name: string) => boolean;
                                                • Used to check if a platform is registered and available.

                                                property registerPlugin

                                                registerPlugin: RegisterPlugin;

                                                  property removeListener

                                                  removeListener?: (
                                                  pluginName: string,
                                                  callbackId: string,
                                                  eventName: string,
                                                  callback: PluginCallback
                                                  ) => void;
                                                  • Remove a listener to a plugin event.

                                                  interface HttpHeaders

                                                  interface HttpHeaders {}

                                                    index signature

                                                    [key: string]: string;
                                                    • A key/value dictionary of Http headers.

                                                    interface HttpOptions

                                                    interface HttpOptions {}

                                                      property connectTimeout

                                                      connectTimeout?: number;
                                                      • How long to wait for the initial connection in milliseconds.

                                                      property data

                                                      data?: any;
                                                      • Note: On Android and iOS, data can only be a string or a JSON. FormData, Blob, ArrayBuffer, and other complex types are only directly supported on web or through enabling CapacitorHttp in the config and using the patched window.fetch or XMLHttpRequest.

                                                        If you need to send a complex type, you should serialize the data to base64 and set the headers["Content-Type"] and dataType attributes accordingly.

                                                      property dataType

                                                      dataType?: 'file' | 'formData';
                                                      • This is used if we've had to convert the data from a JS type that needs special handling in the native layer

                                                      property disableRedirects

                                                      disableRedirects?: boolean;
                                                      • Sets whether automatic HTTP redirects should be disabled

                                                      property headers

                                                      headers?: HttpHeaders;
                                                      • Http Request headers to send with the request.

                                                      property method

                                                      method?: string;
                                                      • The Http Request method to run. (Default is GET)

                                                      property params

                                                      params?: HttpParams;
                                                      • URL parameters to append to the request.

                                                      property readTimeout

                                                      readTimeout?: number;
                                                      • How long to wait to read additional data in milliseconds. Resets each time new data is received.

                                                      property responseType

                                                      responseType?: HttpResponseType;
                                                      • This is used to parse the response appropriately before returning it to the requestee. If the response content-type is "json", this value is ignored.

                                                      property shouldEncodeUrlParams

                                                      shouldEncodeUrlParams?: boolean;
                                                      • Use this option if you need to keep the URL unencoded in certain cases (already encoded, azure/firebase testing, etc.). The default is _true_.

                                                      property url

                                                      url: string;
                                                      • The URL to send the request to.

                                                      property webFetchExtra

                                                      webFetchExtra?: RequestInit;
                                                      • Extra arguments for fetch when running on the web

                                                      interface HttpParams

                                                      interface HttpParams {}

                                                        index signature

                                                        [key: string]: string | string[];
                                                        • A key/value dictionary of URL parameters to set.

                                                        interface HttpResponse

                                                        interface HttpResponse {}

                                                          property data

                                                          data: any;
                                                          • Additional data received with the Http response.

                                                          property headers

                                                          headers: HttpHeaders;
                                                          • The headers received from the Http response.

                                                          property status

                                                          status: number;
                                                          • The status code received from the Http response.

                                                          property url

                                                          url: string;
                                                          • The response URL recieved from the Http response.

                                                          interface Plugin

                                                          interface Plugin {}

                                                            method addListener

                                                            addListener: (
                                                            eventName: string,
                                                            listenerFunc: (...args: any[]) => any
                                                            ) => Promise<PluginListenerHandle>;

                                                              method removeAllListeners

                                                              removeAllListeners: () => Promise<void>;

                                                                interface PluginListenerHandle

                                                                interface PluginListenerHandle {}

                                                                  property remove

                                                                  remove: () => Promise<void>;

                                                                    interface PluginResultData

                                                                    interface PluginResultData {}

                                                                      index signature

                                                                      [key: string]: any;

                                                                        interface PluginResultError

                                                                        interface PluginResultError {}

                                                                          property message

                                                                          message: string;

                                                                            interface WebViewPath

                                                                            interface WebViewPath {}

                                                                              property path

                                                                              path: string;

                                                                                interface WebViewPlugin

                                                                                interface WebViewPlugin extends Plugin {}
                                                                                • ****** WEB VIEW PLUGIN *******

                                                                                method getServerBasePath

                                                                                getServerBasePath: () => Promise<WebViewPath>;

                                                                                  method persistServerBasePath

                                                                                  persistServerBasePath: () => Promise<void>;

                                                                                    method setServerAssetPath

                                                                                    setServerAssetPath: (options: WebViewPath) => 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 ClearCookieOptions

                                                                                          type ClearCookieOptions = Omit<HttpCookie, 'key' | 'value'>;

                                                                                            type DeleteCookieOptions

                                                                                            type DeleteCookieOptions = Omit<HttpCookie, 'value'>;

                                                                                              type HttpResponseType

                                                                                              type HttpResponseType = 'arraybuffer' | 'blob' | 'json' | 'text' | 'document';
                                                                                              • How to parse the Http response before returning it to the client.

                                                                                              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.

                                                                                                    type SetCookieOptions

                                                                                                    type SetCookieOptions = HttpCookie & HttpCookieExtras;

                                                                                                      Package Files (6)

                                                                                                      Dependencies (1)

                                                                                                      Dev Dependencies (11)

                                                                                                      Peer Dependencies (0)

                                                                                                      No peer dependencies.

                                                                                                      Badge

                                                                                                      To add a badge like this onejsDocs.io badgeto 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
                                                                                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](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>