KBComposeSocial provides custom iOS-style dialog boxes for posting to Facebook and Twitter.
The SDK can be configured to capture any of four different media types:
- Text only
- Text and an image array
- Text and a URL array
- Text, an image array and a URL array
A delegate protocol, with two optional callbacks, is provided:
@protocol KBComposeViewControllerDelegate @optional - (void)composeViewControllerDidPressCancel:(id)sender; - (void)composeViewControllerDidPressPost:(id)sender; @end
Clients using the SDK should implement and use the composeViewControllerDidPressPost:
API to link with the Facebook and/or Twitter Social SDK implementation of their choice.
THIS SOFTWARE DOES NOT ACTUALLY POST TO FACEBOOK OR TWITTER!
Rather, it offers user interface controls you can use to capture text, images and urls from your users.
Clients wishing to forward collected information onto the social networks must link with the Facebook and/or Twitter Social SDK implementation of their choice in the composeViewControllerDidPressPost:
API.
You can present a Facebook dialog box using code similar to the following:
KBComposeViewController *comp = [KBComposeViewController composeViewControllerForServiceType:KBServiceTypeFacebook]; [comp setInitialText:@"Hello, Facebook!"]; [comp setDelegate:self]; [self displayViewController:comp];
Running this code would cause the user to be presented with a dialog box similar to the following:
To respond to the input entered by the user, you would implement the composeViewControllerDidPressPost:
API as follows:
- (void)composeViewControllerDidPressPost:(id)sender { KBComposeViewController *controller = (KBComposeViewController*)sender; NSLog(@"++ This is text: %@", controller.text); NSLog(@"++ This is image array: %@", controller.images); NSLog(@"++ This is url array: %@", controller.urls); NSLog(@"++ This is number of attachments: %d", controller.attachmentsCount); // TODO: Extract text, images and urls, and post to Facebook/Twitter using your SDK }
This code will be invoked when the user presses the Post
button, which is the desired behavior.
KBComposeSocial is designed to run on all iOS devices (iPhone4, iPhone5 and iPad) and on all iOS versions from 4.3 and up.
KBComposeSocial is designed to be used on ARC-enabled projects.
KBComposeSocial requires linking with the QuartzCore framework.
This code is distributed under the terms and conditions of the MIT license.
Version 1.1 @ February 11, 2015.
- Support for iOS7, iOS8.
- Other minor updates.
Version 1.0 @ January 18, 2014.
- Initial Release.