html5 appcache stoped working on IOS 11.3 - ios

We now know this is an issue with IOS 11.3, and seems to target only Ipad.
When requesting ressources through appcache, the cookies are discarded. If your ressources are behind some authentication. They will be redirected to your authentication page.
As mentioned by Apple, we tried experimentation feature on/off.
Removing authentication for ressources is not a valid permanent option.
We are looking for solutions while the next version of IOS hopefully fix this problem which seem the case with 11.4 beta 2. Changes are to be as minimal as possible to reduce risks.
Following informations are the process we when through when trying to solve our problem. To this day, no valid solutions have been attempted. Service Workers being the most plausible path.
Day 1
We have an application which was running fine in production for a while (almost a year since last deployment).
Our application use app cache to enable offline mode when wifi is not available.
Our application is mostly used on ipad with safari and some surface pro with chrome. Currently most cases are reported with ipad.
In the last few day, more and more users start to have problem loading the cache. We have been able to reproduce the probleme on an ipad after updating to 11.3 (could not reproduce on iphone 11.3) and using google chrome desktop incognito mode on dev machine. Application work on an older iPad we have which is at version 10.3.3.
--Application Cache Error event: Resource fetch failed (2) http://localhost:63330/client/vendor/kendo-ui/kendo.all.js--
Fact
- It always block on the same files, after some testings it seems to be all files bigger than 1.2Mb, in this case kendo is 4.7Mb and the minified one is 1.7Mb.
- Fiddler does not report any error, all files status response is 200
Guess
1. An update to safari and chrome might have changed
2. An ipad setting might have been changed by admins
3. An update to windows or ios, might have changes something
Since safari and ios follow the same release (29 Mar 2018), they are probably linked and the most likely guess, does anyone have an idea why this might happen?
Could not find much on apple support page of changes for 11.3
https://support.apple.com/en-ca/HT208067
https://support.apple.com/en-ca/HT201222
Update Monday 9 april 2018
We have been able to reproduce the issue both by debugging an Ipad and on the mac mini we have. However, the problem is different and for this reason we currently discarded what we found on Chrome on our desktop in incognito.
Here are the new facts:
Cookies were not provided while downloading file with appcache. The first file request is rejected and redirected to login page.
[Warning] ApplicationCache is deprecated. Please use ServiceWorkers
instead. (192.168.0.152, line 2)
[Error] Failed to load resource: the
server responded with a status of 401 (Unauthorized) (cache.manifest,
line 0)
[Error] Application Cache manifest could not be fetched,
because the manifest had a 401 response.
[Error] 2018-04-09 12:01:51 :
APPLICATION CACHE error
logMsg (logDecorator.js:111)
error (logDecorator.js:128)
(fonction anonyme) (applicationCacheUpdateSrv.js:121)
dispatch (jquery-1.10.2.js:5109)
handle (jquery-1.10.2.js:4780)
- After effect of solving authentication, we have problems with IDBDatabase, might be related to Authorization we removed (currently under investigation)
IndexedDB request error (get all rapports) -> NotFoundError: Failed to
execute 'transaction' on 'IDBDatabase': One of the specified object
stores was not found.
We found this by using Charles Proxy for Mac. For this reason, we removed authentication to our statics files and Home page. This seems to work, but our files would be public which is not really an option.
Similar questions:
Cache-Manifest How to handle authentication cookies?
Update Monday 10 april 2018
IndexDB error are not related. Databases were not initialized properly due to authorization missing.
We currently added an alternative home page where authorization is not required instead of removing authorization from the default home page. It would be called by the manifest cache and downloaded properly.
Update Monday 12 april 2018
We tried to secure the static files, we ended up with adding a token in the query url. While it work and we can authenticate the request (note that since we do not have cookies to authenticate the user, the authentication is far from flawless), the Url is now different than what was requested in the cached Home page and make the custom authentication worthless by itself.
We would need to also rewrite all the url for the cached page base the token genereted by the user. In our cases, it involve throwing out the ASP.Net MVC Bundle feature to maybe make a custom one? At this point, we think it might just be easier to try ServiceWorker since appcache is deprecated. This does not guarantee cookie will be passed on with ServiceWorker...
Update Monday 19 april 2018
We had some return from Apple yesterday. They asked be try Prevent Cross-Site Tracking property (both on and off) in Settings > Safari and also try Experimental feature in Settings > Safari > Advanced > Experimental (mentionning ServiceWorkers, but tried them all)
Unfortunately it didn't change anything for me at the moment.
Note: strikethrough some part that were not related directly to the issue
Update Friday 25 may 2018
Added a section to the top to resume the situation and make the question more to the point.

