forked from facebook/facebook-ios-sdk
/
Facebook.h
281 lines (222 loc) · 8.36 KB
/
Facebook.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*
* Copyright 2010 Facebook
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import "FBLoginDialog.h"
#import "FBRequest.h"
#import "FBSessionManualTokenCachingStrategy.h"
#import "FBFrictionlessRequestSettings.h"
#import "FacebookSDK.h"
////////////////////////////////////////////////////////////////////////////////
// deprecated API
//
// Summary
// The classes, protocols, etc. in this header are provided for backward
// compatibility and migration; for new code, use FacebookSDK.h, and/or the
// public headers that it imports; for existing code under active development,
// Facebook.h imports FacebookSDK.h, and updates should favor the new interfaces
// whenever possible
// up-front decl's
@class FBFrictionlessRequestSettings;
@protocol FBRequestDelegate;
@protocol FBSessionDelegate;
/**
* Main Facebook interface for interacting with the Facebook developer API.
* Provides methods to log in and log out a user, make requests using the REST
* and Graph APIs, and start user interface interactions (such as
* pop-ups promoting for credentials, permissions, stream posts, etc.)
*/
@interface Facebook : NSObject<FBLoginDialogDelegate>{
id<FBSessionDelegate> _sessionDelegate;
NSMutableSet* _requests;
FBSession* _session;
FBSessionManualTokenCachingStrategy *_tokenCaching;
FBDialog* _fbDialog;
NSString* _appId;
NSString* _urlSchemeSuffix;
BOOL _isExtendingAccessToken;
FBRequest *_requestExtendingAccessToken;
NSDate* _lastAccessTokenUpdate;
FBFrictionlessRequestSettings* _frictionlessRequestSettings;
}
@property(nonatomic, copy) NSString* accessToken;
@property(nonatomic, copy) NSDate* expirationDate;
@property(nonatomic, assign) id<FBSessionDelegate> sessionDelegate;
@property(nonatomic, copy) NSString* urlSchemeSuffix;
@property(nonatomic, readonly) BOOL isFrictionlessRequestsEnabled;
@property(nonatomic, readonly, retain) FBSession *session;
- (id)initWithAppId:(NSString *)appId
andDelegate:(id<FBSessionDelegate>)delegate;
- (id)initWithAppId:(NSString *)appId
urlSchemeSuffix:(NSString *)urlSchemeSuffix
andDelegate:(id<FBSessionDelegate>)delegate;
- (void)authorize:(NSArray *)permissions;
- (void)extendAccessToken;
- (void)extendAccessTokenIfNeeded;
- (BOOL)shouldExtendAccessToken;
- (BOOL)handleOpenURL:(NSURL *)url;
- (void)logout;
- (void)logout:(id<FBSessionDelegate>)delegate;
- (FBRequest*)requestWithParams:(NSMutableDictionary *)params
andDelegate:(id <FBRequestDelegate>)delegate;
- (FBRequest*)requestWithMethodName:(NSString *)methodName
andParams:(NSMutableDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate;
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
andDelegate:(id <FBRequestDelegate>)delegate;
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
andParams:(NSMutableDictionary *)params
andDelegate:(id <FBRequestDelegate>)delegate;
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
andParams:(NSMutableDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate;
- (void)dialog:(NSString *)action
andDelegate:(id<FBDialogDelegate>)delegate;
- (void)dialog:(NSString *)action
andParams:(NSMutableDictionary *)params
andDelegate:(id <FBDialogDelegate>)delegate;
- (BOOL)isSessionValid;
- (void)enableFrictionlessRequests;
- (void)reloadFrictionlessRecipientCache;
- (BOOL)isFrictionlessEnabledForRecipient:(id)fbid;
- (BOOL)isFrictionlessEnabledForRecipients:(NSArray*)fbids;
@end
////////////////////////////////////////////////////////////////////////////////
/**
* Your application should implement this delegate to receive session callbacks.
*/
@protocol FBSessionDelegate <NSObject>
/**
* Called when the user successfully logged in.
*/
- (void)fbDidLogin;
/**
* Called when the user dismissed the dialog without logging in.
*/
- (void)fbDidNotLogin:(BOOL)cancelled;
/**
* Called after the access token was extended. If your application has any
* references to the previous access token (for example, if your application
* stores the previous access token in persistent storage), your application
* should overwrite the old access token with the new one in this method.
* See extendAccessToken for more details.
*/
- (void)fbDidExtendToken:(NSString*)accessToken
expiresAt:(NSDate*)expiresAt;
/**
* Called when the user logged out.
*/
- (void)fbDidLogout;
/**
* Called when the current session has expired. This might happen when:
* - the access token expired
* - the app has been disabled
* - the user revoked the app's permissions
* - the user changed his or her password
*/
- (void)fbSessionInvalidated;
@end
@protocol FBRequestDelegate;
enum {
kFBRequestStateReady,
kFBRequestStateLoading,
kFBRequestStateComplete,
kFBRequestStateError
};
// FBRequest(Deprecated)
//
// Summary
// The deprecated category is used to maintain back compat and ease migration
// to the revised SDK for iOS
/**
* Do not use this interface directly, instead, use method in Facebook.h
*/
@interface FBRequest(Deprecated)
@property(nonatomic,assign) id<FBRequestDelegate> delegate;
/**
* The URL which will be contacted to execute the request.
*/
@property(nonatomic,copy) NSString* url;
/**
* The API method which will be called.
*/
@property(nonatomic,copy) NSString* httpMethod;
/**
* The dictionary of parameters to pass to the method.
*
* These values in the dictionary will be converted to strings using the
* standard Objective-C object-to-string conversion facilities.
*/
@property(nonatomic,retain) NSMutableDictionary* params;
@property(nonatomic,retain) NSURLConnection* connection;
@property(nonatomic,retain) NSMutableData* responseText;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@property(nonatomic) FBRequestState state;
#pragma GCC diagnostic pop
@property(nonatomic) BOOL sessionDidExpire;
/**
* Error returned by the server in case of request's failure (or nil otherwise).
*/
@property(nonatomic,retain) NSError* error;
- (BOOL) loading;
+ (NSString *)serializeURL:(NSString *)baseUrl
params:(NSDictionary *)params;
+ (NSString*)serializeURL:(NSString *)baseUrl
params:(NSDictionary *)params
httpMethod:(NSString *)httpMethod;
@end
////////////////////////////////////////////////////////////////////////////////
/*
*Your application should implement this delegate
*/
@protocol FBRequestDelegate <NSObject>
@optional
/**
* Called just before the request is sent to the server.
*/
- (void)requestLoading:(FBRequest *)request;
/**
* Called when the Facebook API request has returned a response.
*
* This callback gives you access to the raw response. It's called before
* (void)request:(FBRequest *)request didLoad:(id)result,
* which is passed the parsed response object.
*/
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response;
/**
* Called when an error prevents the request from completing successfully.
*/
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error;
/**
* Called when a request returns and its response has been parsed into
* an object.
*
* The resulting object may be a dictionary, an array or a string, depending
* on the format of the API response. If you need access to the raw response,
* use:
*
* (void)request:(FBRequest *)request
* didReceiveResponse:(NSURLResponse *)response
*/
- (void)request:(FBRequest *)request didLoad:(id)result;
/**
* Called when a request returns a response.
*
* The result object is the raw response from the server of type NSData
*/
- (void)request:(FBRequest *)request didLoadRawResponse:(NSData *)data;
@end