Js ‘import’ Statement invalid Webview android version 8 and lower - javascript

I am implementing a webview to load a remote blazor webassembly page url as part of a Xamarin android app. The page to load has Js scripts that include ‘import’ statements. This works fine on Android 10 and up but keeps giving “invalid token ‘import’” on lower versions. I found out that js ‘import’ is not supported on the webview of android versions lower than 8-9. Is there any workaround or an alternative webview implementation.
Thank You
I came across Crosswalk but its an obsolete webview alternative, Geckoview as well seems obsolete and the repo is not recommending it for production

Related

Cannot get SharedArrayBuffer to work in android webview, although it works in both chrome and firefox on both android and desktops

I am trying to run mupdf built as web assembly in a webview on Android.
I have set the response headers correctly as far as I know, and this is illustrated by the fact that the web page using the web assembly works fine on desktop browsers and android browsers (including Chrome which uses a version of webview).
But when running a program of my own which uses a webview, the page when loaded gives a console message saying SharedArrayBuffer is not defined.
What I expect is that the webview in my program, when loading, should work the same as in the browsers. All other pages I use, with complex javascript, work the same way. But this one reaches the attempt to create a SharedArrayBuffer, and fails with an error in the console.
When I go to the page that tries to load the web assembly code, and which uses a Shared ArrayBuffer, I have checked and in every browser,
window.isSecureContext is true and
window.crossOriginIsolated is true
however, in the webview in my program
window.isSecureContext is true BUT window.crossOriginIsolated is false
I am having the exact same issue and there doesn't seem to be anything about this on the internet.
Webview (109.0.5414.117) doesn't seem to support cross-origin isolation, and my Xiaomi Redmi 7a Android 10 can't update to the newest version as of this writing (110.0.5481.64).
This is quite bad because there are a lot of phones that don't support newer versions of Webview and never will.
Here is the only discussion regarding this topic that I managed find: https://github.com/ionic-team/capacitor/issues/6182
On some platforms, Site Isolation is not available, due to implementation or resource constraints.

. The iOS WebKit framework and WebKit Javascript must be utilized in apps that browse the web

I submitted my app that was a web browser that uses UIWebview, and I Used UIKit and Webkit, however my app got rejected.
"We noticed your app does not use the iOS WebKit framework for web browsing. The iOS WebKit framework and WebKit Javascript must be utilized in apps that browse the web."
Does Anyone Know why this is?
if its because I didn't use a WKWebView how do I convert my UIWebView to WKWebview without messing up my constraints and app
please help

cordova-plugin-file does not work well in browser

I am now developing an cordova app which is on platform browser. But I met a problem when using cordova-plugin-file to read a local file. My browser always get an "adding proxy for File" and a "Persistent fs quota granted" in my chrome console.
screenshot of console
I download an example from Cordova-Examples-master in github, but it comes in the same situation. So it seems like a wrong setting bug not bug in my code.
Have anyone met this problem before?
Any help is appreciated.
Cordova app should run from WebView control embedded to native mobile Cordova-based application with corresponding plugins compiled. It will not properly work in standalone web-browser, neither on PC nor mobile device.

Phonegap.js is not found

I have a problem with my Phonegap application. I got a 404 error on phonegap.js
I understand that the compiler (I'm using Phonegap build) will replace the src of my phonegap.js by the real path but I don't get that.
It's weird because I have all the other scripts loaded but not this one.
This screenshot is from Safari, debugging my application launched on my iPad to give you more details.
I'm using Phonegap 3.1.0 with an iPad Retina 64 bits with iOS 7.0.
Edit: I can't use Phonegap 3.4.0, Phonegap build is still not supporting it.
Thanks in advance !
Think of phonegap.js as the runtime. It only exists when your app is running on a device.
If you are previewing your app on a local web server, you will get 404 because the local runtime is not your device (its your laptop).
To solve this, developers have invented tools like PhoneGap emulate (http://emulate.phonegap.com/) where you can use an emulator to 'mock' certain behaviors in your local runtime that would occur on a device.
Thanks guys but the problem wasn't related to Phonegap. I copied from our desktop version and that created the problem. And as I wrote in my comment, the screenshot is from Safari debugger for my iPad, not from a browser tab.

Google Analytics not working in Webview in iOS app

Let me first start out by saying I know how to use the iOS SDK so please don't answer this with a "just use the SDK." I want to know WHY google analytics is not working.
Here's my setup. I have a web app that is also baked into an android app and ios app via webview. I'm using cordova. The android app works just fine with the GA JS code. The web works just fine. However no events or page views are showing up from iOS. I've heard that GA is tied to the domain so does an iOS Webview do something under the hood to the domain?
I was going to attach my code snippet but it's coffeescript in a few classes so I'll just paste the compiled js
Analytics.prototype.track = function(args) {
window._gaq.push(args);
};
Analytics.track(['_trackEvent', 'SubscriptionModal', "Closed", data]);
This works fine in web and android so it's not a JS. I'm setting the GA _setDomainName to 'focusatwill.com' and can see that both ios and web have a domain of 'www.focusatwill.com'
I've read online a few people talking about this issue and everyone says just use the SDK. I'm looking for the reason why it doesn't work. How do you fix it to use the JS?
edit
I should mention that the html and JS are not baked into the device, ie they don't have a local url but are served up from our webserver
Safari on iOS6+ blocks third party cookies by default, and I'm certain that webviews do too.
Check that you have something similar to the following in the init method of AppDelegate.m:
NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
That's from the standard boilerplate generated by Cordova 3.0.9, but might not be present if you're using a version that predates iOS6. It sets the app-specific cookie policy, which should override the system default.

Categories

Resources