commit | author | age
|
a0a843
|
1 |
// |
H |
2 |
// Twitter.h |
|
3 |
// |
|
4 |
// Copyright (c) 2015 Twitter. All rights reserved. |
|
5 |
// |
|
6 |
|
|
7 |
#import <TwitterCore/TWTRSession.h> |
|
8 |
#import <TwitterCore/TWTRSessionStore.h> |
|
9 |
#import <UIKit/UIKit.h> |
|
10 |
#import "TWTRAPIClient.h" |
|
11 |
|
|
12 |
NS_ASSUME_NONNULL_BEGIN |
|
13 |
|
|
14 |
/** |
|
15 |
* The central class of the Twitter Kit. |
|
16 |
* @note This class can only be used from the main thread. |
|
17 |
*/ |
|
18 |
@interface Twitter : NSObject |
|
19 |
|
|
20 |
/** |
|
21 |
* Returns the Twitter singleton. |
|
22 |
* |
|
23 |
* @return The Twitter singleton. |
|
24 |
*/ |
|
25 |
+ (Twitter *)sharedInstance; |
|
26 |
|
|
27 |
/** |
|
28 |
* Start Twitter with your consumer key and secret. These will override any credentials |
|
29 |
* present in your applications Info.plist. |
|
30 |
* |
|
31 |
* You do not need to call this method unless you wish to provide credentials other than those |
|
32 |
* in your Info.plist. |
|
33 |
* |
|
34 |
* @param consumerKey Your Twitter application's consumer key. |
|
35 |
* @param consumerSecret Your Twitter application's consumer secret. |
|
36 |
*/ |
|
37 |
- (void)startWithConsumerKey:(NSString *)consumerKey consumerSecret:(NSString *)consumerSecret; |
|
38 |
|
|
39 |
/** |
|
40 |
* Start Twitter with a consumer key, secret, and keychain access group. See -[Twitter startWithConsumerKey:consumerSecret:] |
|
41 |
* |
|
42 |
* @param consumerKey Your Twitter application's consumer key. |
|
43 |
* @param consumerSecret Your Twitter application's consumer secret. |
|
44 |
* @param accessGroup An optional keychain access group to apply to session objects stored in the keychain. |
|
45 |
* |
|
46 |
* @note In the majority of situations applications will not need to specify an access group to use with Twitter sessions. |
|
47 |
* This value is only needed if you plan to share credentials with another application that you control or if you are |
|
48 |
* using TwitterKit with an app extension. |
|
49 |
*/ |
|
50 |
- (void)startWithConsumerKey:(NSString *)consumerKey consumerSecret:(NSString *)consumerSecret accessGroup:(nullable NSString *)accessGroup; |
|
51 |
|
|
52 |
/** |
|
53 |
* The current version of this kit. |
|
54 |
*/ |
|
55 |
@property (nonatomic, copy, readonly) NSString *version; |
|
56 |
|
|
57 |
/** |
|
58 |
* Authentication configuration details. Encapsulates the `consumerKey` and `consumerSecret` credentials required to authenticate a Twitter application. |
|
59 |
*/ |
|
60 |
@property (nonatomic, readonly) TWTRAuthConfig *authConfig; |
|
61 |
|
|
62 |
/** |
|
63 |
* Session store exposing methods to fetch and manage active sessions. Applications that need to manage |
|
64 |
* multiple users should use the session store to authenticate and log out users. |
|
65 |
*/ |
|
66 |
@property (nonatomic, readonly) TWTRSessionStore *sessionStore; |
|
67 |
|
|
68 |
/** |
|
69 |
* Triggers user authentication with Twitter. |
|
70 |
* |
|
71 |
* This method will present UI to allow the user to log in if there are no saved Twitter login credentials. |
|
72 |
* This method is equivalent to calling loginWithMethods:completion: with TWTRLoginMethodAll. |
|
73 |
* |
|
74 |
* @param completion The completion block will be called after authentication is successful or if there is an error. |
|
75 |
* @warning This method requires that you have set up your `consumerKey` and `consumerSecret`. |
|
76 |
*/ |
|
77 |
- (void)logInWithCompletion:(TWTRLogInCompletion)completion; |
|
78 |
|
|
79 |
/** |
|
80 |
* Triggers user authentication with Twitter. Allows the developer to specify the presenting view controller. |
|
81 |
* |
|
82 |
* This method will present UI to allow the user to log in if there are no saved Twitter login credentials. |
|
83 |
* |
|
84 |
* @param viewController The view controller that will be used to present the authentication view. |
|
85 |
* @param completion The completion block will be called after authentication is successful or if there is an error. |
|
86 |
* @warning This method requires that you have set up your `consumerKey` and `consumerSecret`. |
|
87 |
*/ |
|
88 |
- (void)logInWithViewController:(nullable UIViewController *)viewController completion:(TWTRLogInCompletion)completion; |
|
89 |
|
|
90 |
/** |
|
91 |
* Finish the `SFSafariViewController` authentication loop. This method should |
|
92 |
* be called from application:openURL:options inside the application delegate. |
|
93 |
* |
|
94 |
* This method will verify an authentication token sent by the Twitter API to |
|
95 |
* finish the web-based authentication flow. |
|
96 |
* |
|
97 |
* @param application The `UIApplication` instance received as a parameter. |
|
98 |
* @param url The `NSURL` instance received as a parameter. |
|
99 |
* @param options The options dictionary received as a parameter. |
|
100 |
* |
|
101 |
* @return Boolean specifying whether this URL was handled |
|
102 |
* by Twitter Kit or not. |
|
103 |
*/ |
|
104 |
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options; |
|
105 |
|
|
106 |
@end |
|
107 |
|
|
108 |
NS_ASSUME_NONNULL_END |