We have a mobile library (Android and iOS) and we also have a JS library, now we have an App developer who wants to integrate our library into his App, the App is built using Capacitor framework, so I checked the docs and some topics in here in the forum and what I understood is that we should build a custom plugin which will call the native SDKs directly, but while I was working on this plugin I discovered that Android opens to a certain URL based on this configurations,
this URL I guess represents the website in a mobile view, so now I’m a little bit confused, should we integrate our JS library directly into the Capacitor App or should we build a custom plugin that is a wrapper around the native SDK.
The url is used mostly for development, while there are people using it to point to production websites, is not recommended.
Anyway, that doesn’t change anything.
What you should ask yourself is if the js SDK and the native SDK are equivalent or not.
If the native SDK has features that are not available on web and you would prefer your Capacitor users to use, then create a plugin.
If everything works from the js SDK and there are no benefits for users when using the native SDK, then don’t create a plugin and use the js SDK.
I say “if everything works”, because some javascript APIs might not work when using them inside a WebView, or some things might work but a bit different, like if using fetch/XHR to a server, they are affected by CORS, so if you don’t have the server configured to allow requests from the apps they will fail, while native connections won’t.
Thank you for your detailed answer.
I read here that when it comes to the device’s local storage it is not recommended to rely on the local storage of the webview as it is wiped after a short period by the OS, and in both the JS SDK and the mobile one, we rely a lot on the local storage of the browser and mobile, in addition to the CORS, so I guess I won’t be able to use the JS SDK, right ?