Capacitor custom plugin

yotube
0

 IOS


https://capacitorjs.com/docs/ios/custom-code


Create EchoPlugin.swift and EchoPlugin.m files

Use the Plugin



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);
)



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));
});

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top