The FBSDKGraphRequestConnection
represents a single connection to Facebook to service a request.
The request settings are encapsulated in a reusable FBSDKGraphRequest object. The
FBSDKGraphRequestConnection
object encapsulates the concerns of a single communication
e.g. starting a connection, canceling a connection, or batching requests.
Superclass: | NSObject |
Declared in: | FBSDKGraphRequestConnection.h |
delegate
The delegate object that receives updates.
@property (nonatomic,
weak) id<FBSDKGraphRequestConnectionDelegate> delegate;
FBSDKGraphRequestConnection.h
timeout
Gets or sets the timeout interval to wait for a response before giving up.
@property (nonatomic) NSTimeInterval timeout;
FBSDKGraphRequestConnection.h
URLResponse
The raw response that was returned from the server. (readonly)
@property (nonatomic,
retain,
readonly) NSHTTPURLResponse *URLResponse;
This property can be used to inspect HTTP headers that were returned from the server. The property is nil until the request completes. If there was a response then this property will be non-nil during the FBSDKGraphRequestHandler callback.
FBSDKGraphRequestConnection.h
setDefaultConnectionTimeout:
This method sets the default timeout on all FBSDKGraphRequestConnection instances. Defaults to 60 seconds.
Parameter | Description |
---|---|
defaultConnectionTimeout | The timeout interval. |
+ (void)
setDefaultConnectionTimeout:(NSTimeInterval)defaultConnectionTimeout;
FBSDKGraphRequestConnection.h
addRequest:completionHandler:
This method adds an FBSDKGraphRequest object to this connection.
Parameter | Description |
---|---|
request | A request to be included in the round-trip when start is called. |
handler | A handler to call back when the round-trip completes or times out. |
- (void)
addRequest: | (FBSDKGraphRequest *)request |
completionHandler: | (FBSDKGraphRequestHandler)handler; |
The completion handler is retained until the block is called upon the completion or cancellation of the connection.
FBSDKGraphRequestConnection.h
addRequest:completionHandler:batchEntryName:
This method adds an FBSDKGraphRequest object to this connection.
Parameter | Description |
---|---|
request | A request to be included in the round-trip when start is called. |
handler | A handler to call back when the round-trip completes or times out. The handler will be invoked on the main thread. |
name | An optional name for this request. This can be used to feed
the results of one request to the input of another <FBSDKGraphRequest> in the same
|
- (void)
addRequest: | (FBSDKGraphRequest *)request |
completionHandler: | (FBSDKGraphRequestHandler)handler |
batchEntryName: | (NSString *)name; |
The completion handler is retained until the block is called upon the completion or cancellation of the connection. This request can be named to allow for using the request's response in a subsequent request.
FBSDKGraphRequestConnection.h
addRequest:completionHandler:batchParameters:
This method adds an FBSDKGraphRequest object to this connection.
Parameter | Description |
---|---|
request | A request to be included in the round-trip when start is called. |
handler | A handler to call back when the round-trip completes or times out. |
batchParameters | The optional dictionary of parameters to include for this request as described in Graph API Batch Requests. Examples include "depends_on", "name", or "omit_response_on_success". |
- (void)
addRequest: | (FBSDKGraphRequest *)request |
completionHandler: | (FBSDKGraphRequestHandler)handler |
batchParameters: | (NSDictionary *)batchParameters; |
The completion handler is retained until the block is called upon the completion or cancellation of the connection. This request can be named to allow for using the request's response in a subsequent request.
FBSDKGraphRequestConnection.h
cancel
Signals that a connection should be logically terminated as the application is no longer interested in a response.
- (void)
cancel;
Synchronously calls any handlers indicating the request was cancelled. Cancel does not guarantee that the request-related processing will cease. It does promise that all handlers will complete before the cancel returns. A call to cancel prior to a start implies a cancellation of all requests associated with the connection.
FBSDKGraphRequestConnection.h
overrideVersionPartWith:
Overrides the default version for a batch request
Parameter | Description |
---|---|
version | This is a string in the form @"v2.0" which will be used for the version part of an API path |
- (void)
overrideVersionPartWith:(NSString *)version;
The SDK automatically prepends a version part, such as "v2.0" to API paths in order to simplify API versioning for applications. If you want to override the version part while using batch requests on the connection, call this method to set the version for the batch request.
FBSDKGraphRequestConnection.h
setDelegateQueue:
Determines the operation queue that is used to call methods on the connection's delegate.
Parameter | Description |
---|---|
queue | The operation queue to use when calling delegate methods. |
- (void)
setDelegateQueue:(NSOperationQueue *)queue;
By default, a connection is scheduled on the current thread in the default mode when it is created.
You cannot reschedule a connection after it has started.
This is very similar to [NSURLConnection setDelegateQueue:]
.
FBSDKGraphRequestConnection.h
start
This method starts a connection with the server and is capable of handling all of the requests that were added to the connection.
- (void)
start;
By default, a connection is scheduled on the current thread in the default mode when it is created.
See setDelegateQueue:
for other options.
This method cannot be called twice for an FBSDKGraphRequestConnection
instance.
FBSDKGraphRequestConnection.h
FBSDKNonJSONResponseProperty
FBSDK_EXTER N NSString *const FBSDKNonJSONResponseProperty;
When a request returns a non-JSON response (such as a "true" literal), that response will be wrapped into a dictionary using this const as the key. This only applies for very few Graph API prior to v2.1.
FBSDKGraphRequestConnection.h
FBSDKGraphRequestHandler
A block that is passed to addRequest to register for a callback with the results of that request once the connection completes.
typedef void (^FBSDKGraphRequestHandler)( FBSDKGraphRequestConnection *connection, id result, NSError *error);
Pass a block of this type when calling addRequest. This will be called once the request completes. The call occurs on the UI thread.
FBSDKGraphRequestConnection.h