Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/plugins/creating-plugins/ios-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ This makes the `echo` method available to the Capacitor web runtime, indicating

To add more methods to your plugin, create them in the `.swift` plugin class with the `@objc` before the `func` keyword and add a new `CAPPluginMethod` entry in the `pluginMethods` array.

Capacitor currently exposes three `returnType` values in `ios/Capacitor/Capacitor/JSExport.swift` that control how the generated JavaScript proxies interact with native code:

- `CAPPluginReturnNone`: Use for fire-and-forget calls that neither resolve nor reject a JavaScript promise. The generated JS uses `nativeCallback` immediately and expects no further data.
- `CAPPluginReturnPromise`: The default. The generated JS returns a `Promise` that you must resolve or reject once per call.
- `CAPPluginReturnCallback`: Use when you want to push multiple updates back to the web side. Capacitor automatically appends a `_callback` argument to your method, and the generated JS keeps the callback alive until you explicitly finish.

## Permissions

If your plugin has functionality on iOS that requires permissions from the end user, then you will need to implement the permissions pattern.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ This makes the `echo` method available to the Capacitor web runtime, indicating

To add more methods to your plugin, create them in the `.swift` plugin class with the `@objc` before the `func` keyword and add a new `CAPPluginMethod` entry in the `pluginMethods` array.

Capacitor defines three `returnType` values in `ios/Capacitor/Capacitor/JSExport.swift`, and each one changes how the generated JavaScript wrapper calls into native code:

- `CAPPluginReturnNone`: fire-and-forget methods that return immediately through `nativeCallback` and do not keep a promise/callback open.
- `CAPPluginReturnPromise`: the standard promise-based bridge where you resolve or reject once per invocation.
- `CAPPluginReturnCallback`: for streaming data. Capacitor adds a `_callback` parameter to your Swift method and keeps the JavaScript callback alive until you finish.

## Permissions

If your plugin has functionality on iOS that requires permissions from the end user, then you will need to implement the permissions pattern.
Expand Down