Mitra is the Sanskrit word for friend. The project helps you find friendly travel guides in all parts of the world. The template is based on Bestmix which provides a boiler plate code to connect Rails application based on JSON REST to Android and iOS applications.
Documentation for the project
- Ruby on Rails - Web Framework
- Devise - Authentication
- RABL - JSON Formatter
- Doorkeeper - OAuth2 Provider
- omniauth-facebook - Facebook Login
- Koala - Facebook Library for Ruby
- versionist - API Versioning
- Active Admin - Admin Interface
See Gemfile for more details
- CocoaPods - Library Management
- AFNetworking - Networking Framework
- Reachability - Network Reachability
- SDURLCache - HTTP Caching
- MagicalRecord - Active Record for Core Data
- mogenerator - Core Data Code Generation
See Podfile for more details.
- Ruby >= 1.9
- MySQL (you can use another DB server by editing Gemfile)
- iOS >= 5.0
- requries ARC and Storyboard
- Android >= 4.0
- Install Ruby on Rails and RVM if you don't have them.
- Copy server/config/database.yml.example to server/config/database.yml and modify it.
- Copy server/config/initializers/devise.rb.example to server/config/initializers/devise.rb and modify it (See Devise for details).
- Set
config.mailer_sender
. - If you use Facebook login, enable the setting at the bottom and modify
APP_ID
andAPP_SECRET
.
- Set
cd server; bundle; rake db:setup; rake db:migrate
rails s
# (or setup your web server such as Apache, nginx, etc.)- Open URL
http://localhost:3000/
to see the web app. - Open URL
http://localhost:3000/admin
to see the admin page.- Email:
admin@example.com
- password:
password
- See Active Admin for more information.
- Email:
Open admin page: http://localhost:3000/admin
and click "Applications".
Click "New Application" at the bottom of the applications page, and input app information in the form:
- Name:
<your iOS app name>
- Redirect url
bestmix://auth
If you develop your own app instead of just running the sample app, change the URL schema (bestmix
) of the above redirect URL.
When you submit the form, app ID and secret will be published as below. They are used in the iOS app's config file.
- Install mogenerator and make it executable from Xcode (e.g.
ln -s /opt/brew/bin/mogenerator /usr/bin/mogenerator
) - Install CocoaPods
- Copy ios/Bestmix/Config.h.example to ios/Bestmix/Config.h and modify it.
- Set WebApiUrl (e.g.
http://localhost:3000/api/v1/
) - Set AuthBaseURL (e.g.
http://localhost:3000/
) - Set ClientID, ClientSecret and RedirectURL same as you saw in the app registration page.
- Set WebApiUrl (e.g.
cd ios; pod install
- Open Bestmix.xcworkspace and build the app
When you register an app to the web API, use your own custom URL schema for the callback URL in the application registration form (e.g. myapp://auth
).
Create a new Xcode project with copying Bestmix.xcodeproj.
% cd ios
% cp -r Bestmix.xcodeproj MyApp.xcodeproj
% find MyApp.xcodeproj -type f | xargs perl -pi -e "s|Bestmix|MyApp|g"
% cp -r Bestmix MyApp
% mv MyApp/Bestmix-Info.plist MyApp/MyApp-Info.plist
% mv MyApp/Bestmix-Prefix.pch MyApp/MyApp-Prefix.pch
Modify the top line of Podfile to use the new Xcode project.
xcodeproj 'MyApp.xcodeproj'
Run pod install
and open MyApp.xcworkspace.
Open target summary tab and set bundle identifier.
Open target info tab and set URL type identifier and URL schema.
Then build and run your app.
Bestmix itself is provided under MIT License and it uses many other libraries. See Gemfile and Podfile.
Send me pull requests.