Is there a way to pass data from javascript layer to AppDelegate.swift without a plugin in Ionic Capacitor? - capacitor

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.

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

Plugin is likely your best shot.
Not sure which features of that SDK you're using, but you could try using the Cordova plugin they provide. Capacitor supports using some Cordova plugins.

Related

Flutter_How to scrap the data from Javascript in web?

I need to get data from javascript in web-site.
It was successful to get data from general html web by using flutter_webscrapper dart package but looks like the webscrapper do not support to load javascript and scrap it.
I've been searching it and lots of developers recommend to use flutter_webview as headless browser.
However, flutter_webview spends too much time to create browser & load website. It takes almost over 4~5 seconds. Seems that challenge to use it in commercial product.
I also cannot use flutter_puppeteer because it does not support android & ios.
If there are any other way or other Dart package to scrap the data from javascript in web-site, please let me recommend. Waiting for your supports.
You can use web_scraper package .
may be using getAllScripts or getScriptVariables methods help you .
this sample repository used web_scraper package .

Import from node_modules into Svelte

Let me preface this by saying my knowledge of node apps and javascript is very limited, all my programming knowledge comes from a python data analyst background.
So, I am trying to learn frontend and build an app in Svelte. I will serve this app with another backend so I will not be using SvelteKit. I am also using Ionic for my UI framework. I will probably use Routify for routing but this is beyond the scope of this question. Also, I know svelte isn't officially supported by Ionic but i'm not interested in using another framework.
The simple method would be to include the Ionic CDN in the svelte index.html. However, I would like to keep my files in one place when I build the final app and not require a CDN or even possibly a network connection if I decide to use Capacitor to build for mobile devices. So, I'm not sure how to proceed. I would like to bundle Ionic (Ionic/Core - IonicIcons) with the default JS and CSS bundles that svelte builds using Rollup. Googling around a bit iv'e discovered I apparently need to use something called "rollup-plugin-css-only" to bundle the CSS and somehow include the JS files in commonjs in the "rollup.config.js". I tried adding the path to the JS files to commonjs but I couldn't see any changes to the bundled JS the svelte outputs. I also have no idea how to use add the css or use "rollup-plugin-css-only". Instructions and explanations iv'e found haven't been very helpful.
So, in summary... I'm trying to bundle Ionic into my svelte project without using a CDN and haven't figured out how too do it yet. I also may not be understanding this workflow correctly so let me know if I got something wrong. I just need an explanation or example of Ionic bundled in a svelte app. I would also like to mention that the workflow I am looking to accomplish will also allow custom themes in Ionic with the CSS processing.

Advanced features with Flutter Driver (or Silenium/Ghost Inspector)

Looking for a UI integration test strategy for Flutter. We'd love to use Silenium/Ghost Inspector but seems that is not practical due to lack of html id's or CSS classes in Flutter (Add id or name property or other means of identification for Flutter Web applications?). Or has anyone found a way round that?
In the meantime Flutter Driver has only very basic documentation for simple tests like finding a button and pressing the button. Anyone know if I can do other operations like navigate to a specific page (e.g. using a # url fragment), test a link which leads to an external site, check visual setup of the page against an image, and other such tests which would be standard in Silenium and the like.
Thanks!!
Well seems Flutter Driver is still very limited so I have instead found a strategy for using Selenium, posted full details here:
Strategy to use Selenium browser testing with Flutter Web apps

Use navigator.geolocation or $cordovaGeolocation in Ionic

Since I basically can get the same info with both approaches, I'm wondering which is the preferred one and what are the advantages using one over the other?
$cordovaGeolocation is angular wrapper over plain javascript plugin, developed by ionic. Now question is why ngCordova was introduced,in simple words to deal it as plugin service as module and inject plugin wrapper as dependency to only particular controller or service.
On Pratical level, cordova developers were having issues with plugins on angular project. One simple issue was that $scope does not get updated sometimes in simple plugins callback.
Quoting from ionic blog post :
The services support promises to make it easier to deal with their
asynchronous nature and ensure scope data is properly updated.
So my conclusion is, you should go with $cordovaGeolocation.
As far as I remember, on Android that plugin does not do anything at all, and on iOS it prevents the OS asking for access to location over and over.
Overall the plugin totally conforms the html5 specs, so you shouldn't change anything in your calling code (in js) if you use the plugin.
And the plugin has a good documentation here: https://github.com/apache/cordova-plugin-geolocation/blob/master/doc/index.md
It is worth noting that according to the current and oficial documentation (see cordova geolocation doc), there is no need to use $cordovaGeolocation, but rather the global object navigator.geolocation.

How to implement typeahead using ionic without bootstrap

I'm new to Ionic and would like to implement a typeahead for displaying the users list without using Bootstrap and would love if provided with an example .
I was looking for something similar for an ionic app I was building. I can provide a few links that you can look at and choose the most appropriate for your case.
https://github.com/sn0opr/ionic-autocomplete
https://github.com/guylabs/ion-autocomplete
http://www.sitepoint.com/creating-a-typeahead-widget-with-angularjs/
The last link is written is great tutorial written in pure angular. The first two links are projects you need to include in your app and then use them as directives to achieve your goal. Cheers!