[ANN] mobilehtml5app: A simple framework/tool to build mobile apps in Go with HTML5 front-end

697 views
Skip to first unread message

Hariharan Srinath

unread,
Sep 12, 2015, 5:31:48 PM9/12/15
to golang-nuts
Status: Very much alpha - works for me on Linux. Feedback highly sought. Contributions (espl. iOS) highly welcome :-)

Description
mobilehtml5app is simple framework and a tool for creating mobile apps with the Go language using an HTML5 supporting WebView as the frontend and a Go language HTTP server as the backend. This allows us to create front-ends for mobile apps using standard HTML5, CSS and Javascript and make use of the plethora of standard and very mature Web and Web App development frameworks available today rather than using OpenGL or the Native UI system. It currently supports only the Android platform.

Motivation
Go Language has introduced support for mobile application development with version 1.5 and the mobile toolchain is rapidly developing. However, the current UI focus is primarily on OpenGL. On the other hand, both Android and iOS support WebView based applications that deliver their frontend using HTML5. This allows us to build rich user interfaces taking advantage of Web and Web App technologies and frameworks. On Android specifically, the Apache CrossWalk and recent versions of Android system WebView (Kit Kat onwards) provide this functionality. This project attempts to make it easy to use the mobile support in Go and its HTTP server strengths in conjunction with HTML5 supporting WebViews to create mobile apps.

Usage & Reference
  • First run go get github.com/srinathh/mobilehtml5app/... to get the packages and the mobilehtml5app command.
  • Refer to mobilehtml5app command for documentation on how to generate a mobile app project with a go HTTP server backend and HTML5 frontend.
  • Refer to server package for documentation on the server used in the webapp that supports graceful restarts and parameterized routing
Credits
  • The Go Mobile team. I've been itching to be able to develop mobile apps this way for a few years now
  • Julien Schmidt's httprouter package &  TylerB's graceful package which enable server to be started/stopped with mobile app life-cycle 

Daniel Skinner

unread,
Sep 12, 2015, 7:02:03 PM9/12/15
to Hariharan Srinath, golang-nuts

Interesting. I've been considering spiking something similar just to play with polymer but wouldn't do the communication over http.

I'd be overtly concerned with security of the application in this regard. Also, completely ignoring all the java apis to allow integrating with the system isn't particularly a win in my mind e.g. app account managed from system settings (if such was needed), or sharing data with other apps via content provider.

I'd consider generated code that allowed communication via local broadcast manager with hook ins to the go code and the webview to establish some basics.

Doing long lists of items is likely to generate lots of garbage everywhere regardless of the approach taken (assuming no http comm) so that's a concern as well.


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hariharan Srinath

unread,
Sep 12, 2015, 10:50:20 PM9/12/15
to golang-nuts
Thanks!

Yes HTTP/Security wise another approach I did consider (and could still be implemented as an option) was to intercept WebView calls in the Java portion of the app and serve them through a call to a router in Go without HTTP. The main reason I didn't implement it is that the Apache Crosswalk WebView doesn't seem to (yet?) support the full richness of API as the standard WebView and I wanted compatibility ICS onwards. The intercept allowed in Crosswalk seems to be more limited.

Another approach that Crosswalk just seems to be adding support for could be mutual authentication based on certs communicated outside of the HTTP connection when Server.Start is calles.

In any case here we are running a short lived server that lives between onResume() and onPause() lifecycle events on a (usually random) system chosen port binding to the loopback address - so unless there is malware on your phone actively monitoring logcat or port scanning concurrently etc. and trying to connect to the server, security may be acceptable though the HTTP overhead may make the experience a bit slower.

Access to native API through Go will likely get richer over time as Go Mobile API evolves but it should be possible even now to write Java functions wrapping functionality and called from Go.

Hariharan Srinath

unread,
Sep 29, 2015, 4:49:53 PM9/29/15
to golang-nuts

Hi,


I have added a Todo App based on the mobilehtml5app framework to the repo that demonstrates the use of Web Frameworks in building a rich HTML5 UI front-end for a Go app on mobile. 


This app uses React.js & Bootstrap for the user-interface and uses BoltDB to persist data in the private app file storage space on Android. All the build steps like JSX compilation to JS, embedding assets using go-bindata, AAR generation and the Android build are performed using Gradle. This app has been built to use the native Chromium based WebView that is available in Android Kit Kat and above.





Regards
Srinath

Reply all
Reply to author
Forward
0 new messages