commit | author | age
|
655e66
|
1 |
/* |
H |
2 |
* Copyright (C) 2017 Twitter, Inc. |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
* |
|
16 |
*/ |
a0a843
|
17 |
|
H |
18 |
#import <TwitterCore/TWTRSession.h> |
|
19 |
#import <TwitterCore/TWTRSessionStore.h> |
|
20 |
#import <UIKit/UIKit.h> |
|
21 |
#import "TWTRAPIClient.h" |
|
22 |
|
|
23 |
NS_ASSUME_NONNULL_BEGIN |
|
24 |
|
655e66
|
25 |
#ifndef Twitter |
H |
26 |
|
|
27 |
/** |
|
28 |
* To support legacy integrations with TwitterKit, |
|
29 |
* map the old `Twitter` to the new `TWTRTwitter` using a macro. |
|
30 |
*/ |
|
31 |
#define Twitter TWTRTwitter |
|
32 |
|
|
33 |
#endif |
|
34 |
|
a0a843
|
35 |
/** |
H |
36 |
* The central class of the Twitter Kit. |
|
37 |
* @note This class can only be used from the main thread. |
|
38 |
*/ |
655e66
|
39 |
@interface TWTRTwitter : NSObject |
a0a843
|
40 |
|
H |
41 |
/** |
|
42 |
* Returns the Twitter singleton. |
|
43 |
* |
|
44 |
* @return The Twitter singleton. |
|
45 |
*/ |
655e66
|
46 |
+ (TWTRTwitter *)sharedInstance; |
a0a843
|
47 |
|
H |
48 |
/** |
|
49 |
* Start Twitter with your consumer key and secret. These will override any credentials |
|
50 |
* present in your applications Info.plist. |
|
51 |
* |
|
52 |
* @param consumerKey Your Twitter application's consumer key. |
|
53 |
* @param consumerSecret Your Twitter application's consumer secret. |
|
54 |
*/ |
|
55 |
- (void)startWithConsumerKey:(NSString *)consumerKey consumerSecret:(NSString *)consumerSecret; |
|
56 |
|
|
57 |
/** |
655e66
|
58 |
* Start Twitter with a consumer key, secret, and keychain access group. See -[TWTRTwitter startWithConsumerKey:consumerSecret:] |
a0a843
|
59 |
* |
H |
60 |
* @param consumerKey Your Twitter application's consumer key. |
|
61 |
* @param consumerSecret Your Twitter application's consumer secret. |
|
62 |
* @param accessGroup An optional keychain access group to apply to session objects stored in the keychain. |
|
63 |
* |
|
64 |
* @note In the majority of situations applications will not need to specify an access group to use with Twitter sessions. |
|
65 |
* This value is only needed if you plan to share credentials with another application that you control or if you are |
|
66 |
* using TwitterKit with an app extension. |
|
67 |
*/ |
|
68 |
- (void)startWithConsumerKey:(NSString *)consumerKey consumerSecret:(NSString *)consumerSecret accessGroup:(nullable NSString *)accessGroup; |
|
69 |
|
|
70 |
/** |
|
71 |
* The current version of this kit. |
|
72 |
*/ |
|
73 |
@property (nonatomic, copy, readonly) NSString *version; |
|
74 |
|
|
75 |
/** |
|
76 |
* Authentication configuration details. Encapsulates the `consumerKey` and `consumerSecret` credentials required to authenticate a Twitter application. |
|
77 |
*/ |
|
78 |
@property (nonatomic, readonly) TWTRAuthConfig *authConfig; |
|
79 |
|
|
80 |
/** |
|
81 |
* Session store exposing methods to fetch and manage active sessions. Applications that need to manage |
|
82 |
* multiple users should use the session store to authenticate and log out users. |
|
83 |
*/ |
|
84 |
@property (nonatomic, readonly) TWTRSessionStore *sessionStore; |
|
85 |
|
|
86 |
/** |
|
87 |
* Triggers user authentication with Twitter. |
|
88 |
* |
|
89 |
* This method will present UI to allow the user to log in if there are no saved Twitter login credentials. |
|
90 |
* This method is equivalent to calling loginWithMethods:completion: with TWTRLoginMethodAll. |
|
91 |
* |
|
92 |
* @param completion The completion block will be called after authentication is successful or if there is an error. |
|
93 |
* @warning This method requires that you have set up your `consumerKey` and `consumerSecret`. |
|
94 |
*/ |
|
95 |
- (void)logInWithCompletion:(TWTRLogInCompletion)completion; |
|
96 |
|
|
97 |
/** |
|
98 |
* Triggers user authentication with Twitter. Allows the developer to specify the presenting view controller. |
|
99 |
* |
|
100 |
* This method will present UI to allow the user to log in if there are no saved Twitter login credentials. |
|
101 |
* |
|
102 |
* @param viewController The view controller that will be used to present the authentication view. |
|
103 |
* @param completion The completion block will be called after authentication is successful or if there is an error. |
|
104 |
* @warning This method requires that you have set up your `consumerKey` and `consumerSecret`. |
|
105 |
*/ |
|
106 |
- (void)logInWithViewController:(nullable UIViewController *)viewController completion:(TWTRLogInCompletion)completion; |
|
107 |
|
|
108 |
/** |
|
109 |
* Finish the `SFSafariViewController` authentication loop. This method should |
|
110 |
* be called from application:openURL:options inside the application delegate. |
|
111 |
* |
|
112 |
* This method will verify an authentication token sent by the Twitter API to |
|
113 |
* finish the web-based authentication flow. |
|
114 |
* |
|
115 |
* @param application The `UIApplication` instance received as a parameter. |
|
116 |
* @param url The `NSURL` instance received as a parameter. |
|
117 |
* @param options The options dictionary received as a parameter. |
|
118 |
* |
|
119 |
* @return Boolean specifying whether this URL was handled |
|
120 |
* by Twitter Kit or not. |
|
121 |
*/ |
|
122 |
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options; |
|
123 |
|
|
124 |
@end |
|
125 |
|
|
126 |
NS_ASSUME_NONNULL_END |