Home > Mobile >  Is there a way to pass data from javascript layer to AppDelegate.swift without a plugin in Ionic Cap
Is there a way to pass data from javascript layer to AppDelegate.swift without a plugin in Ionic Cap

Time:01-07

I'm using Ionic Capacitor (javascript application ios/android native wrappers), and I have a situation where I want to get a small piece of data from the javascript layer and pass to ./ios/App/AppDelegate.swift.

Is there any way to achieve this without the use of a plugin? For example, can AppDelegate.swift "listen" for javascript events in a manner similar to how a Capacitor plugin would?

Thus, in my application, I would have a form field (e.g. for email), and then on button click I pass the string to AppDelegate.swift, which then does something with it.

CodePudding user response:

Plugin is likely your only shot.

Not sure which features of that SDK your using, but you could try using the Cordova plugin they provide. Capacitor supports using some Cordova plugins.

CodePudding user response:

Yes you can do it. It's documented here That not the favourite way, though.

Edit:
this is from native to JS in the doc, sorry about it.

  • I checked a the module you want to install in your app, it seems you want to do it in AppDelegated because of the need of UIApplication.
  • If it's that i recommend you to create a plugin and use it inside like here
  • Or last solution you can use a config if you don't need to change the config by deploy
  •  Tags:  
  • Related