CafesApi

@interface CafesApi : NodeDependant

Provides access to Textile cafes related APIs

  • Used to register a remote Textile Cafe node with the local Textile node

    Declaration

    Objective-C

    - (void)register:(nonnull NSString *)url
               token:(nonnull NSString *)token
          completion:(nonnull void (^)(NSError *_Nonnull))completion;

    Swift

    func register(_ url: String, token: String, completion: @escaping (Error) -> Void)

    Parameters

    url

    The url of the cafe being registered

    token

    The API token for the cafe being registered

    completion

    A block that will get called with an error

  • Used to deregister a previously registered Textile Cafe

    Declaration

    Objective-C

    - (void)deregister:(nonnull NSString *)sessionId
            completion:(nonnull void (^)(NSError *_Nonnull))completion;

    Swift

    func deregister(_ sessionId: String, completion: @escaping (Error) -> Void)

    Parameters

    sessionId

    The peer id of the cafe you want to deregister

    completion

    A block that will get called with an error

  • Used to refresh an individual Textile Cafe session

    Declaration

    Objective-C

    - (void)refreshSession:(nonnull NSString *)sessionId
                completion:
                    (nonnull void (^)(int *_Nullable, NSError *_Nonnull))completion;

    Swift

    func refreshSession(_ sessionId: String, completion: @escaping (UnsafeMutablePointer<Int32>?, Error) -> Void)

    Parameters

    sessionId

    The peer id of the cafe who’s session you want to refresh

    completion

    A block that will get called with the results of the refresh operation

  • Check messages from all registered cafes

    Declaration

    Objective-C

    - (void)checkMessages:(nonnull void (^)(NSError *_Nonnull))completion;

    Swift

    func checkMessages(_ completion: @escaping (Error) -> Void)

    Parameters

    completion

    A block that will get called with an error

  • Fetches the CafeSession object for a previously registered Textile Cafe node

    Declaration

    Objective-C

    - (id)session:(nonnull NSString *)peerId
            error:(NSError *_Nullable *_Nullable)error;

    Swift

    func session(_ peerId: String) throws -> Any

    Parameters

    peerId

    The peer id of the previously registered cafe node

    error

    A reference to an error pointer that will be set in the case of an error

    Return Value

    The CafeSession for the previously registered cafe

  • Used to get sessions for all previously registered Textile Cafes

    Declaration

    Objective-C

    - (id)sessions:(NSError *_Nullable *_Nullable)error;

    Swift

    func sessions() throws -> Any

    Parameters

    error

    A reference to an error pointer that will be set in the case of an error

    Return Value

    An object containing a list of cafe sessions