As of 25 april 2018, we tried iOS 11.4 beta and it seem to resolve the issue. According the the deployement timeline, it should be available in about a month according to this.
However until then moving to service workers might be a good idea.
Here is an example from google.
Here is a video which gives an introduction to the subject
I will add an example if we get to move to Service workers

Related

Ionic 6 angular capacitor set cookies on ios

i have a ionic 6 app with angular and i'm using external APIs to login user and retrieve some data.
When the user authenticates, the server responds with a Set-cookie header; everything works fine both on browser and android application.
On iOS looks like the set-cookie header received in the response is doing nothing.
I'm trying also to use cordova-plugin-wkwebview-inject-cookie on my app.component.ts:
this.platform.ready().then(() => {
if (this.platform.is('ios')) {
wkWebView.injectCookie(environment.config.baseUrl, '/');
}
});
but the cookie is not stored, so every next request get 401 response:
After a lot searching about this problem, I found this thread in capacitor github issues;
Long story short: It's not an problem or issue, actually it's a security decision take by Apple, like Thomas Vidas said in the same thread here:
It's several things, the main one being it was a deliberate change from Apple on iOS 14 and up called "Intelligent Tracking Prevention" (ITP) which disables all cookies on domains not listed as an App Bound Domain. It's not due to the capacitor:// protocol. ITP made it so document.cookie calls were intended to silently fail to prevent user tracking. If your server.hostname and App Bound domains are set up properly, it may work but could have other unintended consequences (such as Apple potentially rejecting your app) so we don't recommend it.
So, I recommend you to read the entire thread to get some insights, because it's a think that capacitor team doesn't have a solution.
I hope it will help you!

How do I debug/handle Firebase App Check Invalid Requests?

I've integrated (but not enforced) App Check within an iOS app of mine, and have a number of requests that are apparently invalid - that is, the requests have an invalid App Check token. I am using Apple's App Attest as the Attestation Provider.
The two example reasons given for this occurring are
"inauthentic client attempting to impersonate your app"
"from emulated environments"
I don't think 1 is happening, because I have a tiny user base (< 10 active users). I also don't think 2 is happening. I very rarely use emulated environments; I prefer building and testing on a physical device.
From troubleshooting on my own, it seems like the issue has to do with me using a debug build on my physical device vs a release build. I followed the instructions here: https://firebase.google.com/docs/app-check/ios/debug-provider, and the errors have apparently dropped to zero for the last 24 hours.
I have two questions:
Is this conclusion correct? That is, is it possible that me using a debug build is what was causing all those unverified requests? The two examples given don't mention anything about a physical device, so I'm not sure if this conclusion is right.
If the answer to 1 is yes, what is the correct workflow setup I should be using? It seems like the debug tokens have the same TTL as the normal App Check tokens (i.e. 1 hour), and manually uploading a token every 1 hour while developing doesn't seem scalable. Is it possible to have the debug tokens have a longer TTL? Or is it possible to upload these tokens through code vs having to manually add via the firebase console?
Firebaser here!
A debug build of your App should fail App Check, part of the verification is that a legitimate device is running a production build of your app. In that regard it is intended and expected.
Using Debug Tokens is the correct approach, the debug token itself will never expire but will be exchanged for an App Check token which will expire in 1 hour or whatever you have your TTL set as by the App Check SDK.

Firefox on iOS reloads old page although history and cache cleared

I am working on a web page, which I want to test on my iPhone. However, when I visit the website from my phone in either Firefox or Safari it is an old version of the website that opens. I have tried to clear cache and history as described here, but it is still the old website that appears. I have also tried to de-connect my Firefox account and restart both the app and the phone. I have checked in a browser on my computer and here I see the new website and any changes implemented instantaneously.
Do anyone have similar experiences with such an issue and how to solve it?
Edit 1: After a while (couple of hours) I tried again and it was indeed the new page in the mobile browser. I still don't however understand why there is latency in a mobile browser and not elsewhere, i.e. where and why is the old page cached on a mobile device even though history and cache has been cleared?
Edit 2: I have now also discovered that the same issue applies to all other non-mobile browsers than FirefoxDeveloperEdition, so this browser must be doing something the others don't.
I faced similar issues in past. It depends upon your hosting provider. Usually it takes no time to update web pages but sometimes average hosting sucks.
Try opening webpages in incognito mode/private mode.
My problem was solved by running cache-purge from my provider's SSH service.

Are Universal Links cached in iOS? Do they work offline?

