Online Book Reader

Home Category

iPhone Game Development - Chris Craft [79]

By Root 1516 0
should have the Facebook Developer App installed on your Facebook account. In order for a Facebook-enabled iPhone application to function correctly, it must have a Facebook application available to connect to on Facebook itself.

Creating a Facebook application

You can get a basic Facebook application up and running in a matter of minutes. In the bottom-left corner of Facebook you should see an Applications button. If you click this and choose the Facebook Developer application, which you added to your profile earlier, you should see a Set Up New Application button in the upper-right corner. Click this button to make your new Facebook application. You are then taken to the Create Application page, where you need to assign your new Facebook application a name, as shown in Figure 6.8. You can use the name iPhone Test App or another name of your own choosing. You will have to agree to the Facebook Terms of Service. Once you have entered all of the necessary information, click the Save Changes button to proceed.

You have just created a new Facebook application and are now on the Edit iPhone Test App page (Figure 6.9). Here you can edit and configure your iPhone Test App as needed. At first you might be a little overwhelmed by all the options being presented to you, but there is nothing to be concerned about. You can keep the default settings for most options for this sample project. After you become more familiar with the Facebook API, you can come back and take advantage of some of the more advanced options available here.

FIGURE 6.8

Create Application page


FIGURE 6.9

Edit iPhone Test App page


Although it is safe to leave most of the iPhone Test App's options on their default settings, it's a good idea to familiarize yourself with what the most important ones are. At the very least, you will want to be aware of the following settings:

Application Name. This is where you assign the name for your Facebook application.

Application ID. This is the unique ID that Facebook assigns to your application.

API Key. This is your public API key. You need to set this in your iPhone application.

Secret. You also need to set your application secret in your iPhone application.

Description. This is the public description for your application.

Icon. This is the 16 x 16 icon that is displayed on Facebook next to your application's name.

Logo. This is the 75 x 75 image that is shown in the Facebook Application Directory.

Language. This is the language that text in your application is in.

Developers. This is a list of Facebook members who have developer access to this application.

Take some time and explore all the additional developer options available to you. These are located in the tabs on the left-hand side of the iPhone Test App page: Basic, Authentication, Profiles, Canvas, Connect, Widgets, and Advanced. One setting of special note is the Sandbox Mode, which can be enabled or disabled from the Advanced Settings section under the Advanced tab. When an application is in Sandbox Mode (Figure 6.10), it is visible only to developers.

Once you have finished updating your Facebook application's settings, click the Save Changes button on the bottom of the screen.

Tip

Facebook allows you to set up accounts to use for testing purposes. You can learn more about Facebook test accounts at http://wiki.developers.facebook.com/index.php?title=Test_Accounts.

FIGURE 6.10

The Sandbox Mode option is located on the Advanced tab.


Setting the Facebook API key and application secret

You are now ready to return to the Facebook Connect sample project in Xcode and update the project to use your Facebook API key and application secret. On icon folder to expand it, and then click on the Source folder. Choose the SessionViewController.m file, as shown in Figure 6.11.

FIGURE 6.11

Update Facebook API key and secret


You should see a section of code that matches the following listing:

#import “SessionViewController.h”

#import “FBConnect/FBConnect.h”

////////////////////////////////////////////////////////////////////////////////

Return Main Page Previous Page Next Page

®Online Book Reader