rails as a backend for an ios application
DESCRIPTION
Lightning talk given to Vancouver Ruby Meetup group on Mar 28, 2013TRANSCRIPT
![Page 1: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/1.jpg)
Rails as a Backend for an iOS Application
Ian MacKinnonVancouver Ruby Meetup Lightning Talks
Mar. 28, 2013
Thursday, 28 March, 13
![Page 2: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/2.jpg)
We’ll be Talking About
• Authentication
• REST access
• Notifications
Thursday, 28 March, 13
![Page 3: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/3.jpg)
Authentication
• https://github.com/applicake/doorkeeper
• has slightly outdated Railscast
• now supports Mongoid
• OAuth development environment can be a pain b/c of port number w/ simulator (RestKit ignores it)
• Most iOs libraries will keep a regular session
Thursday, 28 March, 13
![Page 4: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/4.jpg)
RESTKit
• Your go-to for remote object loading and persisting (can even integrate with coredata!)
• Handles JSON/XML to object mapping
• Gotchas:
• Rails expects nested attributes for params
• Need root JSON element for mapping
• JSON payload size matters
Thursday, 28 March, 13
![Page 5: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/5.jpg)
Configure RestKit to POST with a root path
Thursday, 28 March, 13
![Page 6: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/6.jpg)
Thursday, 28 March, 13
![Page 7: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/7.jpg)
Ease up on JSON Size
• Normal for application to be run on 3G
• Override a model’s as_json to determine the model attributes that will be sent across wire
Thursday, 28 March, 13
![Page 8: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/8.jpg)
APNS (push notifications)
• Used to suck but there’s a pretty awesome gem now
• Grocer (https://github.com/grocer/grocer)
• “There are other gems out there to do this, but grocer plans to be the cleanest, most extensible, and friendliest.”
• Different Gateways for Dev and Production
• Token identifies a device, not a user
Thursday, 28 March, 13
![Page 9: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/9.jpg)
Grocer
Thursday, 28 March, 13
![Page 10: Rails as a Backend for an IOS Application](https://reader034.vdocuments.site/reader034/viewer/2022052622/559351581a28abc4028b45dc/html5/thumbnails/10.jpg)
MISC
• SSL Certificates are worth it
• Parse is an alternative way of getting up and running quick
• But you might need a web presence too
• Kind of hard to migrate when you have a bunch of apps pointing to api.parse.com
Thursday, 28 March, 13