You are previewing Beginning iOS Apps with Facebook and Twitter APIs: For iPhone, iPad, and iPod touch.
O'Reilly logo
Beginning iOS Apps with Facebook and Twitter APIs: For iPhone, iPad, and iPod touch

Book Description

Beginning iOS Apps with Facebook and Twitter APIs shows you how to add the power of social networking to your mobile apps on iPhone, iPad, and iPod touch. With this book as your guide, you can write apps that connect to Facebook and Twitter quickly, securely, and discreetly. Instead of starting from scratch, you will build on the vast resources, data storage capacity, and familiar features of these platforms which have become part of everyday life for hundreds of millions of users worldwide.

Beginning iOS Apps with Facebook and Twitter APIs introduces you to the development tools, techniques, and design practices you will need to work with the APIs. It helps you decide whether to use Facebook, Twitter, or both, and explains the important issues of design, branding, and permissible use guidelines. You will learn how to guarantee privacy and use OAuth for authentication and single sign-on.

Create news apps, shopping apps, contact apps, GPS apps, guides, and more, that let users transparently:

  • Sign on once, then freely work with and manage their Facebook and Twitter accounts

  • Publish game high scores, post likes, links, and status updates

  • Send messages, share pictures, and forward Tweets

  • Tweet a link to an event, show themselves as attending, and see who else is there

  • Show Tweets that are relevant to a topic within a news app

  • Show Tweets about a restaurant

  • Organize a group or community

From time to time, new forms of communication come along that make it easier for people to communicate and manage their social lives. Like phone calls and SMS before them, Facebook and Twitter have, in a short time, become essential parts of the social fabric of life for an ever-growing number of people throughout the world. The knowledge you'll gain from Beginning iOS Apps with Facebook and Twitter APIs will help you create exciting and popular iOS apps that your users will rely on every day to help make their lives more meaningful and connected.

What you'll learn

  • How to integrate these social networks' APIs into your code

  • How to run multitasking apps and run streamlined background processes

  • When and how to use Oauth for authentication

  • How to connect your users to each other

  • How and where to publish and request data and media from the social graph

  • How to work with JSON, push notifications and other data interchanges

  • How to take advantage of open-source software like Google Wrappers and Google Toolbox

  • How to iterate quickly when using the UIWebView controller

  • How to specify visual & interaction design that is consistent with the design of the platforms (for both iPad and iPhone)

Who this book is for

This book is for iPhone and iPad developers who already know the fundamentals of iOS development and want to add social networking functionality to their apps.

