Mobilizing Your Rails Application - LA Ruby Conference 2009

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

1 comments

Comments 1 - 1 of 1 previous next Post a comment

Post a comment
Embed Video
Edit your comment Cancel

9 Favorites

Mobilizing Your Rails Application - LA Ruby Conference 2009 - Presentation Transcript

  1. Mobilize Your Rails Application
    • Brendan Lim
    • e-mail: [email_address]
    • twitter: @brendanlim
  2.  
  3. Why care about mobile
    • There’s an estimated 2.9 billion mobile users
    • Over 255 million mobile users in the U.S.
    • In developing nations, a mobile phone is sometimes their only way to connect to the Internet
  4. Some mobile stats (in billions of course)
  5. So, how do we take advantage of this?
  6. Make your application accessible by the majority of web enabled mobile devices devices devices
  7. Keep your users engaged through SMS , MMS and E-Mail E-Mail
  8. Many Mobile Devices Can Access the Real Web From Flickr User Carlos Magaña
  9. One Web Making the same information and services available to all users regardless of the device used Making the same information and services available to all users regardless of the device used
    • Max resolution?
    • JavaScript?
    • Flash?
    • Connection speed?
    • Processor speed?
    Problems with one web
  10. Mobile Fu Plugin
    • Can detect if a user is on a mobile device
    • Ability to add custom styling based on the device’s user agent
    • Gives you some tools to make the concept of one web easier to achieve
  11. How does one master mobile fu?
  12. Not Like This ...
  13. Maybe Like This ...
  14. class ApplicationController < ActionController::Base has_mobile_fu end end
  15. demo. presentlyapp.com iPhone Safari
  16. respond_to do | format | format.html format.mobile end
    • views/
    • layouts
      • application.html.erb
      • application.mobile.erb
    • sessions
      • new.html.erb
      • new.mobile.erb
  17. <%= mobile_xhtml_doctype %> <html> <head> ... </head> <body> ... </body> </html> </html> ../layouts/ application.mobile.erb http://mobiforge.com/designing/story/comparison-xhtml-mobile-profile-and-xhtml-basic
  18. <?xml version=&quot;1.0&quot; charset=&quot;UTF-8&quot; ?> <!DOCTYPE html PUBLIC &quot;-//WAPFORUM//DTD XHTML Mobile 1.0//EN&quot; &quot; http://www.wapforum.org/DTD/xhtml-mobile10.dtd &quot;> <html> <head> ... </head> <body> ... </body> </html> </html> ../layouts/ application.mobile.erb http://mobiforge.com/designing/story/comparison-xhtml-mobile-profile-and-xhtml-basic
  19. Is the user using a specific device? is_device?( ‘blackberry’ ) Is the user using a mobile device? is_mobile_device? Is the request format currently :mobile ? in_mobile_view?
  20. iPhone foo_ mobilewebkit .css <%= stylesheet_link_tag 'foo' %> Android foo_ mobilewebkit .css BlackBerry foo_ blackberry .css Win Mobile foo_ mobileexplorer .css etc...
  21.  
  22. What about leveraging other mobile technologies ?
  23. SMS Short Message Service Short Message Service
  24. Keep Users Informed with SMS
    • Text messages are read by about 94% of their recipients.
    • Supported by almost all mobile phones out there
    • Good for quick notifications
    • Generally limited to 160 characters
    • Relatively easy to leverage
  25. What tools can we use to send SMS messages from our Rails application?
  26. Clickatell Gem
    • Paid solution
    • Uses Clickatell’s API
    • Currently $0.043 per text message sent within the U.S.
    • No need to know the recipient’s carrier
  27. api = Clickatell::API.authenticate(' your_api_id ', ' your_username ', ' your_password ') api.send_message(' 5558675309 ', ' Hello from clickatell ') require 'clickatell'
  28. SMS Fu Plugin
    • Doesn’t cost the sender anything
    • Leverages ActionMailer to send a text message
    • You need to know the recipient’s carrier
    • Not as many supported carriers as Clickatell
  29. Wait, it’s free? So how does it work?
  30. Number: 555-867-5309 5558675309 @ vtext.com Carrier: Verizon
  31. deliver_sms(‘ 5558675309 ’,‘ verizon ’, ‘ hello! ’) class AwesomeController < ApplicationController has_sms_fu end end
  32. Some SMS Fu Carriers Alltell, Ameritech, AT&T, Bell South Mobility, BlueSkyFrog, Boost Mobile, Cellular South, Kajeet, Metro PCS, Powertel, PSC Wireless, Qwest, Southern Link, Spring, Rodgers, Suncom, T-Mobile, Virgin Mobile, Verizon Wireless , E-Plus, O2, Orange, Telconica, Vodafone ...
  33. What if I want to add a new carrier called Ruby Mobile ?
  34. carriers: ... ruby_mobile: name: Ruby Mobile value: @txt.rubymobile.com Add the following to .../config/sms_fu.yml deliver_sms(‘ 5558675309 ’,’ ruby_mobile ’, ‘ hello! ’)
  35. Remind Your Users That They May Get Charged from flickr user ‘bowbrick’
  36. MMS Multimedia Message Service Multimedia Message Service
  37. MMS
    • Can send photo, video, audio or other attachments
    • Most commonly used for photos
    • Attachment size limitation generally dependent on device
    • Multipart MIME
  38. The Problem with Receiving MMS Crap Crap Crap Cat
  39. Well, how can I receive SMS or MMS from my Rails app ?
  40. Short Codes Special numbers that are, you guessed it, short, that can be used to receive SMS or MMS messages from mobile phones. Special numbers that are, you guessed it, short, that can be used to receive SMS or MMS messages from mobile phones.
  41.  
  42. Short Codes
    • Also referred to as short numbers
    • MMS support added in this year
    • Crazy Expensive
      • Monthly fees up to $1000/mo
      • Setup fees close to $5000
    • Many companies share short codes
  43. Receiving SMS or MMS as an e-mail is another solution and its free and relatively simple
  44. MMS2R Gem
    • Removes carrier advertising
    • Eliminates carrier default text
    • Decodes and extracts intended files from the multipart MIME e-mail
    • Most major carriers are supported
  45. Retrieve only the intended attachment mms.default_media Retrieve all media files from the MMS mms.media Retrieve only the intended message mms.body Create a new MMS2R object from a TMail object mms = MMS2R::Media.new(email)
    • require ‘ mms2r ’
    • class MailReceiver < ActionMailer::Base
    • def receive (email)
    • begin
        • # load the TMail object into an MMS2R::Media object
        • mms = MMS2R::Media .new(email)
        • # grab a user on record by the e-mail it was sent from
        • user = User .find_by_email(mms.from)
        • # store the body of the mms into a new BlogPost
        • blog_post = BlogPost .create(: body => mms.body, : user => user,
          • : title => mms.subject)
        • # grab the attachment from the mms message
        • media = mms.default_media
        • # store the attachment from mms into a BlogPhoto
        • BlogPhoto .create(: uploaded_data => media, : blog_post => blog_post) if
          • media.content_type.include?(‘ image ’)
      • ensure
        • # cleans up temporary files used for text and attachments
        • mms.purge
      • end
    • end
    • end
    • require ‘ mms2r ’
    • class MailReceiver < ActionMailer::Base
    • def receive (email)
    • begin
        • # load the TMail object into an MMS2R::Media object
        • mms = MMS2R::Media . new (email)
        • # grab a user on record by the e-mail it was sent from
        • user = User .find_by_email(mms.from)
        • # store the body of the mms into a new BlogPost
        • blog_post = BlogPost .create(: body => mms.body, : user => user,
          • : title => mms.subject)
        • # grab the attachment from the mms message
        • media = mms.default_media
        • # store the attachment from mms into a BlogPhoto
        • BlogPhoto .create(: uploaded_data => media, : blog_post => blog_post) if
          • media.content_type.include?(‘ image ’)
      • ensure
        • # cleans up temporary files used for text and attachments
        • mms.purge
      • end
    • end
    • end
    • require ‘ mms2r ’
    • class MailReceiver < ActionMailer::Base
    • def receive (email)
    • begin
        • # load the TMail object into an MMS2R::Media object
        • mms = MMS2R::Media .new(email)
        • # grab a user on record by the e-mail it was sent from
        • user = User .find_by_email( mms.from )
        • # store the body of the mms into a new BlogPost
        • blog_post = BlogPost .create(: body => mms.body, : user => user,
          • : title => mms.subject)
        • # grab the attachment from the mms message
        • media = mms.default_media
        • # store the attachment from mms into a BlogPhoto
        • BlogPhoto .create(: uploaded_data => media, : blog_post => blog_post) if
          • media.content_type.include?(‘ image ’)
      • ensure
        • # cleans up temporary files used for text and attachments
        • mms.purge
      • end
    • end
    • end
    • require ‘ mms2r ’
    • class MailReceiver < ActionMailer::Base
    • def receive (email)
    • begin
        • # load the TMail object into an MMS2R::Media object
        • mms = MMS2R::Media .new(email)
        • # grab a user on record by the e-mail it was sent from
        • user = User .find_by_email(mms.from)
        • # store the body of the mms into a new BlogPost
        • blog_post = BlogPost .create(: body => mms.body ,
          • : user => user, : title => mms.subject )
        • # grab the attachment from the mms message
        • media = mms.default_media
        • # store the attachment from mms into a BlogPhoto
        • BlogPhoto .create(: uploaded_data => media, : blog_post => blog_post) if
          • media.content_type.include?(‘ image ’)
      • ensure
        • # cleans up temporary files used for text and attachments
        • mms.purge
      • end
    • end
    • end
    • require ‘ mms2r ’
    • class MailReceiver < ActionMailer::Base
    • def receive (email)
    • begin
        • # load the TMail object into an MMS2R::Media object
        • mms = MMS2R::Media .new(email)
        • # grab a user on record by the e-mail it was sent from
        • user = User .find_by_email(mms.from)
        • # store the body of the mms into a new BlogPost
        • blog_post = BlogPost .create(: body => mms.body, : user => user,
          • : title => mms.subject)
        • # grab the attachment from the mms message
        • media = mms. default_media
        • # store the attachment from mms into a BlogPhoto
        • BlogPhoto .create(: uploaded_data => media, : blog_post => blog_post) if
          • media.content_type.include?(‘ image ’)
      • ensure
        • # cleans up temporary files used for text and attachments
        • mms.purge
      • end
    • end
    • end
    • require ‘ mms2r ’
    • class MailReceiver < ActionMailer::Base
    • def receive (email)
    • begin
        • # load the TMail object into an MMS2R::Media object
        • mms = MMS2R::Media .new(email)
        • # grab a user on record by the e-mail it was sent from
        • user = User .find_by_email(mms.from)
        • # store the body of the mms into a new BlogPost
        • blog_post = BlogPost .create(: body => mms.body, : user => user,
          • : title => mms.subject)
        • # grab the attachment from the mms message
        • media = mms.default_media
        • # store the attachment from mms into a BlogPhoto
        • BlogPhoto .create(: uploaded_data => media , : blog_post => blog_post) if media . content_type .include?(‘ image ’)
      • ensure
        • # cleans up temporary files used for text and attachments
        • mms.purge
      • end
    • end
    • end
    • require ‘ mms2r ’
    • class MailReceiver < ActionMailer::Base
    • def receive (email)
    • begin
        • # load the TMail object into an MMS2R::Media object
        • mms = MMS2R::Media .new(email)
        • # grab a user on record by the e-mail it was sent from
        • user = User .find_by_email(mms.from)
        • # store the body of the mms into a new BlogPost
        • blog_post = BlogPost .create(: body => mms.body, : user => user,
          • : title => mms.subject)
        • # grab the attachment from the mms message
        • media = mms.default_media
        • # store the attachment from mms into a BlogPhoto
        • BlogPhoto .create(: uploaded_data => media, : blog_post => blog_post) if
          • media.content_type.include?(‘ image ’)
      • ensure
        • # cleans up temporary files used for text and attachments
        • mms. purge
      • end
    • end
    • end
  46. Adding new templates for carriers is easy
    • ---
    • ignore:
    •    image / gif:
    •    - top.gif
    •    - bottom.gif
    •    - middle_img.gif
    •    text / html:
    •     - /< html > s +< head > s +< meta http - equiv = &quot;Content-Type
      • &quot; content=&quot;text/html; charset=iso-8859-1&quot;>s+<title>MMS Email</title>/im
    • transform:
    •    text / plain:
    •    - - / Note:s{1,2}. *? s + message:s{1,2}(. + )$ / m
    •      - &quot;1&quot;
    conf/mms.myhelio.com.yml
  47. Mobilizing your Rails app is simple and easy
  48. Mobile Fu http://github.com/brendanlim/mobile-fu/ Clickatell http://clickatell.rubyforge.org/ SMS Fu http://github.com/brendanlim/sms-fu/ MMS2R http://github.com/monde/mms2r/
  49. Questions!

+ Brendan LimBrendan Lim, 2 years ago

custom

1850 views, 9 favs, 0 embeds more stats

Mobilize Your Rails Application - Slides from talk more

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 1850
    • 1850 on SlideShare
    • 0 from embeds
  • Comments 1
  • Favorites 9
  • Downloads 62
Most viewed embeds

more

All embeds

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories