Building an HTML5 iOS app with UIWebView

2020-05-20 08:13发布

问题:

I have a client who suggested we simply wrap an HTML5 app as a native iOS app by just creating a UIWebView and offloading all of the application-logic to the HTML5 app. This would allow us to have a "native" iOS app and a good mobile app for other devices.

However, this strikes me as a little odd and I was wondering what the pitfalls of such a plan would be. Does anyone have any experience doing this?

Thanks, Trey

回答1:

Any pitfalls you would experience as a web app you are likely to still experience. Don't attempt to do any OpenGL sort of app but if it's more like a webpage then this should work out fine for you.

However, using some frameworks out there you are likely to get a slightly "richer" experience in that you are able to access native phone tools that a web app isn't allowed to use (vibrate, GPS, etc.)

Take a look at PhoneGap. They lack extensive documentation but there are quite a number of people using it and have already 'ran it through the gauntlet', you could say.

All that said, if you don't want to deal with the marketplaces (iTunes, Android Marketplace, etc) you could always do an offline HTML5 app. Where the user goes to the webpage and it caches all the files that are required to run the app offline. This is a similar approach to what Google was doing with Google Voice when it was rejected from the iTunes store.



回答2:

HTML5 features within a WebView are really great (and growing). You can do almost everything.

But if you want use some special features inaccessible via HTML5 (or include some 3rd-party ObjC libraries), you can setup a very simple interaction between ObjC and JavaScript.



回答3:

Trigger.io is an option too. Much better than Phonegap these days. Only adding as this page is heavily google-SEOed.