commit | author | age
|
2e29a3
|
1 |
/* |
L |
2 |
* Copyright (c) Meta Platforms, Inc. and affiliates. |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* This source code is licensed under the license found in the |
|
6 |
* LICENSE file in the root directory of this source tree. |
|
7 |
*/ |
|
8 |
|
|
9 |
#import <Foundation/Foundation.h> |
|
10 |
|
|
11 |
#import <FBSDKCoreKit/FBSDKGraphRequestConnecting.h> |
|
12 |
#import <FBSDKCoreKit/FBSDKGraphRequestConnectionDelegate.h> |
|
13 |
|
|
14 |
NS_ASSUME_NONNULL_BEGIN |
|
15 |
|
|
16 |
/** |
|
17 |
The key in the result dictionary for requests to old versions of the Graph API |
|
18 |
whose response is not a JSON object. |
|
19 |
|
|
20 |
|
|
21 |
When a request returns a non-JSON response (such as a "true" literal), that response |
|
22 |
will be wrapped into a dictionary using this const as the key. This only applies for very few Graph API |
|
23 |
prior to v2.1. |
|
24 |
*/ |
|
25 |
FOUNDATION_EXPORT NSString *const FBSDKNonJSONResponseProperty |
|
26 |
NS_SWIFT_NAME(NonJSONResponseProperty); |
|
27 |
|
|
28 |
@protocol FBSDKGraphRequest; |
|
29 |
|
|
30 |
/** |
|
31 |
The `FBSDKGraphRequestConnection` represents a single connection to Facebook to service a request. |
|
32 |
|
|
33 |
The request settings are encapsulated in a reusable <FBSDKGraphRequest> object. The |
|
34 |
`FBSDKGraphRequestConnection` object encapsulates the concerns of a single communication |
|
35 |
e.g. starting a connection, canceling a connection, or batching requests. |
|
36 |
|
|
37 |
*/ |
|
38 |
NS_SWIFT_NAME(GraphRequestConnection) |
|
39 |
@interface FBSDKGraphRequestConnection : NSObject <FBSDKGraphRequestConnecting> |
|
40 |
|
|
41 |
/** |
|
42 |
The default timeout on all FBSDKGraphRequestConnection instances. Defaults to 60 seconds. |
|
43 |
*/ |
|
44 |
@property (class, nonatomic, assign) NSTimeInterval defaultConnectionTimeout; |
|
45 |
|
|
46 |
/** |
|
47 |
The delegate object that receives updates. |
|
48 |
*/ |
|
49 |
@property (nullable, nonatomic, weak) id<FBSDKGraphRequestConnectionDelegate> delegate; |
|
50 |
|
|
51 |
/** |
|
52 |
Gets or sets the timeout interval to wait for a response before giving up. |
|
53 |
*/ |
|
54 |
@property (nonatomic, assign) NSTimeInterval timeout; |
|
55 |
|
|
56 |
/** |
|
57 |
The raw response that was returned from the server. (readonly) |
|
58 |
|
|
59 |
This property can be used to inspect HTTP headers that were returned from |
|
60 |
the server. |
|
61 |
|
|
62 |
The property is nil until the request completes. If there was a response |
|
63 |
then this property will be non-nil during the FBSDKGraphRequestBlock callback. |
|
64 |
*/ |
|
65 |
@property (nullable, nonatomic, readonly, retain) NSHTTPURLResponse *urlResponse; |
|
66 |
|
|
67 |
/** |
|
68 |
Determines the operation queue that is used to call methods on the connection's delegate. |
|
69 |
|
|
70 |
By default, a connection is scheduled on the current thread in the default mode when it is created. |
|
71 |
You cannot reschedule a connection after it has started. |
|
72 |
*/ |
|
73 |
@property (nullable, nonatomic) NSOperationQueue *delegateQueue; |
|
74 |
|
|
75 |
/** |
|
76 |
@methodgroup Class methods |
|
77 |
*/ |
|
78 |
|
|
79 |
/** |
|
80 |
@methodgroup Adding requests |
|
81 |
*/ |
|
82 |
|
|
83 |
/** |
|
84 |
@method |
|
85 |
|
|
86 |
This method adds an <FBSDKGraphRequest> object to this connection. |
|
87 |
|
|
88 |
@param request A request to be included in the round-trip when start is called. |
|
89 |
@param completion A handler to call back when the round-trip completes or times out. |
|
90 |
|
|
91 |
The completion handler is retained until the block is called upon the |
|
92 |
completion or cancellation of the connection. |
|
93 |
*/ |
|
94 |
- (void)addRequest:(id<FBSDKGraphRequest>)request |
|
95 |
completion:(FBSDKGraphRequestCompletion)completion; |
|
96 |
|
|
97 |
/** |
|
98 |
@method |
|
99 |
|
|
100 |
This method adds an <FBSDKGraphRequest> object to this connection. |
|
101 |
|
|
102 |
@param request A request to be included in the round-trip when start is called. |
|
103 |
|
|
104 |
@param completion A handler to call back when the round-trip completes or times out. |
|
105 |
The handler will be invoked on the main thread. |
|
106 |
|
|
107 |
@param name A name for this request. This can be used to feed |
|
108 |
the results of one request to the input of another <FBSDKGraphRequest> in the same |
|
109 |
`FBSDKGraphRequestConnection` as described in |
|
110 |
[Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ). |
|
111 |
|
|
112 |
The completion handler is retained until the block is called upon the |
|
113 |
completion or cancellation of the connection. This request can be named |
|
114 |
to allow for using the request's response in a subsequent request. |
|
115 |
*/ |
|
116 |
- (void)addRequest:(id<FBSDKGraphRequest>)request |
|
117 |
name:(NSString *)name |
|
118 |
completion:(FBSDKGraphRequestCompletion)completion; |
|
119 |
|
|
120 |
/** |
|
121 |
@method |
|
122 |
|
|
123 |
This method adds an <FBSDKGraphRequest> object to this connection. |
|
124 |
|
|
125 |
@param request A request to be included in the round-trip when start is called. |
|
126 |
|
|
127 |
@param completion A handler to call back when the round-trip completes or times out. |
|
128 |
|
|
129 |
@param parameters The dictionary of parameters to include for this request |
|
130 |
as described in [Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ). |
|
131 |
Examples include "depends_on", "name", or "omit_response_on_success". |
|
132 |
|
|
133 |
The completion handler is retained until the block is called upon the |
|
134 |
completion or cancellation of the connection. This request can be named |
|
135 |
to allow for using the request's response in a subsequent request. |
|
136 |
*/ |
|
137 |
- (void)addRequest:(id<FBSDKGraphRequest>)request |
|
138 |
parameters:(nullable NSDictionary<NSString *, id> *)parameters |
|
139 |
completion:(FBSDKGraphRequestCompletion)completion; |
|
140 |
|
|
141 |
/** |
|
142 |
@methodgroup Instance methods |
|
143 |
*/ |
|
144 |
|
|
145 |
/** |
|
146 |
@method |
|
147 |
|
|
148 |
Signals that a connection should be logically terminated as the |
|
149 |
application is no longer interested in a response. |
|
150 |
|
|
151 |
Synchronously calls any handlers indicating the request was cancelled. Cancel |
|
152 |
does not guarantee that the request-related processing will cease. It |
|
153 |
does promise that all handlers will complete before the cancel returns. A call to |
|
154 |
cancel prior to a start implies a cancellation of all requests associated |
|
155 |
with the connection. |
|
156 |
*/ |
|
157 |
- (void)cancel; |
|
158 |
|
|
159 |
/** |
|
160 |
@method |
|
161 |
|
|
162 |
This method starts a connection with the server and is capable of handling all of the |
|
163 |
requests that were added to the connection. |
|
164 |
|
|
165 |
By default, a connection is scheduled on the current thread in the default mode when it is created. |
|
166 |
See `setDelegateQueue:` for other options. |
|
167 |
|
|
168 |
This method cannot be called twice for an `FBSDKGraphRequestConnection` instance. |
|
169 |
*/ |
|
170 |
- (void)start; |
|
171 |
|
|
172 |
/** |
|
173 |
@method |
|
174 |
|
|
175 |
Overrides the default version for a batch request |
|
176 |
|
|
177 |
The SDK automatically prepends a version part, such as "v2.0" to API paths in order to simplify API versioning |
|
178 |
for applications. If you want to override the version part while using batch requests on the connection, call |
|
179 |
this method to set the version for the batch request. |
|
180 |
|
|
181 |
@param version This is a string in the form @"v2.0" which will be used for the version part of an API path |
|
182 |
*/ |
|
183 |
- (void)overrideGraphAPIVersion:(NSString *)version; |
|
184 |
|
|
185 |
@end |
|
186 |
|
|
187 |
NS_ASSUME_NONNULL_END |