Cordova iOS - WkWebView offline - ios

Application cache is deprecated which means we'll need to switch to service worker but I've done research it was mentioned..
1) "It is not possible to use a ServiceWorker in a Cordova app because the ServiceWorker API is not available to WKWebView and is not implemented in UIWebView. It is available in Safari on iOS, but not WKWebView."
//https://github.com/apache/cordova-ios/issues/414
2) Enabling appcache using private api is not working
//Enable Application cache in WKWebView
3) Cordova file & file-transfer plugin is not even recommended to use for production.
Is there any alternatives to be able to store artifacts (html, js & css files) and load for offline used? Our application needed to cached 300-400 files.
Appreciate your suggestions in advance! (:

Well to answer your question, my suggestion would be this: Get rid of those 400 files and find a more practical way to replace them.
Exactly why would you need to store so much CSS files in a Cordova app anyway? There's no logical reason that I can think of. Nor practical, loading other HTML files in the WebView goes against the SPA design principle.

Related

NativeScript - How to create a webview with request blocking/redirection?

I'm trying to create a webview with the capability to block/redirect certain urls requested inside the webview (not just the page url, but also the requests sent from the page, think of it as what a browser extension is able to do).
After some research, the closest I get was this Swift/Obj-c approach of use NSUrlProtocol: https://www.raywenderlich.com/2292-using-nsurlprotocol-with-swift, and the doc of the native-webview-ext mentioned something about WKURLSchemeHandler https://github.com/Notalib/nativescript-webview-ext .
I'm new to mobile development and this feature is crucial for my project. I wonder if anyone has experience building this out in NativeScript, I hope I don't have to convince my team and my boss to write this in Swift instead :(.
As you see in the webview-ext plugin docs, it does support overriding resource urls. Refer the registerLocalResource method.
Just in case, even if that is not supported you don't have to write your whole project in Swift as you can always access all native apis from JavaScript / TypeScript itself, read more about it here.

Offline WebApp on iOS using CDN

I am trying to setup offline support for our webapp. I would love to use a serviceWorker for that but unfortunately Safari does not support those, yet.
So I tried using the deprecated manifest file. But apparently only files from the same origin are allowed in there. We are loading our static files from a CDN (so the origin is not the same).
Is there any way to make a webapp with CDN files work offline on iOS?
One last idea would be to generate a index-offline.html file, include that one as a FALLBACK in the manifest. In there, I would point to the same files but this time not on the CDN but on our own server... But this does not seem like a nice solution to me.
Thanks in advance :-)
Jesse
As long as iOS does not support service workers, you cannot make offline work. Service worker is the core of a PWA and that can make offline work properly. We as still not sure if iOS will support offline capabilities.

How to upload HTML File(contains img,css and js) to Contentful (CMS)?

I have created a sample HTML(contains js, css and images) guide. I want to upload this html file to CMS(content management System) to edit content later. After that I will retrieve html content from CMS System and load it in my iOS app. So my guide will not be static and I don't have to rebuild for my iOS app every time. I reviewed content-ful api service, but can't find a way to upload html file. is this possible ? Please help me on this? or any other ideas?
I think it's not unfortunately possible. In your case it's easier to add content manually to your Contentul space and then retrieve the content within web application using JavaScript SDK. If you're going to create iOS app as well, then Objective-C SDK and Swift SDK might be useful for utilizing the content in future.

iOS local file access and webkit

I'm absolutely new to iOS App development (I haven't actually started yet, still in a design phase).
The task that I have to accomplish with my app is to download a zip from somewhere, extract anywere to local storage and display its content (html pages with javascript) in a embed webkit widget.
The questions are:
1) Will my app have access to any folder of my iPad storage memory?
2) Will my app's embedded Webkit widget be able to display local html pages (like file:///somewhere/over/the/rainbow.html ?
3) WIll that local page be able to use Ajax method (over httpxmlrequest) to dynamically load external scripts or xml (also locally stored - ie ./something.xml)?
Thank in advance for any help!
No it can't access any file. Apps are sandboxed on iOS. You can only access the app bundle's content and documents folder (a writable area unique to your app).
Yes - provided said content is in the areas mentioned in (1). This is how Phonegap-based apps work.
Yes - they can. We've done exactly this extensively in several of our apps.

Exporting files from a Javascript based phonegap app - options or ideas?

I'm currently writing a mobile app (hopefully iOS or android) using the jquery mobile framework and phonegap.
It'll need to export/send csv files in some way to the users, but I'd be interested to hear ideas or suggestions about the best way of doing so. If this can be done on the js side of the app that'd be ideal as it's what I'm most familiar with. A couple of options I've considered are:
Uploading the file using the google docs api
Writing the file to the file system (then export e.g. via iTunes)
I'm new to this so any suggestions gratefully received! Thanks for your help
There are a few options that you could use depending on how you want it to work.
The main options would be to
Use the File API (http://docs.phonegap.com/phonegap_file_file.md.html#File) to store files on the filesystem of the device.
Upload the file to a server using a standard XMLHttpRequest.
Write a native PhoneGap plugin on each platform that you are interested in that could connect to Google docs.
As Dave pointed out you can write files with the FILE API. I have used the file api on iOs to write custom log files and havent found any yikes so far.

Resources