所需积分/C币:9 2011-10-31 14:56:48 28.68MB PDF
收藏 收藏

Contents at a Glance Contents mmmmm iv About the authors ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■ About the technical reviewer Acknowledgments ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ X Preface ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■国■■■■国■■■ Chapter 1: What the Social Graph Can Do for Your App sea ■■■■■■■■■■■■口■ Chapter 2: Privacy, Privacy, Privacy mm RBBIRIBRIB REB RIEIRIR RIB RIaRI RIR mI 9 Chapter 3: Choose Your Weapon ■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■国■ 15 Chapter 4: Getting Set Up ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■日■口■日■■■■■ Chapter 5: Working Securely with OAuth and Accounts ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Chapter 6: Getting Your App Ready for Social Messaging m ImaIImn 65 Chapter 7: Accessing People, Places, Objects, and relationships .amman 81 Chapter 8: POSTing, Data Modeling, and going offline ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 105 Chapter 9: Working with Location Awareness and Streaming Data aim 135 Chapter 10: Using Open Source Tools and other Goodies ■■■■■■■■■■■■■■■■■■■■■■■■■E■ 179 Chapter 11: Apps you can(and cannot) Build mannin 211 Chapter 12: UI Design and Experience Guidelines for Social iOS Apps mm. 235 Chapter 13: Twitter UI Design. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 247 Chapter 14: Facebook Ul Design. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■国■■■■■■■■■■■■■L■■■■■■■■■■■■■■■ a267 ndex ■■■■■■■■■■■■■■■■■■■■■■■■■■■ 281 Chapter What the Social Graph Can Do for Your App Once upon a time, there were social "networks that helped people connect with friends Nowadays, every application and web service can be considered social. Why Simply put, it's because people like to share. Whether it's publishing a high score in a video game or posting a picture where friends can see it, ios users have become accustomed to showing their digital life to their network of friends, family, and colleagues That network of people is called the social graph. a person 's social graph describes everyone he knows and how those people are connected. Since Facebook CEO Mark Zuckerberg coined the term in 2007, the social graph has become more than just who you know. other"nodes "that have been added include places, events brands, and multimedia. All these things can act as vectors by which people connect to one another Facebook and Twitter exist to document the social graph of its users and push them to make new connections. Both companies have powerful incentives to expand the social graph of its users: knowing users' connections and predilections allows them to sell targeted advertisements, deliver recommendations, and initiate partnerships around e commerce and real-world commerce alike For app developers, the opportunities are much the same. Adding Facebook or Twitter functionality to an ioS app can open up vast new opportunities for monetization and new features, but there is plenty of other cool stuff in store, too. Connecting your app to the social graph makes it easier for users to log in, manage their account, and transfer information in and out and both facebook and twitter have built extensive apis and frameworks that can spare developers from having to reinvent the wheel. Facebook, for example, has even made its custom ioS frameworks open source) Both services have audiences of hundreds of millions of users looking to explore. Now that all those folks have invested time building out a Facebook profile or cranking out a stream of tweets, many of them are curious how else they can use their accounts Show them 2 CHAPTER 1: What the Social Graph Gan Do for Your App What s this book for? This book shows ios developers how you can build Facebook and/or twitter into your apps, allowing you to build more secure, flexible, and usable apps. But there is a lot more than just technical guidance here. The chapters of this book will also delve into some of the philosophical questions that go into utilizing the social graph For example, it will address design and branding so that users will recognize the Facebook and Twitter features they love when they're inside your app What youll need This book won't endeavor to teach you how to build an entire ios app from the ground up, so you'll want to have some semblance of an app already built by the time you pick up the Facebook and Twitter APIs. And while we'll be working in trusty ol'Cocoa Touch and objective-C, there will also be plenty of Web stuff that requires JavaScript, HTML, and css. Picking up the aPIs we'll discuss in this book will go more smoothly if you've programmed for the Web before What you should know The social graph is about people. It's about their content, their friends, and their businesses. Some of the interactions you'll encounter are socially sophisticated-you're messing with peoples' relationships here. the way these relationships function online will be hard to understand if you've never spent much time using Facebook or Twitter. If you're thinking about adding one of these APIs to your app, you'l find it worth taking the time to get comfortable with the services. Do this, and you'll gain a more nuanced understanding of the privacy issues (there are many); the platforms(theyre not perfect) and most importantly, an idea of what these things are actually useful for What youll learn By the time you're finished with this book, you 'll know how to build an app that can connect to the world's most popular social Web services quickly, securely, and discreetly. You'll understand how to leverage the social graph to make your software more useful, more fun, and more popular. You'll also see where the weak spots in the platform lie and understand better how the aPls will evolve in the future But perhaps most crucially, you'l understand the beginnings of a significant moment in the development of the Web and the iOS: the coalescence of online life and real life There is immense power being endowed in the Web now as people bring their real-life relationships, experiences, interests, and emotions into the social graph. The more rack space that twitter and facebook build the more user data becomes available to your app. And the better you know the user, the more useful your programs become CHAPTER 1: What the Social Graph Gan Do for Your App Learning the Social Graph o you haven't seen the movie The Social Network, "well save you the trouble. You lon't even know what the thing is yet, Sean Parker says to zuckerberg at the films apogee. And he's absolutely right: no one knows what Facebook is, or what it will become Both Facebook and Twitter, as large and well-funded as they are, are probably still in their incipience. A lot is going to change as business and society come to mold their media, communication, and commerce around these platforms. if you cant think of a killer use-case for Facebook or Twitter in your app at this stage in the game, don't worry-you're only on page three. It may take some thinking(and plenty of prototy ping before you understand how to put the social graph to the best possible use in your app But that's okay because everyone else is in the same boat To get your brain on its way to ginning up good ideas, we'll cover some very basic things you can do with Facebook and Twitter inside an app by manipulating their APls Use-Cases, Briefly There are plenty of things that an iOS application can get from Facebook and Twitter APls. Some very basic use cases consist of, but are not limited to, what's described in the following sections. You'll learn how to do all the things described in these sections in this book; you'l also learn how to concoct much more complex use cases Facebook Here are some examples that illustrate how a developer could use facebook inside a hypothetical app Upload a photo or a video created in a camera app to a user's profile Post a link to a content within a news app to a user's wall Post likes to a user's wall from inside a shopping app Post a status update to a user's profile Display a list of a user' s friends and their profile photos in a contacts application Let a user set herself as attending an event from within an application Show users who else is at an event from inside an app Display search results of public Facebook data, so that users can search for people, places, or content CHAPTER 1: What the Social Graph Gan Do for Your App Twitter Here are some examples that illustrate how a developer could use Twitter inside a hypothetical app Tweet a link to an event from within a location-based app Tweet a photo from with a photo editing app Send direct messages to specific Twitter users Show tweets that are relevant to a topic within a news application Display a list of a user's followers and followees and their profiles in a contacts application Automatically tweet a users location from within a GPs application Organize a group or community around your app Show tweets about a restaurant in a food guide application Publicize a high score in a game Search up to the minute news or photos Use trends or trending topics as input Brief overview of the aPls and services Facebook and T witter are both robust platforms, but they don't always let you do what 'ou want. If you already have some idea of what you want to add to your app, here are basic summaries of what these platforms allow Facebook The Facebook API is currently in an ongoing, transitional phase. The original Facebook API was a Representational State Transfer(REST) API, but this aPI is being phased out and is officially deprecated All Facebook development moving forward should use facebook's new graph aPl the Graph aPI is where you will find support for all new and future Facebook features, and it is continuously updated to include the full set of original features from the REST API Note that the graph APl only supports responses as JavaScript object Notation ( JSON) objects a basic summary of these apls follows Reading This aPI provides access to the basic information stored in the Facebook graph CHAPTER 1: What the Social Graph Gan Do for Your App Publishing This APl enables you to add comments, likes, and so on to the Facebook Grapl Searching This API allows you to search public objects in the social graph, such as all public posts people, events, places, and so on allofthefacebookapisarehttpbased,sodataisretrievedviaanhttpgetanddata issubmittedviaanhttppost To make the lives of ios developers easier, Facebook also makes available an iOS Objective-C Facebook SDK. This SDK is open source and functions as a wrapper around the Facebook Http-bAsed Graph apL. This book will use the ios objective-c Facebook Sdk , but will refer back to the Http Apls where appropriate or wherever they provide additional insight Twitter Twitter's API has evolved to be somewhat segmented-it was mostly developed in- house, but augmented by major code infusions that were purchased from third-parties The result is an api that consists of two representational state t ranster(rest)APls, a Core API and a Search APl, and one Streaming APl. twitter's API supports both XML and JSoN formats, but we will be using the default XML format when discussing technical details and when showing example code. A basic summary of these APIs Core APl This API provides the basic Twitter functionality of twitter. com tweet, follow, and timeline Search Apl This API provides a real-time search index of Twitter and global and local trends Streaming APl This Apl is currently designed primarily for server-to-server integrations via Http long- poll connections, and it provides tweets in real-time. Twitter is in the process of experimenting with server-to-client integrations via this aP Alloftheaplsarehttp-basedandusageisratelimitedJustlikeFacebookdatain Twitter is retrieved via an Http get and data is submitted via an Http post 6 CHAPTER 1: What the Social Graph Gan Do for Your App Note that Twitter has gone to great lengths to adhere to the following principles when developing each of these aPls: To be ridiculously simple ■ To be obvious ■ To be self- describing The social Graph on iOS Back when it was known as the iPhone OS, Apple's mobile platform didnt offer much to social graph applications, which weren't allowed to achieve anything close to parity with a desktop experience. But slowly, Apple began giving more power to its devices and more tools to developers. Now with multitasking and a new Sleep mode, ios 4 has empowered social apps to evolve even deeper functionality. In the process, Apple has solved some very deep usability problems with rather elegant(if sometimes limited solutions Sure, you can do a lot of the stuff we'll talk about in this book with other platforms, but it won't work as well (or look as good)as it will on the ios. Here are some of the new goodies that come with ios 4: Multitasking allows your app to go about its business in the background. Whatever your app does, it can keep on doing it without the user needing to manually activate it Better spell-check and text-replacement options make data entry easier means that ios devices can continue to perform Web-related I WiFi connections now have limited persistence in Sleep mode operations when the device isn't being used NOTE: When an app is running in the background on iOS, it can't perform all its functions in that state. For reasons relating to reliability and battery life apple has chosen to restrict background processing to the seven specific APls(see Chapter 10 for more information on this topic) Other changes introduced in ios 4 will make programming for the social graph more robust. Some of those changes include the following Local notifications lOS has had Push notifications for a while, but now Apple has introduced Local notifications, too. These alerts dont travel through apple,s Push server, but instead reside on the device itself, waiting in the background until it's time to pop out at the Iser. The notification that someone is calling you on Skype is an example of a Local notification CHAPTER 1: What the Social Graph Gan Do for Your App Task Completion If a task is underway when a user exits an app, ios can now register that thread and keep it going in the background, even after the user has moved on to doing something else. Keeping that single thread open allows the user to shut down the remainder of the app, releasing most of the memory back to the system ioS will shut the app down completely once that task is done Fast Task Switching and Saved State Before iOs 4, it was very difficult to build a persistent app that would save the users progress upon exit. saved states are now recommended for all ios apps. This means that when a user returns to an app, the app's current state has been preserved in memory and appears just as the user left it. This functionality is managed by the new task switcher" that appears when you double-tap the Home button This state-saving is especially useful when apps call other apps, such as when a user chooses to compose an email from inside an app. After the email is sent, the app the user was using when she initiated the email will return to the screen, just as she left it Background Music, Location, and VOIP Apple has also made provisions for music, location-based, and voiP apps to continue operations in the background while the user navigates through other apps. This means that music can continue playing, and"check-in"apps can be notified of a change of yenue-even when the user is outside a music or location app. VolP apps can deliver notifications (for incoming phone calls, for example), which makes telephony more robust, too SMS: Search and in-app SMSing Apple has created a new API with ios 4 that allows in -app sms composition inside third-party apps. There's no unified messaging service, as on other platforms, but Facebook's new Messages service might serve as a stand-in More powerful photos and calendars Apple has granted developers new access to the Calendar app, allowing third-party apps to create events inside a user's calendar. Apple has also added developer access to the device's entire photo and video library, not just the "image picker"available in the old os New camera and flash The iPhone's rear-tacing camera now supports zoom and adjustable focus, and developers have also been given access to the front-facing camera that appears on new

试读 127P Beginning.iOS.Apps.with.Facebook.and.Twitter.APIs
限时抽奖 低至0.43元/次
身份认证后 购VIP低至7折
csilsy 全英文版本 看起来贼累
  • 至尊王者

关注 私信
Beginning.iOS.Apps.with.Facebook.and.Twitter.APIs 9积分/C币 立即下载

试读结束, 可继续阅读

9积分/C币 立即下载