Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-07-2010, 12:22 AM   #2 (permalink)
rocotilos
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Quote:
Originally Posted by AmanApps View Post
Yesterday I shared my helper class on paginating data.

Today I am will share how my use facebook connect to use in iPhone apps.

Problem of the approach described in facebook conenct website:
1. need to change the project settings include path
2. need to write lots of code to show login prompt, publish code, ask permission , update status etc.

Though these does not seem to be problematic but it really kills time if you are developing quite a few apps and integrating facebook connect into them.

I just encapsulated all the reusable code into a single class and a protocol for required callbacks like what should be done if logged in/out, facebook username fetched by query etc.


For example, say I want to update status.
1. first I need to write code to show login prompt
2. then i need to write code to show permission dialog
3. and then i need to write the code to update user facebook status.

but using facebook agent it is just one line of code!

Code:
// fbAgent is an instacne of FacebookAgent
[fbAgent setStatus:@"My new status"]
for publishing feed there are many methods, one is:

Code:
/**
 * Let the agent make attachement for you. You just pass the information
 *
 */
- (void) publishFeedWithName:(NSString*)name 
			 captionText:(NSString*)caption 
					   imageurl:(NSString*)url 
						linkurl:(NSString*)href
			  userMessagePrompt:(NSString*)prompt;
FacebookAgent will check if the user is logged in, if not it will show the login in prompt.
Once logged in, it will show the permission dialog if not given permission earlier.
Then it will update the user status.

I can also define some delegate method to work on some events like:

Code:
/**
 * This method is called if after login or logout
 */
- (void) facebookAgent:(FacebookAgent*)agent loginStatus:(BOOL) loggedIn;

/**
 * Must define this method if uploadPhoto is called
 *
 * This method is called after photo is uploaded
 */
- (void) facebookAgent:(FacebookAgent*)agent photoUploaded:(NSString*) pid;
....
//etc

More detail with sample code is available in this page:

All code is free to use without any obligation even for closed source commercial projects but I will appreciate if you let me know.
Hi Aman.. thanks a lot for this.. i have not tried it.. but sure will be useful. Im giving it a try soon.
rocotilos is offline   Reply With Quote
 

» Advertisements
» Online Users: 271
19 members and 252 guests
ADY, apatsufas, BdR, Diegan, Duncan C, F_Bryant, glenn_sayers, Guthook, ilmman, joeallenpro, ketaskin, Music Man, NSeven, rodgo, Sunny46, VikMyr, vogueestylee, zbynda, ziocleto
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,876
Threads: 89,225
Posts: 380,708
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jorge599
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:06 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.