Upgrading

Upgrading to Twitter Kit 3.0

Note

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.

Note

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 consumerKey and 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

The 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 recent, popular, or mixed, with the default value being mixed.

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

Note

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 TWTRShareEmailViewController class 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_credentials endpoint, 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 instance because the guest authentication logic is now automatically handled by 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 Twitter instance. If you want to migrate existing OAuth tokens use the -[TWTRSessionStore saveSession:completion:] method instead.
  • [Removed] The APIClient property was removed from the Twitter instance. An APIClient can be instantiated directly without the need to use the shared instance. See Construct a Twitter API Client for more information.
  • [Removed] The logOut method and session property were removed from the Twitter instance, use the methods that are available on the TWTRSessionStore instead.

TWTRTweetView delegate methods

  • [New] Version 2.0 removed several delegate methods from the TWTRTweetViewDelegate protocol. 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 NSNotifications which 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 YES the view controller will be presented but if NO is 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.