Swift SDK Version

GraphRequestConnection

publicclassGraphRequestConnection
Represents a single connection to Facebook to service a single or multiple requests.
The request settings and properties are encapsulated in a reusable GraphRequest or a custom GraphRequestProtocol. This object encapsulates the concerns of a single communication e.g. starting a connection, canceling a connection, or batching requests.
  • A type of the closure that could be used to track network progress of a specific connection.

    Declaration

    Swift
    publictypealiasNetworkProgressHandler=(_bytesSent:Int64,_totalBytesSent:Int64,_totalExpectedBytes:Int64)->Void
  • A type of the closure that could be used to track network errors of a specific connection.

    Declaration

    Swift
    publictypealiasNetworkFailureHandler=(Error)->Void
  • Network progress closure that is going to be called every time data is sent to the server.

    Declaration

    Swift
    publicvarnetworkProgressHandler:GraphRequestConnection.NetworkProgressHandler?{getset}
  • Network failure handler that is going to be called when a connection fails with a network error. Use completion on per request basis to get additional information, that is not related to network errors.

    Declaration

    Swift
    publicvarnetworkFailureHandler:GraphRequestConnection.NetworkFailureHandler?{getset}
  • The operation queue that is used to call all network handlers.

    Declaration

    Swift
    publicvarnetworkHandlerQueue:OperationQueue{getset}
  • Initializes a connection.

    Declaration

    Swift
    publicinit()
  • Adds a request object to this connection.

    Declaration

    Swift
    publicfuncadd<T>(_request:T,batchEntryName:String?=nil,completion:Completion<T>?=nil)

    Parameters

    request
    Request to be included in this connection.
    batchEntryName
    Optional name for this request. This can be used to feed the results of one request to the input of another, as long as they are in the same GraphRequestConnection As described in Graph API Batch Requests.
    completion
    Optional completion closure that is going to be called when the connection finishes or fails.
  • Adds a request object to this connection.

    Declaration

    Swift
    publicfuncadd<T>(_request:T,batchParameters:[String:Any]?,completion:Completion<T>?=nil)

    Parameters

    request
    Request to be included in this connection.
    batchParameters
    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.
    completion
    Optional completion closure that is going to be called when the connection finishes or fails.
  • Starts a connection with the server and sends all the requests in this connection.
    Warning
    This method can’t be called twice per a single GraphRequestConnection instance.

    Declaration

    Swift
    publicfuncstart()
  • Signals that a connect should be logically terminated as per application is no longer interested in a response.
    Synchronouslly calls any handlers indicating the request was cancelled. This doesn’t 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

    Swift
    publicfunccancel()