Monday, 1 October 2012

The Social Framework - Makes the iPhone/iPad App Simple in Facebook and Twitter Posting

Hi All,

For easy sharing of content including images and url's with Facebook, Twitter and Sina Weibo(I am not familiar with this). iOS 6 provides a new framework named Social. 

Now a days in most of the iOS app had a required functionality to share some content in Facebook / Twitter to increase the app acceptability and as advertisement. For achieving this by a formal method the developer has to code separate set of classes to achieve oAuth for each one for Facebook and other for Twitter, as each had their own framework and the developer need to use those classes to communicate with. but for a developer perspective it is very much extravaganza for a simple sharing.

Now everything ends, apple provide a framework for both, effort is very much less and QA effort is also less. cheers Apple!!!!

To Integrate the Facebook / Twitter / SinaWeibo

First add social framework to project.

And import the framework as follows in the class needed to invoke the share action.

#import <Social/Social.h>

Create a SLComposeViewController object with the service type required,

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

Service type available are,


Then we can set the content to share,
- (BOOL)setInitialText:(NSString *)text;
- (BOOL)addImage:(UIImage *)image;
- (BOOL)addURL:(NSURL *)url;

Setting of parameters can be done before the view is presented.

Present the view when needed,
[self presentViewController:controller animated:YES completion:nil];

In iOS6 there is an option to login the Facebook and Twitter if not logged then when a SLComposeView is present it show an alert to tell the user to login.


if you need more details feel free to contact me 

Naveen Shan

No comments:

Post a Comment