Sessions

public class Sessions

This class provides methods to connect to and logout from the established session against the server.

Properties

  • Information about current user

    Declaration

    Swift

    public var user: User? { get }
  • Token for current session

    Declaration

    Swift

    public var sessionToken: String? { get }
  • True if an active session can be restored

    Declaration

    Swift

    public var canRestoreSession: Bool { get }
  • Session identifier for signaling server

    Declaration

    Swift

    public var sessionId: String? { get }
  • True when sippo server and media server are connected and authenticated

    Declaration

    Swift

    public var isAuthenticated: Bool

API

  • Connects the session and notify ClientStateDelegate when it finishes, onSuccess is called if it’s all OK or onFailure(ErrorType) if an error occurs.

    Declaration

    Swift

    public func connect(authentication: SippoServer.Authentication,
                        result: @escaping (Result<Void, ClientError>) -> Void)

    Parameters

    authentication

    Token authentication or basic authentication (user/password).

    result

    Result with success when actions is completed

  • Restore an active session that had been activated before. (Call canRestoreSession to check if exist an active session)

    Declaration

    Swift

    public func restoreSession(result: @escaping (Result<Void, ClientError>) -> Void)

    Parameters

    result

    Result with success when actions is completed

  • Destroys the session established against the server.

    Declaration

    Swift

    public func disconnect(result: @escaping (Result<Void, ClientError>) -> Void)

    Parameters

    result

    Result with success when actions is completed

  • Suspend session, should be called when app enters background

    Declaration

    Swift

    public func suspend()
  • Fetches the list of the available providers.

    Declaration

    Swift

    public func providers(result: @escaping (Result<[Provider], ClientError>) -> Void)

    Parameters

    result

    A single that will emit a list with the available providers when the request is completed. In case of error, it will emit a [ClientError]. It is possible that the error may be caused by the fact that recent server versions only support the [AuthProvider] model, in which case, the [authProviders] method should be called instead.

  • Fetches the info for the provider that will manage the user authentication.

    Declaration

    Swift

    public func authProviders(result: @escaping (Result<AuthProvider, ClientError>) -> Void)

    Parameters

    result

    A single that will emit the provider info when the request is completed. In case of error, it will emit a [ClientError]. It is possible that the error may be caused by the fact that previous server versions only support the [Provider] model, in which case, the [providers] method should be called instead.

  • Register a new push token in server

    Declaration

    Swift

    public func registerAPNS(_ token: String,
                             production: Bool = true,
                             result: @escaping (Result<Void, ResourceError>) -> Void)

    Parameters

    token

    Token to save

    production

    Use production or debug apn gateway

  • Check if a permission is granted in current session

    Declaration

    Swift

    public func isPermissionGranted(_ permission: Permission) -> Bool

    Parameters

    permission

    Permission to be checked