开发者

Creating iphone & android apps for existing rails app

I've just spent a lot of time looking into the best ways to create iphone and android apps for an existing rails app that I've built and I feel that I haven't actually gotten any closer to knowing how to best achieve this.

What I want:

  • I would like to have the rails app and the mobile code cleanly separated. I'm not looking to just render a di开发者_Python百科fferent layout in my rails app. I'd prefer to use something like phone gap that allows me to use roughly the same codebase to run the mobile apps.
  • I'd like to have offline/sync capabilities in the mobile apps (hence if a user creates a record on their iphone while they are out of coverage the app should save the record on the phone and continue to try to to sync that record to the web app until success.
  • Having access to the hardware features will be needed down the road. GPS, accelerometer, etc.

My questions:

  • Is this a good situation to use oauth? Would I just build an oauth provider into my web app and then build the two mobile apps as clients to the web app?
  • Is there an easier method for secure authorization that I'm missing?
  • Does Devise work with oauth? My app is built on top of devise at the moment.
  • Is this syncing something that should be abstracted to a middleware or metal?

Sorry, I know this is actually a lot of questions but I'd like someone who is familiar with the situation to answer in a comprehensive manner rather than just a couple little pokes that leave more questions. I feel like this has to be a common situation now-a-days but I can't seem to find anything up-to-date in my searches.

Cheers!

ps. - If you've done something like this yourself and know how to pull it off, I'd love to talk to you directly. I'll even buy the beers. Seriously... no takers?


I am building a mobile application with a grails backend, must support android and iphone

I have done a few iterations so far while attempting to settle on technology, a native objective-c, native android, phoneGap and titanium appcelerator.

for authentication I use HTTPS with basic auth. I know people are concerned about basic-authentication, but it has been argued both ways see this StackOverflow Question

I have not solved the syncing problem yet, but I dont expect to implement that complex of a solution initially, will store local content (XML or JSON) and push back to server on demand. Content is stored locally in same format used when posting to server

Backend in grails, all REST API calls are logged and authenticated on each request. Will probably add additional security only allowing specific registered devices to access the API as and additional level of security


I've been building a iPhone app with a Rails back end. I've been using Objective-C because it needs the full Core Location framework which isn't available with a browser based solution. So if you want to use the full capabilities of the device, you have to use the native development environment.

I've been using Objective Resource http://iphoneonrails.com/ which is an open source framework that provides Active Resource-like extensions to Objective C NSObject classes and plays very well with my Rails App. You just have to put in render JSON or XML for your controller actions like in the example below.

 class UsersController < ApplicationController
 # GET /users
 # GET /users.xml
 def index
   @users = User.all

  respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @users }
  format.json  { render :json => @users }
end

end

I don't if this answers all your questions as I don't know enough about your app but it's a good starting point.


Maybe you will find useful my example rails + ember.js App with token authentication based on ember-auth and several OAuth strategies. It is responsive and works both as a desktop and mobile App with Phonegap.

Currently in de the devel branch: https://github.com/joscas/base_app/tree/devel

Life here: https://starter-app-staging.herokuapp.com for the desktop version.

It uses the phonegap-rails gem (of which I'm also the author) to export the apps assets, fix paths etc without hassle.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