iphone offline web app cache does not function - iphone

I am developing an offline web app for iphone. I have created the application and tested, it works fine apart of one feature, it is not being cached.
I have created the manifest file, and I checked with fiddler whether the right mime type comes in, and everything seems to be fine, when I shut down my data and wireless network connection, the application fails to open.
Does anyone has a clue for this problem?
Thanks
Arian

In order to cache a web app using manifest file, the browser must be able to get all files listed in the manifest file.
Although I made sure that each file can be located from the browser, there was one missing part. The browser was looking for favicon.ico file, although it was not specified in the manifest file, and as it was not found in the directory, the application was not cached.
Immediately after putting favicon.ico file in the directory, the application started to be cached and work offline.

There is a cache limit that you might be hitting. I believe it's around 5mb, but I'm not 100% certain.
Take a look at: http://www.thecssninja.com/javascript/how-to-create-offline-webapps-on-the-iphone
also:
Max size iPad / iPhone Offline Application Cache
and:
http://techblog.viewbook.com/2011/02/mobile-safari-offline-application-cache-limit/
That said, it appears that iOS 4 allows you to store more.

Related

Firebase Dynamic Links No Longer Open App

I am working on an app that uses Firebase dynamic links. All throughout testing, the base link, and deep links would open the app, as expected.
At some point, this stopped working on my test device. I tried turning the Associated Domains off and back on again (format is applinks:myappid.app.goo.gl). My URL Types setup in Info has the URL scheme set to my app's bundle id, which is also reflected in Firebase. My AASA still has the expected info in it as well.
I also tried long pressing on the link in both notes and messages (don't get an option to open in app, just open), but it still refuses to work. Oddly enough, it still works in simulator. Any help would be appreciated.
Update: I uploaded the build to TestFlight, and it works properly there. It looks like the issue only occurs on a physical test device, with the app being built from XCode.
Solution Update: Oddly enough after installing a dynamic links build via TestFlight, subsequent XCode test run builds started working properly again. Not the most elegant solution, but at least it is working now.
Update:
This most likely has to do with an open issue that prevents the AASA file from being updated or installed. Currently the only work around is to delete the app, reboot the device, and reinstall.
http://www.openradar.me/radar?id=4999496467480576

Adding a NETWORK section to HTML5 manifest file and accessing iPhone web-app in airplane mode

The facts
I'm building an HTML 5 responsive website with an offline mode. To do that, I'm using a manifest file with a FALLBACK section and the browser's localStorage to store the pages that the users decide to save for offline access.
Everything is working great both on desktop or iPhone (haven't tested it on Android yet), except when I add a NETWORK section to the manifest file.
Why do I need the NETWORK section ? I need it for Google Analytics to work - otherwise my website's users won't get tracked, even if the user if online (that's how HTML5 applicationCache works). So this really is mandatory.
On the desktop, this is not an issue, I can turn off the Internet connection and the website works in offline mode.
On the iPhone, however, if i'm turning off the Internet connection (for instance turning on airplane mode) I'm not able to start the web-app (meaning my website added to the home screen) once the NETWORK section is added to the manifest : i'm prompted by iOS to turn on the Internet connection, and the app is closing. If there's no NETWORK section in the manifest file, everything runs fine.
My question
is twofold :
1) while I can understand that there is some logic behind such behaviour, it seems very strange (well, almost unbelievable) to me that you can't have an iOS web-app working in offline mode if there is the slightest attempt to access the network - I've read numerous tutorials about applicationCache on iOS and no one ever mention the NETWORK section's incompatibility with airplane mode.
So, does anyone can confirm (or infirm) what I'm experiencing ?
2) If there is indeed such incompatibility, the only workaround I can imagine is having a dynamically build manifest file server-side, adding a NETWORK section for desktop users only - but that means forgetting about tracking mobile online users, which is not acceptable.
So, does anyone have a better idea ?
Oops, I should have looked better on SO : this has already been answered here :
https://stackoverflow.com/a/6285955/2251905
Following the steps outlined in the abover answer solved the problem.
This has nothing to do with the NETWORK section (thankfully and rightfully !), but with what seems to be an annoying iOS bug on the iPhone.

Clean way to programmatically control Safari on iPhone?

The title say's almost all. What I have is short lived server processes that serves a web-based javascript test suite with optionally accompanying back-ends for integration tests (see here for how it's done). I'm looking for a better way to direct the iPhone Emulator's Safari to the URL given.
More, possibly optional background:
Up until iOS SDK 4.0 I've managed to control XCode using AppleScript to start a specially prepared PhoneGap project in this fashion:
AppleScript (referred to as "AS") starts XCode (referred to as "XC")
AS instructs XC to load the previously set up PhoneGap project.
AS instructs XC to launch the PhonePap project.
The PhoneGap project will redirect to the server serving the test suite, and the test suite runs.
In iOS 4.0 SDK, this only works the first round, the next time the test suite runner tries to make XC do the above routine, it fails requesting the previous run to be stopped. And I can't for the life of me find a way to stop the debugging session with AS [1], so I can only run one test suite without manual intervention, witch is pretty much a show stopper for us since we rely a lot on nightly test runs.
Now, what I really want to do is just start the iPhone Emulator, and then start Safari on the emulator with the possibility of sending an arbitrary URL to the emulated Safari.
What I've found so far is iphonesim, but I'm running into this issue and can't get it to properly start pre-compiled apps. A way to circumvent this issue in iphonesim would also be a good way forward.
[1] I'd accept a way to do this as a valid answer too.
I have a very different solution for you.
Write a custom iPhone app that just contains a web view. It will behave pretty much the same as MobileSafari. Then, embed a little web server in the app.
You can then control your app by calling specific urls on that server.
This is a very simple app. Will take you 30 minutes to put together.
This is easily integrated in Xcode or a bigger (Apple) script. You can use commands like curl to open URLs.
This is possible now:
xcrun simctl openurl booted "https://google.com"
https://apple.stackexchange.com/a/198798/144271
Post scriptum: how it was solved in the end.
A while after I asked this question, a user at github added a comment in issue 3 that what you need for iphonesim to work correctly is to give the absolute path to the application to start. So now we have a prebuilt PhoneGap project where a script modifies the contents of the www directory inside build/Debug-iphonesimulator/PhoneGap.app. The absolute path to this directory is then sent to iphonesim, starting up the project now pointing towards the correct server. No AppleScript and no XCode (except for the initial build). The test suite now takes 1/7 of the time it took to run earlier.

