How to intercept Xamarin's WebView javascript API calls - xamarin

We are trying to intercept in Xamarin Get API calls done in WebView.
The reason we do it - is we want to implement such flow:
for Example:
there is index.html that we are navigating to in newly opened WebView in Xamarin. And this index.html has let's say 2 resources: 1) abc.css and 2) def.js files. When WebView container will load index.html it will try to load this to files by making two Get API call, and we want to create interceptor on Xamarin side which will check: 1) if there is abc.css exists in Xamarin app 2) if yes stop loading it from server, but provide it to WebView instead.
Can we create such kind of interceptor in Xamarin?
I did my research and I found that Xamarin can intercept Navigating events, but this is very different to Get API calls.

Related

Integrating Surveyjs with Nativescript + Angular

I am trying to merge surveyjs along with my NativeScript application. I have referred URL for merging the same with Angular application
From the Angular demo code given on website, we have to add event handler for Complete button where we can get the response from surveyjs. Is it possible to integrate similarly for Nativescript Mobile application? Here is the approach which i feel can be taken.
Display
Create a HTML as provided by SurveyJS with required CSS and JS
referenced and add them as a file in project.
Modify HTML once i get the survey question json back from server.
Show the HTML as part of WebView. This will take care of displaying
the survey on my Application.
Here are my challenges during Submission
As per the process given on SurveyJS, i need to add handler for
oncomplete which will get the result json for me. How can i add
handlers for Complete button click in my code? Also please note that
there is a possibility that there may be multiple surveys on a single
page.
Apart from Survey, there are other fields also on the page and user
will submit them all in one go by clicking submit button of the page.
Hence i am planning to hide Complete button provided by SurveyJS
page. This needs to be triggered via code. Can this be done?
If someone can give directions on whether this scenario can be handled in nativescript application with Angular,it would help immensely.
yes it can be done using nativescript-webview-interface plugin.
add jS code inside WebView to handle oncomplete event from surveyJS. and on that function call emit some event to native app. after that add nativescript code to listen for that event and get the JSON back.
inside webView JS function
var oWebViewInterface = window.nsWebViewInterface;
// emit event to native app
oWebViewInterface.emit('anyEvent', jsonData);
inside native App
oWebViewInterface.on('anyEvent', function(jsonData){
// perform action on event
});
for more details on this you can check plugin readme file https://github.com/shripalsoni04/nativescript-webview-interface

Switching between views in Ionic2 is too slow

I'm building an Ionic application, I have built 50% of the project, and at first I used the sidemenu template that is auto generated with ionic start MyProject sidemenu, and then I added my own pages and components after that.
In the browser view the app was great, then I deployed my application to an android device, with the deployment being successfully When I start the application I felt that the application was slow, but when I switch to a some view, it took 5-10 seconds to open the new page.
I watched the traffic between the server side and the application, and observed that the application is not switching to the new page until the request is back and the view is rendered!
any help?
Try switching to your views first and then using the ionViewWillEnter() or another built in ionic API for the application lifecycle.
ionViewWillEnter will pull the data everytime the view loads, where
ionViewDidLoad will pull the page on first load only.
ionViewDidLoad() {
console.log('ionViewDidLoad SplashPage');
}
You do not state which version of ionic you are using but in ionic 3 if you create your pages with the terminal using
ionic g page MyPage
It will automatically create the page as a module. This allows for lazy loading. You can read more on it here form ionic's official blog post.
Its hard to say exactly why the view is only loading after it hits the server as you have not added your navigational code. There could be a code block that waits for a server response before pushing to the next page.
If your view is depended on received data from the server then your request should be in a new Promise allowing you to add conditionals for before and/or after the data has been touched.

It's possible to trigger an action in my Air app, from a link in a webview?

I'm planning on create a desktop app for a customer, which will be basically a webview (displaying some page only accessible in this app), and two widgets.
But this page needs to have a couple of links/buttons that will trigger some events (outside the webview, obviously) in the app, calling the widgets.
It is possible? How?
I've made a little research and didn't found any resource on that.
Thanks in advance!
You can use JavaScript to call Action Script 3 (and also you can call JS methods from AS3) methods using ExternalInterface (http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7cb2.html).

Ajax not working in CefSharp based WebView with local files

I have successfully embedded CefSharp in win form application using VS-2008 i am loading a jQueryMobile based webpage in webView which uses #id based ajax calls. which are not working in webView.
Is there any way to disable the security so i can load local files in the webview ?
got the answer by my self just needed a single line to do it
_browserSettings.FileAccessFromFileUrlsAllowed = true;

Common silverlight object for all web pages

In my web project I want to have global silverlight control (music player) common for all web pages in my project. When user click in hyperlink(want change view in web app) I dont want refresh all view with silverlight control but only part of view. Some think like in grooveshark.com. I think that for all views in my project I use PartialViews and load them using ajax(its good idea? Maybe anyone have better idea?) but I have problem. If we call action not from ajax but we write adress in web browser I get only partial view without shared layout. Also after load partial view with ajax and after them click back in browser I have updated adress in browser but not updated view(view not render).
Most important for me it's to have global silverlight object for all pages in my project and during the change view don't reload silverlight control.
Any ideas how do this?

Resources