Giter Club home page Giter Club logo

bestmix's Introduction

Bestmix

Bestmix is a boilerplate code of iOS app, Android app and Rails-based backend. You can use it as a basic structure to build your own mobile app and backend web API integrated with each other. They are connected with JSON REST API supporting CRUD, pagination, caching, OAuth2 and Facebook integration.

The sample app is a simple blog engine.

Architecture

bestmix_architecture

Screenshots

Features

Server-Side

  • Generating JSON from DB records
  • HTTP caching
  • Basic authentication with Email and passwrod
  • Facebook login
  • Call Facebook API using authorized token
  • OAuth2 authorization for web API
  • API versioning
  • Admin UI

iOS App

  • JSON REST web API integration
  • Getting OAuth2 token and refreshing it behind the scenes
  • Storing authorized token in Keychain
  • Parsing JSON response
  • Importing JSON objects into Core Data as local cache
  • Pagination and incremental loading
  • HTTP caching
  • Checking reachability and display object cache if it is offline

Android App

Android app is still under early development.

  • JSON REST web API integration using IntentService
  • Getting OAuth2 token and refreshing it behind the scenes

These features are implemented using libraries listed below.

Libraries

Server-Side

See Gemfile for more details

iOS App

See Podfile for more details.

Android App

  • Gson - Java Objects -> JSON Converter
  • Scribe - OAuth Library

Requirements

Server-Side

  • Ruby >= 1.9
  • MySQL (you can use another DB server by editing Gemfile)

iOS App

  • iOS >= 5.0
    • requries ARC and Storyboard

Android App

  • Android >= 4.0

Setup

Server-Side

  1. Install Ruby on Rails and RVM if you don't have them.
  2. Copy server/config/database.yml.example to server/config/database.yml and modify it.
  3. 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 and APP_SECRET.
  4. cd server; bundle; rake db:setup; rake db:migrate
  5. rails s # (or setup your web server such as Apache, nginx, etc.)
  6. Open URL http://localhost:3000/ to see the web app.
  7. Open URL http://localhost:3000/admin to see the admin page.

Register iOS App to Web API

Open admin page: http://localhost:3000/admin and click "Applications".

admin_dashboard

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.

admin_new_app

When you submit the form, app ID and secret will be published as below. They are used in the iOS app's config file.

admin_create_app

iOS App

  1. Install mogenerator and make it executable from Xcode (e.g. ln -s /opt/brew/bin/mogenerator /usr/bin/mogenerator)
  2. Install CocoaPods
  3. 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.
  4. cd ios; pod install
  5. Open Bestmix.xcworkspace and build the app

Develop Your Own App

Server-Side

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).

iOS App

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.

ios_summary

Open target info tab and set URL type identifier and URL schema.

ios_url

Then build and run your app.

License

Bestmix itself is provided under MIT License and it uses many other libraries. See Gemfile and Podfile.

Future Plan

  • Android app features equivalent to iOS app
  • Image uploading
  • Push notification
  • Twitter integration
  • Testing ...current test codes are not enough.

Contributing to Bestmix

Send me pull requests.

Using Pull Requests · github:help

bestmix's People

Contributors

yatsu avatar

Watchers

Jason Young avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.