Example Mobile Push Notification Service in Rails
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,682
On Slideshare
2,681
From Embeds
1
Number of Embeds
1

Actions

Shares
Downloads
21
Comments
0
Likes
5

Embeds 1

http://localhost 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Create Your Own: Mobile Push-Notification Service Monday, January 13, 14
  • 2. Starting Point • To expedite the tutorial process, I’ve already created three models: • User • Device • Permitted Apps Monday, January 13, 14
  • 3. app/models/user.rb app/models/device.rb Monday, January 13, 14
  • 4. app/models/permitted_app.rb Permitted App Migration Monday, January 13, 14
  • 5. User and Device Migrations Monday, January 13, 14
  • 6. Step 2(ish): Routes config/routes.rb lib/app_constraints.rb Monday, January 13, 14
  • 7. Behold, a versioned API So, /api/users/ will default to version 1 of our API. Is this a good idea? There’s a LOT of discussion about versioning APIs... http://apiux.com/2013/05/14/api-versioning/ https://mathieu.fenniak.net/aint-nobody-got-time-for-that-api-versioning/ http://railscasts.com/episodes/350-rest-api-versioning Do what feels comfortable / correct. I’m not too keen on having a default API route which may change behind-the-scenes, and inadvertently break applications that use the API. Monday, January 13, 14
  • 8. Controllers and Authentication Monday, January 13, 14
  • 9. Controllers cont. Additional info http://railscasts.com/episodes/350-rest-api-versioning?view=asciicast http://collectiveidea.com/blog/archives/2013/06/13/building-awesome-rails-apis-part-1/ http://railsware.com/blog/2013/04/08/api-with-ruby-on-rails-useful-tricks https://github.com/rails-api/active_model_serializers Monday, January 13, 14
  • 10. Authentication Additional info http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html http://railscasts.com/episodes/352-securing-an-api?view=asciicast Monday, January 13, 14
  • 11. Authentication in Action Monday, January 13, 14
  • 12. Cool, we have a Users Resource which is accessible via the routes we’ve created on /api/users... what does that have to do with sending push-notifications to phones? Monday, January 13, 14
  • 13. How do Push Notifications work? (iOS) Phase 1 Good documentation of the process can be found on Adobe’s site for Adobe AIR (seriously) http://www.adobe.com/devnet/air/articles/ios-push-notifications.html Monday, January 13, 14 Phase 2
  • 14. Next, install a background processing system of your choice https://www.ruby-toolbox.com/categories/Background_Jobs Monday, January 13, 14
  • 15. iOS worker for Sidekiq Monday, January 13, 14
  • 16. Android worker for Sidekiq Monday, January 13, 14
  • 17. Final example • • A final example with some additional features is available [1] • Primary Gems used: Much credit is due to Ryan Bates for the API skeleton [2] and authentication implementation [3], and wellwithme.com for their original Android/iOS push notifications tutorial. [4] • • • • • Sidekiq Sidetiq Grocer • Friendly ID GCM Active Model Serializers [1] https://bitbucket.org/momer/example-mobile-pns/src [2] http://railscasts.com/episodes/350-rest-api-versioning [3] http://railscasts.com/episodes/352-securing-an-api [4] http://blog.wellwith.me/how-to-send-ios-and-android-notifications-from-your-rails-backend Monday, January 13, 14