Search code examples
htmlcordovatitaniumhybrid-mobile-app

Can a hybrid html5 app serve html/css from a server


Supposedly one of the advantages of hybrid apps is that they shorten the deployment and A/B testing cycle. Instead of having to publish the app, wait for approval, and then wait for users to update it, you can just update your HTML on the server.

However, PhoneGap & Titanium package your HTML/CSS/JS with the app distribution. Is it possible to write an native app that servers HTML/CSS/Javascript from the server?

UPDATE Just found out about trigger.io reload functionality (https://trigger.io/reload/). That's basically what I'm looking for. Does PhoneGap provide something similar?


Solution

  • Simply put, yes. I read this article awhile back (The story behind Exfm - A PhoneGap featured app).

    From the article -

    Loading Assets

    One of the beauties of PhoneGap compared to native is its ability to load and run remote code. As I mentioned above, for development this is a complete time saver. But it also has the added benefit of being able to update your app at any point you want without having to go through App Store approval. Remote loading is certainly great, but mobile apps are also expected to work when offline. To get the best of both worlds, we decided to bundle our JS and CSS with the native build, but before loading them check online to see if we have newer versions available. To accomplish this, when our app first starts, it remotely loads the manifest JSON file that Mott created to determine the version numbers of our latest JS and CSS. If the remote versions are different, it loads them and then saves them locally using PhoneGap’s FileSystem API. If the remote versions are the same, it loads them directly from the FileSystem thus saving time. If we are offline, it goes directly to FileSystem. And if for whatever reason FileSystem fails, it loads the JS and CSS versions that we bundled inside the app when we uploaded to the store. This system has allowed us to update our app often while also keeping load times down and working offline.

    I suggest reading the article and checking out Mott.

    Be careful and make sure that Apple never finds out that you're bringing new content into your app without going through approval.

    Official word from Apple that is relevant -

    The only exceptions to the foregoing are scripts and code downloaded and run by Apple's built-in WebKit framework or JavascriptCore, provided that such scripts and code do not change the primary purpose of the Application...