Reading a file from a hard drive in iPhone simulator

Is it possible to read a file (from my normal file system) into a iPhone App running on the iPhone Simulator?
I understand that the iPhone itself has not got a (user accessible) file system but this is simply for testing and will only ever be run in the simulator.
The file will be a text file that can be edited while the application is running, it will be read every-time a method is called.
Yes, you can, and it doesn't matter where it is. Just give it an absolute path name when you load it (Xcode won't recognize a different working directory when running the simulator).
Yes, you can if your file is within your app folder
~/Library/Application Support/iPhone Simulator/User/Applications/ [your app folder] /Documents
No. Your app is running in its own sandbox on the phone. It's not allowed to read or write outside of it.
Edit: I think CiNN is correct. As long as your code stays on the simulator, you shouldn't have problems working with a file on your local drive.
I personally think that the easiest way would be to enter "file:///" in Safari within the simulator, if thats what your looking for.
It should also be noted that you can do this in reverse -- you can grab the files off your hard drive that your application created in the simulator. This is a good way to check out your results (data, images, whatever) without having to build a data "viewer" into the application.
FYI 'newer' sds versions will do this... Search for iPad and you will find it. (for obvious reasons I cannot give more details here) good luck.

iphone offline cached apps dissapear after closed in safari?

We're developing an html5 offline webapp for the ipod touch/iphone. We have the manifests and everything working correctly, but we can't figure out why our app will not reopen after the 'tab' in iphone safari is closed.
For example's sake, here's what works:
1) open the url to the offline-enabled html file in safari on the ipod touch
2) exit safari, turn wifi off
3) go back into safari where the dynamic webapp is in a window, hit refresh
4) app works offline!
however, if we do this, the offline app dissapears:
5) add a bookmark to the app's url (or a home screen icon)
6) close the 'tab' or window in safari
7) open the bookmark or the home screen icon
8) error message: "Cannot Open Page: Safari cannot open page because it is not connected to the internet."
I've googled on the issue a bit, and you know how it goes, I'll find the answer 2 seconds after hitting 'post' here.. but anyway my gut feeling is that the current latest iphone OS version of safari is trying to dns lookup on the url and erroring out rather than realizing it has the locally stored app already on the device.
anyone run into this? is there some flag i can set in my manifest or something to fix this?
You probably do not have your server properly configured. The Apple docs do not make this clear.
If your server is running Apache (most likely), you need to edit this file: /user/local/apache2/conf/mime.types
Add this line to the end:
text/cache-manifest manifest
You will need to restart Apache so the settings take effect. Could be something like
restart_apache from the shell.
What's happening here is that the server needs to return the cache file back to you with the proper content type set. If you don't do this, the file will probably come back as 'text'. If set properly, it will come back with a type of 'cache-manifest'.
To test what mime type a document is being returned as, use web-sniffer.net. Enter the url to your manifest file - you will see the result displayed in Content-Type:
Tip: Check that whenever you make changes to the files in the manifest that you change something in the manifest itself to indicate that those files need to be downloaded. And watch out for cached files that might not be checked for changes based on their expiration settings
It seems Safari (and thus the iPhone) expects all files to be listed in the manifest - even the main file of the app. I was using default.asp as the main page of my app and not including this in the manifest. My app was run from mydomain.com/myapp/ and thus the browser never saw the "default.asp". Also, according to the HTML5 spec, the main page need not be in the manifest but apparently Safari sees that a little differently.
My solution was to avoid using default.asp and calling my app app.asp and adding "app.asp" to the manifest. Hope this helps.