iOS SDK Version

FBSDKGraphRequestConnection

@interfaceFBSDKGraphRequestConnection:NSObject
The FBSDKGraphRequestConnection represents a single connection to Facebook to service a request.
The request settings are encapsulated in a reusable
object. The FBSDKGraphRequestConnection object encapsulates the concerns of a single communication e.g. starting a connection, canceling a connection, or batching requests.
  • The default timeout on all FBSDKGraphRequestConnection instances. Defaults to 60 seconds.

    Declaration

    Objective-C
    @property(class,nonatomic,assign,unsafe_unretained,readwrite)NSTimeIntervaldefaultConnectionTimeout;
    Swift
    classvardefaultConnectionTimeout:TimeInterval{getset}
  • The delegate object that receives updates.

    Declaration

    Objective-C
    @property(nonatomic,weak,readwrite,nullable)id<FBSDKGraphRequestConnectionDelegate>delegate;
    Swift
    weakvardelegate:GraphRequestConnectionDelegate?{getset}
  • Gets or sets the timeout interval to wait for a response before giving up.

    Declaration

    Objective-C
    @property(nonatomic,assign,unsafe_unretained,readwrite)NSTimeIntervaltimeout;
    Swift
    vartimeout:TimeInterval{getset}
  • The raw response that was returned from the server. (readonly)
    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 FBSDKGraphRequestBlock callback.

    Declaration

    Objective-C
    @property(nonatomic,retain,readonly,nullable)NSHTTPURLResponse*urlResponse;
    Swift
    varurlResponse:HTTPURLResponse?{get}
  • Determines the operation queue that is used to call methods on the connection’s delegate.
    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.

    Declaration

    Objective-C
    @property(nonatomic,retain,readwrite)NSOperationQueue*_NonnulldelegateQueue;
    Swift
    vardelegateQueue:OperationQueue{getset}
  • @method
    This method adds an
    object to this connection.
    The completion handler is retained until the block is called upon the completion or cancellation of the connection.

    Declaration

    Objective-C
    -(void)addRequest:(nonnullFBSDKGraphRequest*)requestcompletionHandler:(nonnullFBSDKGraphRequestBlock)handler;
    Swift
    funcadd(_request:FBSDKGraphRequest,completionHandlerhandler:@escapingGraphRequestBlock)

    Parameters

    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.
  • @method
    This method adds an
    object to this connection.
    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.

    Declaration

    Objective-C
    -(void)addRequest:(nonnullFBSDKGraphRequest*)requestbatchEntryName:(nonnullNSString*)namecompletionHandler:(nonnullFBSDKGraphRequestBlock)handler;
    Swift
    funcadd(_request:FBSDKGraphRequest,batchEntryNamename:String,completionHandlerhandler:@escapingGraphRequestBlock)

    Parameters

    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
    A name for this request. This can be used to feed the results of one request to the input of another
    in the same FBSDKGraphRequestConnection as described in Graph API Batch Requests.
  • @method
    This method adds an
    object to this connection.
    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.

    Declaration

    Objective-C
    -(void)addRequest:(nonnullFBSDKGraphRequest*)requestbatchParameters:(nullableNSDictionary<NSString*,id>*)batchParameterscompletionHandler:(nonnullFBSDKGraphRequestBlock)handler;
    Swift
    funcadd(_request:FBSDKGraphRequest,batchParameters:[String:Any]?,completionHandlerhandler:@escapingGraphRequestBlock)

    Parameters

    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 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”.
  • @method
    Signals that a connection should be logically terminated as the application is no longer interested in a response.
    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.

    Declaration

    Objective-C
    -(void)cancel;
    Swift
    funccancel()
  • @method
    This method starts a connection with the server and is capable of handling all of the requests that were added to the connection.
    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.

    Declaration

    Objective-C
    -(void)start;
    Swift
    funcstart()
  • @method
    Overrides the default version for a batch request
    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.

    Declaration

    Objective-C
    -(void)overrideGraphAPIVersion:(nonnullNSString*)version;
    Swift
    funcoverrideGraphAPIVersion(_version:String)

    Parameters

    version
    This is a string in the form @“v2.0” which will be used for the version part of an API path