Table of Contents

  1. Copyright
  2. About the Authors
  3. About the Technical Reviewer
  4. Acknowledgments
  5. Preface
  6. 1. What the Social Graph Can Do for Your App
    1. 1.1. What Is This Book for?
      1. 1.1.1. What You'll Need
      2. 1.1.2. What You Should Know
      3. 1.1.3. What You'll Learn
    2. 1.2. Learning the Social Graph
      1. 1.2.1. Use-Cases, Briefly
        1. 1.2.1.1. Facebook
        2. 1.2.1.2. Twitter
    3. 1.3. Brief Overview of the APIs and Services
      1. 1.3.1. Facebook
        1. 1.3.1.1. Reading
        2. 1.3.1.2. Publishing
        3. 1.3.1.3. Searching
      2. 1.3.2. Twitter
        1. 1.3.2.1. Core API
        2. 1.3.2.2. Search API
        3. 1.3.2.3. Streaming API
      3. 1.3.3. The Social Graph on iOS
        1. 1.3.3.1. Local Notifications
        2. 1.3.3.2. Task Completion
        3. 1.3.3.3. Fast Task Switching and Saved State
        4. 1.3.3.4. Background Music, Location, and VOIP
        5. 1.3.3.5. SMS: Search and in-app SMSing
        6. 1.3.3.6. More Powerful Photos and Calendars
        7. 1.3.3.7. New Camera and Flash
        8. 1.3.3.8. Map Overlays
        9. 1.3.3.9. iAd
        10. 1.3.3.10. Quick Look
        11. 1.3.3.11. Math APIs
        12. 1.3.3.12. File Transfer
    4. 1.4. Summary
  7. 2. Privacy, Privacy, Privacy
    1. 2.1. The Old Way
    2. 2.2. A Quick History of Hot-Button Issues
      1. 2.2.1. Facebook's Track Record
      2. 2.2.2. Twitter's Track Record
    3. 2.3. How OAuth Changes Everything
      1. 2.3.1. A New Standard Emerges
    4. 2.4. What Users "Want"
    5. 2.5. Educating Your Users
    6. 2.6. A Note on Feeds
    7. 2.7. What to Do if You Encounter a Security Loophole
    8. 2.8. Summary
  8. 3. Choose Your Weapon!
    1. 3.1. What Are They Good For?
      1. 3.1.1. Facebook
      2. 3.1.2. Twitter
    2. 3.2. Getting Started with Facebook's Awesome Developer Tools
      1. 3.2.1. Using Facebook's API
        1. 3.2.1.1. Making API Calls
        2. 3.2.1.2. Displaying Dialogs
        3. 3.2.1.3. Error Handling
        4. 3.2.1.4. Logging Out
    3. 3.3. Twitter's Less Awesome (but Still Great!) Tools
      1. 3.3.1. Using MGTwitterEngine
        1. 3.3.1.1. Making API Calls
        2. 3.3.1.2. Error Handling
        3. 3.3.1.3. Using ShareKit
    4. 3.4. Summary
  9. 4. Getting Set Up
    1. 4.1. Git 'Er Dun
      1. 4.1.1. Github.com
      2. 4.1.2. Installing Git
        1. 4.1.2.1. Git Basics
        2. 4.1.2.2. Bookmark These Twitter Resources
        3. 4.1.2.3. Also Bookmark These Facebook Resources
          1. 4.1.2.3.1. A Note on Bug Tracking
    2. 4.2. Hello Facebook
      1. 4.2.1. Creating a Project
        1. 4.2.1.1. Adding the Facebook iOS SDK Source Code
        2. 4.2.1.2. Add UIViewController
    3. 4.3. Hello Twitter
      1. 4.3.1. Creating a Project
        1. 4.3.1.1. Adding the MGTwitterEngine Source Code
        2. 4.3.1.2. Add UIViewController
    4. 4.4. Now, on to Security
  10. 5. Working Securely with OAuth and Accounts
    1. 5.1. OAll OAbout OAuth
      1. 5.1.1. How OAuth Works
        1. 5.1.1.1. OAuth in Facebook and Twitter
    2. 5.2. OAuth in Facebook
      1. 5.2.1. Single Sign-On with Facebook
        1. 5.2.1.1. Logging in to Facebook
        2. 5.2.1.2. Logging out of Facebook
        3. 5.2.1.3. Determining if iOS Supports Backgrounding of Applications
    3. 5.3. OAuth in Twitter
      1. 5.3.1. Creating a Twitter Application
        1. 5.3.1.1. The OAuthTwitter Project
        2. 5.3.1.2. Logging into Twitter
        3. 5.3.1.3. Logging out of Twitter
        4. 5.3.1.4. Under the Hood: webViewDidFinishLoad
    4. 5.4. There's More
  11. 6. Getting Your App Ready for Social Messaging
    1. 6.1. Introducing the Facebook Graph API
      1. 6.1.1. A Little Help from Our Friends
      2. 6.1.2. Paging Graph Responses
      3. 6.1.3. Under the Hood: The FBRequest Class
        1. 6.1.3.1. A General Note on Error Handling
    2. 6.2. Introducing the Twitter APIs
      1. 6.2.1. Welcome to the Timeline
        1. 6.2.1.1. It Always Feels Like Somebody's Following Me
      2. 6.2.2. Under the Hood: MGTwitter HTTP Connections and XML Parsing
    3. 6.3. Conclusion
  12. 7. Accessing People, Places, Objects, and Relationships
    1. 7.1. More Fun with the Facebook Graph API
      1. 7.1.1. Facebook Dialogs
      2. 7.1.2. Under the Hood: The FBDialog Class
      3. 7.1.3. Posting to Facebook and Authorization
      4. 7.1.4. Getting More Goodies from the Facebook Graph
      5. 7.1.5. Limiting Results
        1. 7.1.5.1. Date Formatting
    2. 7.2. More Fun with the Twitter API
      1. 7.2.1. A Tweetin' We Will Go
      2. 7.2.2. Under the Hood: Twitter URLs
      3. 7.2.3. The Twitter Dev Console
    3. 7.3. Conclusion
  13. 8. POSTing, Data Modeling, and Going Offline
    1. 8.1. Strike a Pose
      1. 8.1.1. Saving a Picture to the iOS Simulator's Photo Library
      2. 8.1.2. Working with UIImagePickerController
      3. 8.1.3. ImagePostController
      4. 8.1.4. Facebook Photo Upload
      5. 8.1.5. Twitter Photo Upload
        1. 8.1.5.1. GSTwitPicEngine
        2. 8.1.5.2. ASIHTTPRequest
        3. 8.1.5.3. SBJSON
        4. 8.1.5.4. OARequestHeader
      6. 8.1.6. Post a Photo
    2. 8.2. Offline Paradigm and Background Processing
      1. 8.2.1. Data Modeling with TwitterDataStore
        1. 8.2.1.1. Updating the View from the Model
    3. 8.3. Conclusion
  14. 9. Working with Location Awareness and Streaming Data
    1. 9.1. Here, There, and Everywhere
      1. 9.1.1. Location Privacy, Disclosure, and Opt-Out
      2. 9.1.2. Facebook Places
      3. 9.1.3. Adding Locations to Tweets
      4. 9.1.4. Power Hungry
      5. 9.1.5. CoreLocation
        1. 9.1.5.1. Using CLLocationManager
      6. 9.1.6. Generating Locations in the iOS Simulator
        1. 9.1.6.1. iSimulate
        2. 9.1.6.2. futuretap's FTLocationSimulator
      7. 9.1.7. MapKit
      8. 9.1.8. Facebook Places (Search), Check-ins (Getting and Posting), and Friends Nearby
      9. 9.1.9. Tweetin' With Location
    2. 9.2. Conclusion
  15. 10. Using Open Source Tools and Other Goodies
    1. 10.1. The Shorter, the Better
      1. 10.1.1. Using URL Shorteners in iOS
    2. 10.2. ShareKit: Sometimes Quick and Dirty Does the Trick
      1. 10.2.1. Getting Started with ShareKit
    3. 10.3. All the Latest Twitter Trends
      1. 10.3.1. Trending Topics
      2. 10.3.2. Where On Earth ID
    4. 10.4. Offline Storage Revisited: SQLite
      1. 10.4.1. Reimplementing OfflineTwitter Without Core Data
    5. 10.5. To Test or Not to Test, That is the Question
      1. 10.5.1. Adding Unit Tests to a Social iOS App
    6. 10.6. Conclusion
  16. 11. Apps You Can (and Cannot) Build
    1. 11.1. Twitter: No Clients Allowed
      1. 11.1.1. The Lowdown on the Twitter Terms of Service
        1. 11.1.1.1. Rules of the Road
          1. 11.1.1.1.1. Using the API
          2. 11.1.1.1.2. What Your App Can Do
          3. 11.1.1.1.3. Rules Governing Existing Twitter Clients
          4. 11.1.1.1.4. How Twitter Defines Usability
          5. 11.1.1.1.5. Login and Identity
          6. 11.1.1.1.6. Monetizing Your App
          7. 11.1.1.1.7. Twitter Ads
          8. 11.1.1.1.8. Advertising Around Twitter Content
        2. 11.1.1.2. New Rate Limits and the End of Whitelisting
    2. 11.2. REST API Rate Limiting
    3. 11.3. Facebook: Mind Your Manners
      1. 11.3.1. The Lowdown on Platform Policy
      2. 11.3.2. Creating a Great User Experience
      3. 11.3.3. Be Trustworthy
        1. 11.3.3.1. Rate Limits
        2. 11.3.3.2. For Your Privacy Policy
        3. 11.3.3.3. Other Stuff
        4. 11.3.3.4. Rules About Content
        5. 11.3.3.5. Other Odd Rules About How Facebook Apps Must Work
      4. 11.3.4. The Principles in Action
        1. 11.3.4.1. Photos
        2. 11.3.4.2. The Like Button
        3. 11.3.4.3. Advertising
        4. 11.3.4.4. Using the Social Stream
        5. 11.3.4.5. Button Text
    4. 11.4. App Gallery
      1. 11.4.1. Twitter Apps
        1. 11.4.1.1. Remember The Milk
          1. 11.4.1.1.1. Adding Tasks
          2. 11.4.1.1.2. Sending Tasks to Other Twitter Users
          3. 11.4.1.1.3. Updating Tasks
          4. 11.4.1.1.4. Changing Preferences
        2. 11.4.1.2. Evernote
          1. 11.4.1.2.1. SMS notes
          2. 11.4.1.2.2. Adding TwitPics
        3. 11.4.1.3. Waze
      2. 11.4.2. Facebook Apps
        1. 11.4.2.1. Fone
        2. 11.4.2.2. Flipboard
    5. 11.5. Conclusion
  17. 12. UI Design and Experience Guidelines for Social iOS Apps
    1. 12.1. UI Basics for Facebook and Twitter
      1. 12.1.1. Attention to Detail: Start with the Icons
      2. 12.1.2. Show All Kinds of Feedback
      3. 12.1.3. Touch Targets and Text
      4. 12.1.4. Prototype and Test
      5. 12.1.5. What the User Wants from Your App
        1. 12.1.5.1. Content
        2. 12.1.5.2. A Logical Path
        3. 12.1.5.3. Obvious Settings
        4. 12.1.5.4. Branding
        5. 12.1.5.5. Brevity
        6. 12.1.5.6. A License Agreement
        7. 12.1.5.7. Appropriate iPad Design
      6. 12.1.6. Make Usage Easy and Obvious
    2. 12.2. Conclusion
  18. 13. Twitter UI Design
    1. 13.1. Usability Priorities
      1. 13.1.1. Anatomy of a Tweet
        1. 13.1.1.1. Suggested Components
      2. 13.1.2. (Not) Using Twitter Colors
        1. 13.1.2.1. Create Theme Elements
      3. 13.1.3. Using the Twitter Trademark
        1. 13.1.3.1. Advertising in the App Store
        2. 13.1.3.2. We Don't Know You
    2. 13.2. Twitter Navigation Paradigms
      1. 13.2.1. Twitter Logos and Icons
        1. 13.2.1.1. Splash Screens
      2. 13.2.2. Visual Assets (a.k.a., the Exceptions)
      3. 13.2.3. Naming Your Project
      4. 13.2.4. Offline Display Guidelines
      5. 13.2.5. Working with Notifications
      6. 13.2.6. Design Tricks from the Web App
    3. 13.3. Conclusion
  19. 14. Facebook UI Design
    1. 14.1. Usability Priorities
      1. 14.1.1. Themes and Icons
        1. 14.1.1.1. Third Party Resources
        2. 14.1.1.2. Create Theme Elements
          1. 14.1.1.2.1. Hootsuite
          2. 14.1.1.2.2. Taptu
      2. 14.1.2. Rules for Facebook Art
        1. 14.1.2.1. Button Text
      3. 14.1.3. Facebook Navigation
      4. 14.1.4. Showing Progress
      5. 14.1.5. Essential Three20 Components
      6. 14.1.6. Design Tricks from the Web App
        1. 14.1.6.1. The Tabbed Approach
    2. 14.2. Conclusion