-
Notifications
You must be signed in to change notification settings - Fork 448
Upgrading
NOTE: From v3.4.0 and higher, please make sure to remove all references to TwitterShareExtensionUI
in your project settings if they are not already removed by Cocoapods. You may notice a TwitterShareExtensionUI
resource bundle file in the "Build Phases" section of your project section, please remove this.
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.
If you had previously been calling
[Fabric with:@[[Twitter class]]]
or
Fabric.with([Twitter.self])
in your app delegate, you
will need to call
TWTRTwitter.sharedInstance().start(consumerKey:consumerSecret:)
instead. You will pass along the consumerKey
and
consumerSecret
for your Twitter app. See
Installation <./installation> for more information.
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).
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
.
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 <./compose-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 <basic-composer> .
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.
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.
- [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 theverify_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.
- [Removed] Guest authentication methods were removed from the
Twitter
instance because the guest authentication logic is now automatically handled byTwitter Kit
. If you still need to manage guest authentication on your own see ios-guest-login for more information. - [Removed] The
-[Twitter logInWithExistingAuthToken:authTokenSecret:completion:]
was removed from theTwitter
instance. If you want to migrate existing OAuth tokens use the-[TWTRSessionStore saveSession:completion:]
method instead. - [Removed] The
APIClient
property was removed from theTwitter
instance. AnAPIClient
can be instantiated directly without the need to use the shared instance. See construct-api-client for more information. - [Removed] The
logOut
method andsession
property were removed from theTwitter
instance, use the methods that are available on theTWTRSessionStore
instead.
- [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 ofNSNotifications
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 returnsYES
the view controller will be presented but ifNO
is returned the view controller will not be presented and the developer can proceed however they want. For more information see show-detail-view for more information.