@cap-kit/test-plugin
v1.0.3
Published
Architectural reference and boilerplate for Cap-Kit plugins.
Readme
Install
pnpm add @cap-kit/test-plugin
npx cap sync
Configuration
Configuration options for the Test plugin.
| Prop | Type | Description | Default | Since |
| -------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | ----- |
| customMessage | string | Custom message appended to the echoed value. This option exists mainly as an example showing how to pass static configuration data from JavaScript to native platforms. | " (from config)" | 0.0.1 |
| verboseLogging | boolean | Enables verbose native logging. When enabled, additional debug information is printed to the native console (Logcat on Android, Xcode on iOS). This option affects native logging behavior only and has no impact on the JavaScript API. | false | 1.0.0 |
Examples
In capacitor.config.json:
{
"plugins": {
"Test": {
"customMessage": " - Hello from Config!",
"verboseLogging": true
}
}
}In capacitor.config.ts:
/// <reference types="@cap-kit/test-plugin" />
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
Test: {
customMessage: ' - Hello from Config!',
verboseLogging: true,
},
},
};
export default config;API
Public JavaScript API for the Test Capacitor plugin.
This interface defines a stable, platform-agnostic API. All methods behave consistently across Android, iOS, and Web.
echo(...)
echo(options: EchoOptions) => Promise<EchoResult>Echoes the provided value.
If the plugin is configured with a customMessage, that value
will be appended to the returned string.
This method is primarily intended as an example demonstrating native ↔ JavaScript communication.
| Param | Type | Description |
| ------------- | --------------------------------------------------- | ------------------------------------ |
| options | EchoOptions | Object containing the value to echo. |
Returns: Promise<EchoResult>
Since: 0.0.1
Example
const { value } = await Test.echo({ value: 'Hello' });
console.log(value);openAppSettings()
openAppSettings() => Promise<void>Opens the operating system's application settings page.
This is typically used when a permission has been permanently denied and the user must enable it manually.
On Web, this method is not supported.
Since: 1.0.0
getPluginVersion()
getPluginVersion() => Promise<PluginVersionResult>Returns the native plugin version.
The returned version corresponds to the native implementation bundled with the application.
Returns: Promise<PluginVersionResult>
Since: 0.0.1
Example
const { version } = await Test.getPluginVersion();Interfaces
EchoResult
Result object returned by the echo method.
This object represents the resolved value of the echo operation after native processing has completed.
| Prop | Type | Description |
| ----------- | ------------------- | ------------------------------------------------------------------------------------------------------------- |
| value | string | The echoed string value. If a customMessage is configured, it will be appended to the original input value. |
EchoOptions
Options object for the echo method.
This object defines the input payload sent from JavaScript to the native plugin implementation.
| Prop | Type | Description |
| ----------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| value | string | The string value to be echoed back by the plugin. This value is passed to the native layer and returned unchanged, optionally with a configuration-based suffix. |
PluginVersionResult
Result object returned by the getPluginVersion() method.
| Prop | Type | Description |
| ------------- | ------------------- | --------------------------------- |
| version | string | The native plugin version string. |
Contributing
Contributions are welcome! Please read the contributing guide before submitting a pull request.
Credits
This plugin is based on prior work from the Community and has been refactored and modernized for Capacitor v8 and Swift Package Manager compatibility.
Original inspiration:
License
MIT
