ios 5 loading cached images in a uiwebview - iphone

I have an application with a UIWebView where I display some html content.
The content is first downloaded from the web, and then saved to the cache in /library/cache for reuse.
The images are also saved to the cache.
The html code that is saved to the cache is changed so that the 'src' code for the image point to the exact folder - where the images have been saved on cache.
When I load the page from the cache, the images doesn't display with iOS 5. I even don't have the "?" icon for missing files. No errors. And it is working perfectly on all other iOS except with the actual iOS 5.
Anyone got an idea or experiencing the same problem ?
Yes im using the loadHTMLString method
I found this in the docs and other topics:
Issue: UIWebView can't load local resources in apps built against 3.0.
When using [UIWebView loadHTMLString:baseURL:], the HTML string should not refer to local resources with the file:// scheme. Instead, pass in NULL or a file:// URL for baseURL:, or include the resources directly in the HTML with <style> and <script> tags.
And Im using [UIWebView loadHTMLString:baseURL:] to load the html from the cache, and my app was build against 3.0
My baseURL was fixed to the url of my server. If now I put 'NULL' in the baseURL, the images are displayed correctly with iOS 5.
What I just don't get is why the images don't get displayed if I put an url for the baseURL, and thus just with iOS 5 - while with the other iOS the image are displayed.
The project has been build and deployed with XCode 4.2 a few month ago - I don't know if this is usefull. It has ever worked ! But the issue with loadHTMLString make me think it was not supposed to work with the other iOS ?!?

Are you loading the Data in the WebView with the loadHTMLString method?
If yes, then you should pass in he baseUrl the NSCachesDirectory

Related

HTML5 video player gives errror when loading video located inside device using Ionic-v3

I'm developing an app using Ionic. One of the required features is letting the user upload videos to the application and seen them inside the app.
When I try to load the video using a <video> tag I get the following error:
"DEMUXER_ERROR_COULD_NOT_OPEN: FFmpegDemuxer: open context failed"
I already tried loading external videos and they load fine. I also made sure that I could access that location displaying local images without problems.
I'm using:
Ionic V3
cordova-plugin-ionic-webview 3.1.1
cordova-android 7.1.0
The problem was with the video I was using. It got corrupted when I tried to convert it to another format.

How to deal with missing hw back button on iphone in a phonegap app?

I have a web app, hosted in a phonegap application (i use phonegap build for this)
The setup is simple, but shouldn't really matter in this case. I'll tell you anyways because sometimes the devil is in the details, right? :)
The details
The phonegap app is really just the minimal setup with one single html. That html actually serves as a splashscreen - the background of HTML has an image. There is a meta refresh tag, set to redirect the page to an external url. I'll call it myurl.com from now.
The website at myurl.com is build using jquery mobile and angularjs. I use that adapter floating around to handle the problem with both frameworks wanting to manipulate the dom on page load. This is the domain the app is really hosted on and where the whole application is run.
The setup
One page has a link to an external page. That page has a bootload of javascript, showing some fancy stuff. If you click the link - your app takes you to that page. That is great! It actually works on all devices. On my desktop browser and android app, i simply hit the hardware (or browser) BACK button and i'm returned to my app at myurl.com. Iphone on the other hand doesn't have a back button :(
My first attempt is creating a landing page that has a back button/link and an iframe to host the fancy page. It works on desktop and android even though i get some exceptions/errors in the console. It doesn't load on iphone - i can only suspect security issues. I am told that what i'm trying to do with the iframe won't work which i think is true.
How do i deal with this? I actually tried the InAppBrowser like this:
var ref = window.open(url, 'random_string', 'location=yes');
And i checked my config.xml has this:
<preference name="stay-in-webview" value="false" />
I also added this to my page:
<script stype="text/javascript" src="phonegap.js"></script>
Leaving out the phonegap.js file since phonegap build promise to include the correct version.
It still opens the page in the same view/app without the possibility to go back - i get the excat same result as just opening the link the normal way.
Help me {insert jedi name here}, you're my only hope!
EDIT:
I found the problem. The phonegap.js file is automaticly deployed ON the device so only the first index.html (with the meta refresh) actually links correctly. The pages on myurl.com is not linking to the file. I placed the phonegap.js on myurl.com and it's working. Only problem, the phonegap.js is different per device - meaning only the device i picked the phonegap.js from is working - the other devices break!
Anywhere i can link to the native apps files? i tried file:///{path}/phonegap.js but it doesn't work. I can see/guess the path, which is different per device, but for iphone its
Payload{name}.app\www - it won't load from there though... i also tried
http://localhost/phonegap.js
but that doesn't work either.
Any ideas?
FINAL EDIT
I decided to go back to the drawing board and place all the html files on the device instead. I'll implement JSONP on my ajax api instead so i can let the API live on myurl.com and still access it from the phone. It's probably also the intended way to make a phonegap app - i just liked the other approach more...
I actually just answered a question like this the other day. You can find it here. In short, see below:
Ensure you have <script src="phonegap.js"></script> in each of your pages that wants to use the inappbrowser
You should NOT need to include a plug-in tag in your config.xml. I am pretty sure that around 2.5 they included inappbrowser in the core build functionality.
To open a link in the inappbrowser, use this javascript:
function openURL(urlString){
myURL = encodeURI(urlString);
window.open(myURL, '_blank');
}
This will open the passed URL in the inappbrowser. If you change window.open(myURL, '_blank'); to window.open(myURL, '_system'); it will open the passed URL in the system browser.
Finally, your item clicks look like this:
<a href='#' onclick='openURL("http://www.urlyouwant")/>
Also, depending on the version of phonegap you are using, stayinwebview is depreciated.
***Based on your edit: Do not put phonegap.js in your project directory. When you upload it to build, it will include it in your project.

Pre caching webpage when app loading in ios

I've problem in ios that loading webpage in UIWebView is getting too slow at first time.It is possible to pre cache the specific webpage when loading the app, Then show that pre cached webpage on where I want in the app.How to fix it ? or Please give any guidelines...

Jquerymobile HTML5 Iphone App Add to Home screen

I'm creating a Mobile App with JQM and JSP I'm using Bookmark bubble to do this, but I just want to ensure I understand what is happening behind the scenes here.
Is the static HTML generated by my JSP saved locally on the iPhone?
Does clicking on the APP always get fresh info from my online server or does it cache?
I'm assuming it still uses Safari to render? And just hides the toolbar etc?
If instead of hosting this online, I packaged it as an Apple App and it went on App store,
would the device still use safari to render it?
Thanks!
Documentation is at: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/SafariJSDatabaseGuide/OfflineApplicationCache/OfflineApplicationCache.html
It's possible to cache the page(s) locally.

iPhone UIwebview with embedded quicktime video?

When I load a HTML page with a .MOV embedded video on my App using a UIWebview it appears a broken icon, any idea? The same HTML page on Iphone Safari works fine and the media player is started without problem...
Where is the webpage? Is it embedded in your app? If you not giving the UIWebView a URL to load it from the server where it is make sure you set the baseURL properly so that the webview knows how to handle handle relative URLs.
When using the app sandbox, apple stops WebKit from accessing it's com.apple.security.WebKit.PluginAgent.
You must enable these in the entitlements file with the appropriate entitlement of
Add this line to the entitlements file as an ARRAY:
com.apple.security.temporary-exception.mach-lookup.global-name
in this array add the value : com.apple.security.WebKit.PluginAgent
and you should get your app to give sandbox permission so the app can access the quicktime movie plugins.
Hope this helps, if this doesn't solve the problem maybe the movies are missing... ;)