UIWebView cannot read correctly some local HTML5 stuff - ios

Here I come with a new challenge for you all, Objective-C developers:
I'm trying to load some HTML5 exports from Articulate into an UIWebView. Well, at first sight it's quite simple: just put the HTML5 resources into the project and call index.html.
Well, that simply doesn't work if the HTML5 resource have a complex javascript structure. Specially with <audio> and <video> tags.
Any idea?

I've been investigating for hours and the solution appeared with some lateral thinking:
If the main problem is that reading locally doesn't work, but the app requirements forces you to maintain the content offline, then let's serve the content locally!.
Here are the steps I followed to resolve this issue:
Embed a web server into your app (I prefer GCDWebServer)
Let GDCWebServer serve your storyline locally with: [webServer startWithOptions:#{#"BindToLocalhost": #YES} error:nil];
Use WKWebView to call your local web server with: [wkView loadRequest:[NSURLRequest requestWithURL:webServer.serverURL]];
Then you will see your Articulate storyline working perfectly in your app inside a window, with iOS8.
Hope this can help someone.

Related

How to load local file via iframe inside html file in wkwebview?

I am migrating UIWebView to WKWebview.
While I could manage to migrate most of the workflows.
I am stuck at one workflow that I am not able to load the local file ("file://") via iframe from the html file in WKWebview.
It was working fine in UIWebView.
Also if iframe source is "web-url" and not local, it is working fine.
I am not seeing any error or any message on the console.
I read on few thread that loading local data in iFrame is broken in WKWebView, most probably because "allowReadAccesstoURL" setting which i am passing for main html is not passed to iframe correctly.
I wanted to check if there is a way to load local file via iframe.
It is disappointing that Apple has broken the functionality without providing proper alternative.
I am finally able to resolve it.
Issue was that the readAccess path for the "LoadFileUrl" was not inclusive of the url that was being loaded as iframe.
What was irritating is that console log did not give out any detail related to the error and I was not seeing any network call like decidepolicy or anything for the iframe loading, which caused the confusion.

How to print .docx,doc,xls,csv in rails 4?

How can I print .docx,doc,xls,csv in rails 4?
I tried window.open and window.print using javascript, but each time when it invokes window.open it downloads the file.
I tried to embed that in an iframe, that also fails.
Displaying a specific type of file isn't something that relies on your application it relies on the browser. In common browsers there is no support to display the file formats you mentioned.
What you can do is implementing some document viewers based on js if they are available for your usage. For example I know there is a plugin viewer.js that provides functionality to convert office and pdf to html. That might help you out... https://developers.box.com/viewer-js-tutorial/
I tried doing this some time back and this is the blog which i refereed. Helped a great deal.
Hope this helps.

Playing videos inside a Node Webkit <webview>?

I'm working on a Node Webkit project (now called NW.js). The latest stable version of NW (0.12.1) allows the "webview" tag from Chrome extensions to be integrated into a NW project.
After some initial testing, the webview tag seems to work fine for displaying basic webpages. But it won't display any Flash videos embedded in a webpage.
Flash videos play just fine outside of webview (ie in the normal NW browser), as I have "plugin" set to "true" in package.json, thereby using the Flash dll installed on my system. They just don't play inside a webview.
I just came across an article here...
https://developer.chrome.com/apps/tags/webview#local_resources
...which states that "webviews are prevented from loading any resources packaged with the app". So I'm guessing maybe that is what's preventing any Flash dll's installed on my system from being used by webview? I'm not quite sure how to fix this though (assuming this is even the actual problem). Do I need to create a manifest.json file specifically for this, as stated in the article linked to above? If so, what exactly would I put in there? I've been using NW for a while, but haven't really messed around with Chrome extensions code at all, so that part's still a bit fuzzy to me.
Thanks!

Combine JQM, MVC and PhoneGap together

I have a site which uses microsoft mvc 3 on the server side, jQuery Mobile on the client side and I want to combine it with PhoneGap and produce executes for Android and iOS.
Is it possible?
How?
Thanks
Yes, it is possible.
If you must use Phonegap, there are a couple of things to do:
First, you must create a project corresponding to each platform , following these instructions. Once you do that, you basically copy all the client side code (js, html, css) to the www folder of your project. This is one of the reasons, the app could load faster, since it's reading its resources from the local filesystem, and not receiving them from an http connection each time.
Second, you must find a way to provide your server side data to your app. If you are already using REST services or RPC methods to populate your website, then that's done, but if not, you must start by building them, and then calling them from your client (through ajax calls from jQUery most likely), and then rendering them through javascript (you can use the multiple templating libraries out there or just plain javascript, I recommend the latter only if the UI updates are minimal).
As you can see, the second part requires quite a little bit more work. Especially if you haven't built web services before.
The other option ,which does not require phonega/cordova is to use an embedded webview. Then you wouldn't have to do anything. It would work similarly to a browser (Loading the remote URL of your site), with the added advantage of being inside and android/ios app, and you could add other views or communicate with the embedded webview using native code. If you are planning to load html files from the filesystem and not from your server, you would have to do the same thing you have to do with phonegap.
It happened to me, if you have a web app depending on server code I would go with a WebView based app, and not a Cordova app.
It's really simple to create those webviews apps for Android or IPhone.
Here you have an example for building a webview based app on android
Here you have an example for building a webview based app on IOS
Hope it helps.
If you want to reuse your site you'll need a webview that browses it.
Phonegap wouldn't be needed if you use this approach, but the application will not be as responsive as a native app, and the IPhone moderators may reject your app for that reason (it happened to me).
Another approach would be that you recreate your site as a pure Javascript application and only communicate with your servers to execute some REST Services. In this case Apache Cordova makes sense.

How to get Back button working between remote and local jQuery Mobile pages?

I have a local jQuery Mobile project going (inside PhoneGap, thus file:// protocol) where I sometimes need to fetch external pages (using http://) from a server where the content too are jQM pages with almost identical markup (except for the content, which is generated from a CMS).
Setting $.mobile.allowCrossDomainPages to true gives me the page, and that is all right. Going Back, however, fails. I get stuck in a place where /www/index.html is not found on the server (like, doh, of course..). Is there a way to "remember" where I came from, taking me back to the local html page I originally came from?
We just added a docs page on PhoneGap in jQuery Mobile for RC3 that should help you out quite a bit:
http://jquerymobile.com/test/docs/pages/phonegap.html

Resources