Changes

Jump to: navigation, search

Integrating Twitter and Facebook into iOS 7 Applications

45 bytes added, 19:56, 27 October 2016
m
Text replacement - "<table border="0" cellspacing="0">" to "<table border="0" cellspacing="0" width="100%">"
<googlehtmlet>BUY_IOS7ios9_upgrade</googlehtmlet>
When using the SLRequest class to construct API requests, it will be necessary to use the Accounts framework to identify and request permission to use the corresponding social network accounts in an application. When using the UIActivityViewController or SLComposeViewController classes, however, the account handling is performed automatically by the class. The remainder of this chapter will focus on the UIActivityViewController and SLComposeViewController classes. The SLRequest class will be covered in detail in the chapter entitled [[iOS 7 Facebook and Twitter Integration using SLRequest]].
== Using the UIActivityViewController Class==
The UIActivityViewController class is instantiated within an application at the point at which a posting is ready to be made to a social network. Once the user takes an action to post an update from within an application, the screen shown in Figure 79 -2 will appear listing the options that are available:<googlehtmlet>ADSDAQBOX_FLOWadsdaqbox_flow</googlehtmlet>
[[Image:ios_7_social_share.png|The iOS 7 UIActivityViewController sheet]]
In the event that the user has not yet configured an account for the selected social network in the Settings application, a dialog will appear providing the option to either set up an account or cancel the post.
<googlehtmlet>BUY_IOS7ios9_upgrade</googlehtmlet>
The assumption is generally made that at the point an instance of UIActivityViewController is created, the application will already have gathered together the text and images that are to be included in the post. These items need to be placed into an NSArray object and passed to the controller before it is presented to the user. The following code excerpt, for example, instantiates a UIActivityViewController instance primed with text and an image to be included in the post and presents it to the user:
NSString *postText = @”My first Facebook post from iOS 7”;
<googlehtmlet>BUY_IOS7ios9_upgrade</googlehtmlet>
 
<htmlet>ezoicbottom</htmlet>
<hr>
<table border="0" cellspacing="0" width="100%">

Navigation menu