I tested Universal Links in iOS by turning on Airplane mode and saw that the correct application was opened (instead of a website)
This indicates some level of "caching" the apple-app-site-association.
I want to determine the extent to which this is cached, so I can determine
What UX edge cases are there (e.g. Offline for x days)
What security considerations are there (e.g. MITM / SSLStrip + .well-known/URL)
etc.
Ideally I would like to have details if additional logic is employed (conditional caching if HTTPS employed, DNSSec, etc)
The exact behavior here is (intentionally?) unclear from Apple. Here is my personal experience, gleaned partly from official documentation and partly from helping thousands of apps implement Universal Links at Branch.io.
The apple-app-site-association file is cached once when the app is first installed.
If this initial scrape fails, in almost all situations it will not be reattempted. The only exception to this is if the initial return is a 5xx error, in which case a limited number of retries may occur. This is not well-documented, and is not covered in Universal Links documentation at all. You can find a mention in the Shared Web Credentials docs.
The file is not checked at all when a Universal Link is opened. This is why you are able to get Universal Links behavior in airplane mode.
The file does not expire. Once it is cached, it sticks permanently for as long as the app is installed.
The file will be re-checked when installing an app update.
The file must be accessible via a valid SSL connection at either https://example.com/apple-app-site-association or https://example.com/.well-known/apple-app-site-association. If there are redirects of any kind, this will fail.
It is theoretically possible to MITM the request if you are able to install a new SSL certificate directly on the device in question. Charles Proxy for example uses this approach for debugging. I have never seen or heard of this being exploited, and the damage would be quite limited because the domain still has to be specified inside the app itself.
I found a way to get around the caching issue. The cache is bound to the domain name, so for every time you want iOS to request apple-app-site-association you can create a new subdomain, and configure iOS to use that subdomain as the universal link for your app.
Extremely hacky, but it is the only workaround that worked for me.

iOS 6.1.2 forever caching redirect content

I've got (actually my employer has) a mobile website that enables Safari integration (for iPhones and iPads) - meaning that customers can bookmark it to their home screen and then it would behave as a standalone web app (no address bar, custom icon, start-up image etc).
It works all right except that one week ago (coincidentally soon after apple has released iOS 6.1.2) some of our customers (6 of them initially) complained that they no longer get the normal content but a '404 page' of a public wifi provider (The Cloud owned by Sky here in the UK). After a bit of investigation we've figured that at some point those customers connected to the Cloud wifi without actually logging in (it's one of those providers that would redirect you to a login page to enter your credentials, after which you can carry on browsing). The thing is that even after switching back to their private wifi or mobile data connection the application would display the Cloud's page.
This only happens (as far as I can tell) when the application is launched via the bookmark (I couldn't see this behavior when using it from safari).
What happens is that the customers would connect to the cloud wifi (without logging in), they would open the application at which point the router will issue a redirect response to their login page; the application would cache the login page and it will always display it whenever using the bookmark again. (I've performed a capture when this happens and there are no requests being made at start-up whatsoever).
Even weirder, in this situation, if removing the existing bookmark and adding a new one will show you the same cached page (with the whole operation being performed away from the Cloud). We've fixed this by adding a unique identifier to the URL each time we hit the bookmark screen (this indicates that the web apps' sandboxes are linked to the url, which is to be expected).
What we're trying to achieve is to have the application properly recovering after the customer has moved away from the Cloud. But there doesn't seem to be a straight forward way to do this.
Furthermore there's a level of inconsistency in all of this - most of the times when the flow is performed I will see a 404 page (a custom 404 page https://service.thecloud.net/service-platform), but sometimes I would be properly redirected to the login page, in which case the application would not break.
My assumption is that there is a weird race condition in the standalone web app application model causing the browser not to properly handle redirects (and actually caching 404 pages). I've raised a support incident with Apple (which eventually turned into a bug report) but it might take a while and I'm trying my best to figure out a workaround.
Any ideas, maybe someone has seen this before?
The issue is aggravated by the fact that I need to have a 5 minutes walk ever time I'm testing any fixes; I've tried creating simple test forms, but I wasn't able to reproduce the issue, where as with the full app I can do it pretty much every time.
Here's a summary of the steps to reproduce:
Via private wifi (or mobile data connection) add a bookmark to a website (I've managed to reproduce it with quite a couple of apps that support safari integration as described above)
Open the application to review the normal content
Connect to a Cloud hotspot and open the application from the bookmark (open-close it for a couple of times if you don't get the 404 right away)
Connect to the private wifi (or mobile data connection) and open the application via the bookmark -> you'll see the same 404 page again
In the end the fix was to add a unique query string parameter with the initial page request (pretty easy with the setup we already had, via the launcher page). I've filed a bug report with Apple which they've acknowledged by linking it to a previous item. Here's a post on the topic:
http://blog.onos.ro/ios-6.1.2-caching-issue

Resources