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

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.

Related

Is there any way for progressive web apps to access local filesystem?

Boss is requesting that we make our new email web app into a Progressive Web App. We are finding that there is no way to save local files from PWAs but he has asked that we keep looking for a way.
Can somebody please confirm that it is impossible to save files to the local filesystem when the webpage is running as a PWA?
Obviously for an email app you need to be able to download the files from your email, so without access to local filesystem storage there's no chance of downloading files right?
This would need to work across devices (iOS + Android)
Edit: This is not a duplicate of the question: "how to save a file in javascript"
That solution does not work and it seems to be documented that it doesn't work in PWAs on iOS: https://github.com/eligrey/FileSaver.js/issues/479
Anyway you guys have indirectly answered my question, it seems this is not supported and there is no workaround.
The answer is: no, there is no way to download files to the local filesystem in a Progressive Web App on iOS -- they do not support it.
Quote from here: https://github.com/eligrey/FileSaver.js/issues/479
This issue is based on the general iOS WebKit download attribute
issue. The download attribute in iOS is not working, therefore the
browser does not recognize the generated ObjectUrl as download and
ignores the provided filename.
This issue cannot be resolved by WebKit itself, because it involves
iOS proprietary code, which is the reason why all browsers on iOS are
affected. I personally triggered an Apple Care incident assisted by
the Browser Compliance Center of my employer and got a feedback from
Apple.
This incident was classified as high priority and will be fixed for
future releases. It will not be available in iOS version 12.1 or any
prior version.

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

iphone offline web app cache does not function

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.

Iphone app sharing file with iTunes problem

Somebody please help me out. This problem is killing me.
I went through tones of documents and posts. All seems to suggest that simply add a UIFileSharing key into info.plist and set boolean value to YES, files in App's Documents folder (not sub-folder, I know) will show up in iTunes.
However my problem is that I don't have an iPhone, so I really have no clue about what exactly the behaviors of both iPhone or iTunes will be when try to verify this file sharing thing. And what is the right way to verify this.
So when my client try to verify this off my watch (we are on different sides of earth), he keeps reporting back that file sharing feature not work. It is certain that file is properly stored under Documents folder.
In the last attempt, he claimed that he can see the app but not files.
I would like to know the following things, so I can guide him through this and end this pain:
Is it really plain and simple like add one key, no changes to code needed? Or did I miss something?
Are there any special requirements for building (like, only work for release build?), deploying?
What will really happen when plug the iPhone into the computer and sync with iTunes? Will the app show up in the Apps tab anyway, or only show up if file sharing feature are enabled correctly?
Thank you all.
Is it really plain and simple like add one key, no changes to code needed? Or did I miss something?
Yes
Are there any special requirements for building (like, only work for release build?), deploying?
No
What will really happen when plug the iPhone into the computer and sync with iTunes? Will the app show up in the Apps tab anyway, or only show up if file sharing feature are enabled correctly?
It will show up in the app view (on top) all the times. But you will only see them in the file sharing area if you have an app with enabled filesharing.
File sharing is only available on iPhone OS 4 onwards and iPad 3.2
Make sure your client has iOS4 or later.

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.