Twitter and Facebook Connect

Beyond sending emails, you may want to also give users the ability to post messages to their Twitter and Facebook accounts. And although it's nice when users blatantly promote your app, another more subtle way to increase awareness for your app is to deeply integrate social networking with other core features in your app. For example, if you're building a game, enabling users to share their high scores via Twitter and Facebook will not only breed synergy among players but may also attract new customers who want to get in on the action. NimbleBit's Moon Drop includes a seamless user option for Tweeting high scores (see Figure 4-18). A more comprehensive extension of community building is to integrate one of the many social gaming platforms currently available for iPhone games, which I'll be talking about in Chapter 5. For now, let's look at Twitter and Facebook.

Figure 4-18. Alter finishing a game in NimbleBit's Moon Drop, users are prompted to tweet about their high scores.

Many open source iPhone Twitter clients are available for download. A quick online search reveals at least a dozen of them. Many of them appear to rely on the popular open source framework, MGTwitterEngine, developed by prominent Cocoa developer Matt Legend Gemmell. Originally developed for Mac OS X software applications, Matt's Twitter framework has since been updated for use in iPhone app projects.

MGTwitterEngine is an Objective-C class library that encompasses the entire Twitter API and returns data as native Cocoa objects, making it extremely easy to use. And you'll be happy to know that Matt's license terms are very generous, allowing developers to use MGTwitterEngine royalty-free in commercial products. All he requires is that you credit him as the author of the MGTwitterEngine code included in your app. Of course, if you find his code helpful, I suggest emailing him a personal "thank you" or posting a comment on his blog. Open source developers put a lot of hard work into their contributed code, so they always appreciate knowing when people find their efforts useful.

For details on how to use MGTwitterEngine, visit Matt's blog. You can download the source code from his Subversion repository. For those who don't know, Subversion is a popular open source version control system. If you don't have Subversion installed or need help using it, check out http://subversion.tigris.org/.

■ Mike Legend Gemmell's MGTwitterEngine:

http://mattgemmell.com/2008/02/22/mgtwitterengine-twitter-from-cocoa

■ Download MGTwitterEngine: http://svn.cocoasourcecode.com/MGTwitterEngine/

■ Matt's Source License: http://mattgemmell.com/license

Facebook allows developers to access their platform using their Facebook Connect API Recently, it released Facebook Connect for the iPhone, and already some iPhone apps in the App Store are taking advantage of Facebook Connect's extensive features. Having access to your list of friends and their profile information, as well as connecting with them in real time, brings the full power of the Facebook platform into your iPhone app. It may seem like overkill to integrate such an extensive framework into your Xcode project just so your users can post status updates to their Facebook page. But if you're developing an iPhone game or any kind of peer-to-peer community app, you may soon find yourself utilizing additional Facebook Connect features in other parts of your project.

The beauty of Facebook Connect is that you, the developer, need not worry about programming a secure environment for users to share their personal data. Facebook Connect handles the security for you by providing users with Facebook's simple and trusted authentication process for logging into their accounts.

On the official Facebook Connect for iPhone web site, Facebook provides links for downloading the SDK, reading the documentation, and even watching the online video How to Implement Facebook Connect on the iPhone in 5 Minutes.

■ Facebook Connect for iPhone: http://developers.facebook.com/connect_iphone.php

Before you can use the Facebook Connect SDK in your iPhone app, you'll first need an API key and secret in order to authenticate your Facebook Connect requests. This requires you to have an active Facebook account of your own. Once logged into your account, visit the following Facebook Developer site:

■ Facebook Developer: My Applications: http://www.facebook.com/developers/apps.php

On that Developer web page, click the Set Up New Application button to create a new Facebook application. Be sure to give it the same name as the iPhone app you're building since that application name will be listed as the source when users post status updates from your iPhone app. This is a subtle yet effective way to get your app's name displayed on users' Facebook pages—great exposure for your app.

Once your new Facebook application is created on their Developer site, the application's "Essential Information" will list your unique API key and secret. Save those two text strings in a safe place because you'll need them when customizing the Facebook Connect code in your own iPhone app.

App Rejection Warning: Your app must notify users when an online connection attempt fails. If your app relies on connecting with a third-party web service, you must include appropriate error-handling code so that in the case of a failed connection or data request, your app handles the failure gracefully and notifies the users of the current status. If a bad data request freezes your app or leaves the user waiting without any indication of what's happening, then the App Store review team will most likely reject your submission. If you provide a demo account for use during the review process, make sure that demo account works! Or provide two demo accounts, just in case one fails during the review. It's also a good practice to always notify users if and when your app requires an online connection, especially since iPod touch devices may not always be logged into a WiFi network.

Now you're ready to integrate social networking into your own iPhone apps! Following the documentation and example code included with the MGTwitterEngine framework and the Facebook Connect for iPhone SDK, see whether you can add support for posting to Twitter and Facebook in the existing Tell A Friend example project. I bet you'll have it up and running in no time!

Continue reading here: Google AdSense for Mobile Applications

Was this article helpful?

0 0