Online Book Reader

Home Category

iPhone Game Development - Chris Craft [78]

By Root 1626 0
Application Directory, and there are more than 660,000 registered developers and entrepreneurs from more than 180 countries using the Facebook platform today.

Connecting to Facebook Accounts

Today you can easily find your Facebook friends on any Facebook Connect–enabled iPhone application. You just log in using your Facebook member account on your iPhone. That iPhone application can then access the same information as on the Facebook site, controlled by your privacy settings. You can even publish stories back to your profile, allowing you to share experiences you have from any Facebook Connect–enabled iPhone application.

Figures 6.2, 6.3, and 6.4 show a few of these applications.

FIGURE 6.2

Facebook Connect–enabled application: Agency Wars


FIGURE 6.3

Facebook Connect–enabled application: Tap Tap Revenge


Download the Facebook Connect for iPhone SDK

The first thing you need to do in order to create iPhone applications that can integrate with Facebook is to download the Facebook Connect for iPhone SDK. You should be able to find the zip file you need at the following address:

http://svn.facebook.com/svnroot/platform/clients/packages/fbconnect-iphone.zip

FIGURE 6.4

Facebook Connect–enabled application: Live Poker


Inside the zip file you will find a samples folder and a source code folder named src (Figure 6.5). First you will explore the Facebook Connect sample project, and then you will go through the steps of creating an iPhone application from scratch to integrate with Facebook Connect.

FIGURE 6.5

Facebook Connect for iPhone SDK package


The Facebook Connect sample project

You must open the sample project in Xcode in order to run it. Find the fbconnect-iphone.zip file that you downloaded earlier. Extract the files from the zip file into a folder of your choosing. Open this folder, then open the samples folder, and finally go into the Connect folder. You should now see a file named Connect.xcodeproj. In Figure 6.5, the Connect.xcodeproj file has been selected. Double-click this file to automatically open the project in Xcode.

Now that you have the sample project loaded into Xcode, your screen should look something like Figure 6.6. You can run the sample application by clicking on Build and Go in Xcode. The application should compile and start fine, but you will not be able to connect to Facebook successfully because by default the sample project does not have a correct Facebook API key or application secret. Facebook uses your API key to identify your application. You will need to pass it into any API call you make. The application secret is used by Facebook to authenticate any API calls you make. Effectively these are your applications' user names and passwords, just with fancier names.

FIGURE 6.6

Facebook Connect sample project loaded into Xcode


Registering as a Facebook developer

You must do several things before you can get a Facebook API key of your own. First, if you have not already done so, you need to join Facebook and become a member. Just go to www.facebookcom and sign up. It only takes a few minutes to join.

Once you are a member of Facebook, you need to register as a developer on Facebook. Again, this is a very simple process: Go to the Facebook Developers page at http://developerfacebookcom and click the Start Now button. Be sure to take a few minutes and explore the wealth of information Facebook has to offer developers.

On the Facebook Developers page you can find online documentation, forums, events, information on getting started, and more. It's a good idea to bookmark this site and refer to it frequently as you become more and more familiar creating Facebook-enabled iPhone applications.

After you click the Start Now button on the Facebook Developers page, you are redirected to a special “getting started” page where you are asked to install the Facebook Developer App. Click the Allow button to install the Developer App (Figure 6.7).

FIGURE 6.7

Facebook Developer App prompt


By now you should be a member of Facebook and a registered Facebook developer, and you

Return Main Page Previous Page Next Page

®Online Book Reader