CSSocial is an iOS social sharing library supporting Facebook, Twitter and Google+ CSSocial framework was built to make use of social services like Facebook, Twitter or Google+ safe and easy to implement by the programmer. We were frustrated that every time we needed to integrate a social service into the app, each programmer did it his own way and usually spent more than an hour doing so. The decision was to make a one-line-of-code-do-magic solution which took only a couple of minutes to set up and run.
- clone the CSSocial.git to CSSocial directory on your Mac
- open your XCode project where you want to add the social features
- drag&drop CSSocial.framework to Frameworks - check copy
- drag&drop CSSocial.plist to Supporting Files - check copy
- open CSSocial.plist and enter your parameters
ID | Parameter | Description |
---|---|---|
1 | CSSOCIAL_FACEBOOK_APP_ID | Facebook App ID |
2 | CSSOCIAL_TWITTER_CONSUMER_KEY | Twitter Consumer Key |
3 | CSSOCIAL_TWITTER_CONSUMER_SECRET | Twitter Consumer Secret |
4 | CSSOCIAL_FACEBOOK_PERMISSIONS_READ | Facebook read permissions |
5 | CSSOCIAL_FACEBOOK_PERMISSIONS_PUBLISH | Facebook publish permissions |
6 | CSSOCIAL_GOOGLEPLUS_CLIENT_ID | Google+ Client ID |
add the following frameworks to your XCode project
- Accounts.framework
- AdSupport.framework
- CFNetwork.framework
- MobileCoreServices.framework
- Security.framework
- Social.framework
- SystemConfiguration.framework
- libsqlite3.0.dylib
- libz.1.2.5.dylib
Posting a message to Facebook wall can be done by calling a single method like this. If you haven't handled the login or permissions process yourself, CSSocial handles it for you automagically:
[CSFacebook postToWall:@"Test"
completionBlock:^(CSSocialRequest *request, id response, NSError *error)
{
}];
If you assign a handler block, you will receive a response or an error if one has occured during the posting process.
Posting an image with a caption is done like this
[CSFacebook postPhoto:[UIImage imageNamed:@"test"]
caption:@"test"
completionBlock:^(CSSocialRequest *request, id response, NSError *error) {
}];
Showing a Facebook dialog (as available depending on the platform )
[CSFacebook showDialogWithMessage:@"test"
photo:[UIImage imageNamed:@"test"]
handler:^(NSError *error) {
}];
If you assign a handler block, you will receive an error if user cancels the dialog or if something goes wrong while posting.
Posting a tweet to Twitter can be done calling a single method like this:
[CSTwitter tweet:@"test"
completionBlock:^(CSSocialRequest *request, id response, NSError *error) {
}];
Showing a Twitter dialog (as available depending on the platform )
[CSTwitter showDialogWithMessage:@"test"
photo:[UIImage imageNamed:@"test"]
handler:^(NSError *error) {
}];
If you assign a handler block, you will receive an error if user cancels the dialog or if something goes wrong while posting.
Showing a Google+ dialog (as available depending on the platform )
[CSGoogle showDialogWithMessage:@"test"
photo:[UIImage imageNamed:@"test"]
handler:^(NSError *error) {
}];
If you assign a handler block, you will receive an error if user cancels the dialog or if something goes wrong while posting. For more information on errors, see here.