Inherits from NSObject
Declared in Twitter.h

Overview

The central class of the Twitter Kit.

Note: This class can only be used from the main thread.

Properties

authConfig

Authentication configuration details. Encapsulates the consumerKey and consumerSecret credentials required to authenticate a Twitter application.

@property (nonatomic, readonly) TWTRAuthConfig *authConfig

Declared In

Twitter.h

sessionStore

Session store exposing methods to fetch and manage active sessions. Applications that need to manage multiple users should use the session store to authenticate and log out users.

@property (nonatomic, readonly) TWTRSessionStore *sessionStore

Declared In

Twitter.h

version

The current version of this kit.

@property (nonatomic, copy, readonly) NSString *version

Declared In

Twitter.h

Class Methods

sharedInstance

Returns the Twitter singleton.

+ (Twitter *)sharedInstance

Return Value

The Twitter singleton.

Declared In

Twitter.h

Instance Methods

application:openURL:options:

Finish the SFSafariViewController authentication loop. This method should be called from application:openURL:options inside the application delegate.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options

Parameters

application

The UIApplication instance received as a parameter.

url

The NSURL instance received as a parameter.

options

The options dictionary received as a parameter.

Return Value

Boolean specifying whether this URL was handled by Twitter Kit or not.

Discussion

This method will verify an authentication token sent by the Twitter API to finish the web-based authentication flow.

Declared In

Twitter.h

logInWithCompletion:

Triggers user authentication with Twitter.

- (void)logInWithCompletion:(TWTRLogInCompletion)completion

Parameters

completion

The completion block will be called after authentication is successful or if there is an error.

Discussion

This method will present UI to allow the user to log in if there are no saved Twitter login credentials. This method is equivalent to calling loginWithMethods:completion: with TWTRLoginMethodAll.

Warning: This method requires that you have set up your consumerKey and consumerSecret.

Declared In

Twitter.h

logInWithViewController:completion:

Triggers user authentication with Twitter. Allows the developer to specify the presenting view controller.

- (void)logInWithViewController:(nullable UIViewController *)viewController completion:(TWTRLogInCompletion)completion

Parameters

viewController

The view controller that will be used to present the authentication view.

completion

The completion block will be called after authentication is successful or if there is an error.

Discussion

This method will present UI to allow the user to log in if there are no saved Twitter login credentials.

Warning: This method requires that you have set up your consumerKey and consumerSecret.

Declared In

Twitter.h

startWithConsumerKey:consumerSecret:

Start Twitter with your consumer key and secret. These will override any credentials present in your applications Info.plist.

- (void)startWithConsumerKey:(NSString *)consumerKey consumerSecret:(NSString *)consumerSecret

Parameters

consumerKey

Your Twitter application’s consumer key.

consumerSecret

Your Twitter application’s consumer secret.

Discussion

You do not need to call this method unless you wish to provide credentials other than those in your Info.plist.

Declared In

Twitter.h

startWithConsumerKey:consumerSecret:accessGroup:

Start Twitter with a consumer key, secret, and keychain access group. See [Twitter startWithConsumerKey:consumerSecret:]

- (void)startWithConsumerKey:(NSString *)consumerKey consumerSecret:(NSString *)consumerSecret accessGroup:(nullable NSString *)accessGroup

Parameters

consumerKey

Your Twitter application’s consumer key.

consumerSecret

Your Twitter application’s consumer secret.

accessGroup

An optional keychain access group to apply to session objects stored in the keychain.

Discussion

Note: In the majority of situations applications will not need to specify an access group to use with Twitter sessions. This value is only needed if you plan to share credentials with another application that you control or if you are using TwitterKit with an app extension.

Declared In

Twitter.h