Offline iOS Web App: Loads My Manifest, But Doesn't Work Offline

iOS: Web app added to home screen not working in offline mode

We fixed this by supporting a cached version of the app with the manifest attribute as follows:

<!DOCTYPE HTML>
<html manifest="/cache.manifest">
....
</html>

The cache.manifest file:

CACHE MANIFEST

# Version 0.0.2

NETWORK: *

CACHE:
ShareIconTutorial.png
HomeScreenIcon.png

FALLBACK:

Documentation is outdated on this topic because of PWAs, so hope this helps someone in the future!

iOS App - No functionality when offline

You could use the Reachability library available here, just follow the examples described in the README.md file, it's pretty straightforward.

Basically, after you've set up the library and the required framework (SystemConfiguration.framework), you can import Reachability into your view controller's classes and do something like this:

Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];
reach.reachableBlock = ^(Reachability*reach)
{
// Your app has internet connection, begin working as usual
};

reach.unreachableBlock = ^(Reachability*reach)
{
// Your app does not have internet connection,
// display an alert/image that will notify the user about this
};

[reach startNotifier];

You could put this code into the viewDidLoad: method, so when the app runs it checks for internet connection and does something based on whether it's available or not.

I think that Apple will approve the app, because there are a lot of apps that require a internet connection to do anything. A good thing that you could do is that you could save the data when user is done working with the app, so that when the user runs the app tomorrow let's say, and has no internet connection, he at least could look at his work he's done. A good example of this is the WordPress app, if you don't have any connection at the moment but you've logged in recently, you can see your older posts, but can't post anything new because you don't have the connection available.

Hope it helps.

How to set up offline manifest for a web app to run in Safari in iOS?

This tutorial is pretty good and if your pages are generated dynamically, you may use a .htaccess to rewrite domain.com/script.html to domain.com/script.php and then call the *.html from your app. This way the content on the device is saved as html and could be delivered statically. You can also add fallback urls/files to your manifest file which may be useful if your content is dynamically by default.



Related Topics



Leave a reply



Submit