Tuesday, February 15, 2011

iPhone sdk facebook twitter sharing integrate very easily in your app.

sharing is that part of app where you dont want to wast time and skill as we dont want any other functionality that it is in hundreds of other apps. Social sharing in your iPhone app can be done very easily sharekit ,which is available for free, content can be modified.kit can be integrated easily with your app. this can be downloaded from here

I'm going to tell you the the easy and independent integration of each service (facebook , twitter. etc)
- download kit from here.
- Open the Example project , drag drop shrekit folder from example project to you project.
Make sure the "Copy items into destination group's folder (if needed)" checkbox is checked.
- Add frameworks
  1. SystemConfiguration.framework
  2. Security.framework
  3. MessageUI.framework
- Fill you API keys
get api's from respective services ,by just signing up your app.Open SHKConfig.h from Sharekit folder
At the top you'll find a list of services that require api keys.
Each service has a link next to it.
Follow the link for each service to get an api key.
Fill in the api key for each corresponding service within SHKConfig.h.

- Use following methods

-(IBAction)shareOnTwitter

{


UIImage *image=[UIImage imageNamed:@"Default.png"];

SHKItem *item = [SHKItem image:image title:nil];

twitterController = [[SHKTwitter alloc]init];

twitterController.item = item;


if ([twitterController isAuthorized])

{

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Already Logged In" delegate:self

cancelButtonTitle:nil

destructiveButtonTitle:@"Logout"

otherButtonTitles:@"Upload",nil];

actionSheet.tag = 40;//facbook

[actionSheet showInView:self.view];

[actionSheet release];


}

else

{

[twitterController share];

}

}

-(IBAction)shareOnfacebook

{

UIImage *image = [self getImage];

SHKItem *item = [SHKItem image:image title:@"Birthday eCards"];

fbController = [[SHKFacebook alloc]init];

fbController.item = item;


if ([fbController isAuthorized])

{

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:str

delegate:self

cancelButtonTitle:nil

destructiveButtonTitle:@"Logout"

otherButtonTitles:@"Upload",nil];

actionSheet.tag = 20;//facbook

[actionSheet showInView:self.view];

[actionSheet release];

}

else

{

[fbController share];

}

}

}

#pragma mark -

#pragma mark actionSheet delegate Methods


- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex

{

if (actionSheet.tag == 20)//facebook

{

if (buttonIndex == 0)

{

[SHKFacebook logout];

[fbController share];

}

else if(buttonIndex == 1)

{

[fbController share];

}

}

if (actionSheet.tag == 40)//twitter

{

if (buttonIndex == 0)

{

[SHKTwitter logout];

}

else if(buttonIndex == 1)

{

[twitterController share];

}

}

}


- Done ..it can be done for other services

No comments:

Post a Comment