How to add some typescript logic to Capacitor plugin #7698
Unanswered
SpertsyanKM
asked this question in
Q&A
Replies: 1 comment
-
We do it for iOS on As for custom tyspescript you can check Google Maps plugin |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I’m looking to develop a Capacitor plugin that includes both native iOS and Android components, along with a TypeScript part for mapping and additional logic. From my review of the documentation and examples, it seems that all Capacitor plugins function as intermediaries for native methods, meaning that each time a plugin method is invoked, the call is routed directly to the corresponding native method.
My goal is to intercept these calls on the TypeScript side, perform some processing, invoke the native method myself, handle the response, and then return the result to the user. I attempted to customize the
registerPlugin
call like this:However, I found that all calls from Android still go directly to the native part, ignoring the
MySDKMob
class.If my current approach isn’t correct, I’m considering an alternative: creating an interface for communication with the native code, creating the plugin for internal use without exporting it, and then creating a public interface with my SDK implementation to export as my plugin. However, I haven’t seen any community plugins using this approach, and I’m uncertain if this is the right way to proceed. Is this approach valid, or are there better alternatives to achieve my goal?
Beta Was this translation helpful? Give feedback.
All reactions