Upgrading to Twitter Kit 3.0¶
It is important to note that Twitter Kit 3.0 supports iOS 9+. Please do not upgrade to Twitter Kit 3.0 if your project needs to be built for iOS versions less than 9.0.
With Twitter Kit 3.0, changes have been made to how Twitter API keys are managed. Please refer to Upgrading from Fabric for details.
Twitter Kit 3.0 includes a number of new, changed, and removed methods that must be taken into consideration when upgrading from 2.x. The sections below outline these changes. A full list of changes can be viewed in the changelog.
Twitter Kit Initialization¶
If you had previously been calling
[Fabric with:@[[Twitter class]]] or
Fabric.with([Twitter.self]) in your app delegate, you will need to call
Twitter.sharedInstance().start(consumerKey:consumerSecret:) instead. You will pass along the
consumerSecret for your Twitter app. See Installation for more information.
Simplification of Log in methods¶
If you had been calling
-[Twitter logInWithMethods:completion:] or
-[Twitter logInWithViewController:methods:completion:] methods directly, you can now use the simplified
-[Twitter logInWithCompletion:] and
-[Twitter logInWithViewController:completion:] methods instead. There is no longer any need to specify
TWTRLoginMethods since all login calls now allow the user to add another user (
TWTRLoginMethodWebBasedForceLogin is no longer required) and the login methods in Twitter Kit 3 all support showing Twitter permission requests (including email, if your app has enabled it).
Search timeline result type¶
TWTRSearchTimelineDataSource has received a new
resultType property to more closely match the standard Twitter Search API. This replaces the existing
topTweetsOnly Boolean property.
The new options to match the standard REST API are
mixed, with the default value being
Removal of Twitter App Card support¶
The ability to compose app cards from the
TWTRComposerViewController has been removed. You had been been creating app cards in your application, you can continue to use the
TWTRComposerViewController, but will have to provide your image as an attachment to the Tweet, and add your App Store link to the Tweet text. Please see Twitter App Cards for more about app cards, and Composing Tweets for more about the new composer.
If you are still using
TWTRComposerViewController, note that it is the responsibility of the developer to ensure that there is a valid logged-in session in Twitter Kit. You can see further details here: Composing Tweets .
Removal of Tweet detail view¶
Twitter Kit 3.0 now allows users to click hashtags, cashtags, and mentions directly from within the
TWTRTweetView without requiring users to click into the
TWTRTweetDetailViewController. This new interaction will open the Twitter iOS app by default if it is installed, and will call
openURL: to proceed to Safari if not. This will allow users to get more context for the content of the Tweets they see in your app.
If you had been using the
TWTRTweetDetailViewControllerDelegate you may instead implement
[TWTRTweetViewDelegate tweetView:didTapTweet:] which allows developers to override the default behavior for tapping a Tweet.
Upgrading to Twitter Kit 2.0¶
It is important to note that Twitter Kit 2.0 supports iOS 8+. Please do not upgrade to Twitter Kit 2.0 if your project needs to be built for iOS versions less than 8.0.
Twitter Kit 2.0 includes a number of new and deprecated methods that must be taken into consideration when upgrading from 1.x. The sections below outlines these changes. A full list of changes can be viewed in the changelog.
Requesting user email¶
- [Removed] The
TWTRShareEmailViewControllerclass has been removed from Twitter Kit in version 2.0. If you still require access to the email address associated with the account you must use the web based OAuth login flow and request the email address via the
verify_credentialsendpoint, see Request User Email Address for more information. When the user is presented with the web based authentication flow they will be shown which permissions the application is requesting.
Removal of deprecated methods on Twitter instance¶
- [Removed] Guest authentication methods were removed from the
Twitter Kit. If you still need to manage guest authentication on your own see Guest Authentication for more information.
- [Removed] The
-[Twitter logInWithExistingAuthToken:authTokenSecret:completion:]was removed from the
-[TWTRSessionStore saveSession:completion:]method instead.
- [Removed] The
APIClientproperty was removed from the
APIClientcan be instantiated directly without the need to use the shared instance. See Construct a Twitter API Client for more information.
- [Removed] The
sessionproperty were removed from the
TWTRTweetView delegate methods¶
- [New] Version 2.0 removed several delegate methods from the
TWTRTweetViewDelegateprotocol. Most of the methods that were removed were used for metrics related purposes and did not provide any mechanism for overriding functionality. These methods have been replaced in favor of
NSNotificationswhich will allow developers to isolate their metrics logic from their controller logic.
- [New] The notable exception to this is the removal of the
-[TWTRTweetViewDelegate tweetView:didSelectTweet:]method. This method was replaced with
-[TWTRTweetViewDelegate tweetView:shouldDisplayDetailViewController:]method which provides more value by allowing developers to customize the default implementation or provide their own behavior. If this method is not implemented a modal view controller will be presented when a Tweet view is tapped. If it is implemented developers can decide whether the detail view controller should be presented; if the delegate method returns
YESthe view controller will be presented but if
NOis returned the view controller will not be presented and the developer can proceed however they want. For more information see Show Standalone Tweets in a Detailed View for more information.