Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Ruby on Rails app to native Android PhoneGap app

I've been working on a jQuery mobile web app written in Ruby on Rails, and would like to make it available as a native Android app. I've setup the phonegap project to load my url, and everything seems to be working, but I've been reading that Google will reject the app if it's simply a webview container to an external url. Has anyone had any experience with this?

From what I can tell, I'll need to rewrite the web app to use ajax calls to populate the page, as opposed to relying solely on web requests to my web server. Can anyone offer any insight into this? Would they accept a PhoneGap app that simply loads an external url? Any help is appreciated.

Update1: I've also read that being able to handle no internet connection is one of the main reasons they will approve/reject your app. I think this could be handled in the android app with some logic that checks for an internet connection, and if it exists, load the external url, if it doesn't load a local html splash page. Would this idea be ok?

Update2: Would it be an option to have a "skeleton" of the app as basic html files within the phone gap app, which just uses ajax to pull down all of the main html? That way the app would still function without an internet connection, but you could also make large changes to the content of the pages which would be pulled down in every request. Is that a viable option?

like image 586
Tim S Avatar asked Jan 16 '13 15:01

Tim S


1 Answers

I've never heard of an app being rejected from the Play Store due to just being a WebView container. But even if they wont reject your app for this, you shouldn't be building a PhoneGap application this way. You'll end up with an app that will feel like it's just a WebView container, and an app that breaks easily when connectivity gets spotty. Remember that even in good reception, latency on a phone is high, so reducing the number of requests you have to make (for static files and assets) is paramount.

Ideally, when porting a web site to a PhoneGap application, you should be decoupling your interface as much as possible. Fewer variables should be passed down from the controller to the views, and more data should pass through AJAX calls. When your front end code (all of the files in app/views) can be served statically, moving to a PhoneGap app is easy.

Ensure that the actions in your controllers all have responses for JS (format.js), not just HTML. Your views should be making AJAX calls to rails to get the data that fills in pages via AJAX. Then you can bundle your views (and your assets) into your PhoneGap app.

like image 174
Benjamin Avatar answered Nov 07 '22 06:11

Benjamin