Reputation: 4187
I am using the following code to display a website in my app.
let webVC = SFSafariViewController(url: myUrl)
present(webVC, animated: true)
Now, I want to add offline reading. I know that iOS has a reading list, which apparently caches articles for offline use, but I could not find anything related in either the documentation for SFSafariViewController or elsewhere.
The only similar post I could find was this one (Swift iOS Cache WKWebView content for offline view) although it depends on WKWebView and writing a custom web archive exporter.
There must be a better way to achieve offline capabilities for SFSafariViewController, considering that it is newer and the recommended in-app method, and that Safari itself utilises an offline-mode for the iOS reading list. Any help?
Upvotes: 4
Views: 588
Reputation: 162
It seems like you might be out of luck here. As suggested by this radar SFSafariViewController doen‘t even load data from the reading list.
That said, I don‘t think there is any possibility to achieve what you‘re trying to, other than, as in the link you have provided, writing a custom archive exporter and using WKWebView. As stated in it‘s documentation, SFSafariViewController only supports http or https url schemes, which makes this approach unsuitable for it.
If your application relies on this functionality, it shouldn’t be too hard to implement something like that, possibly using SwiftSoup or similar projects to extract and manipulate the links to reflect their on-disk path.
Upvotes: 1