IOS
https://capacitorjs.com/docs/ios/custom-code
Create EchoPlugin.swift and EchoPlugin.m files
Use the Plugin
1 Create EchoPlugin.swift and EchoPlugin.m files
EchoPlugin.swift
import Capacitor @objc(EchoPlugin)public class EchoPlugin: CAPPlugin { @objc func echo(_ call: CAPPluginCall) { let value = call.getString("value") ?? "" call.resolve(["value": value]) }}
EchoPlugin.m
#import <Capacitor/Capacitor.h>
CAP_PLUGIN(EchoPlugin, "Echo",
CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
)
2 Use the Plugin
import { Plugins } from '@capacitor/core';
const { EchoPlugin } = Plugins;
EchoPlugin.echo({ log: 'Echo Plugin call echo method' }).
then((result) => {
console.log('Resutl in ts: ' + JSON.stringify(result));
});