PrivMX DOCS
API Reference/PrivMX Endpoint Swift Extra/Threads

ThreadApi

Swift wrapper for privmx.NativeThreadApiWrapper, providing Thread-related operations within PrivMX platform.

Methods

listThreads(from:basedOn:)

Lists the Threads the user has access to in a specified context. This method retrieves a list of Threads in the given context, with pagination and filtering options.

Params

contextId

String

The unique identifier of the context from which to list Threads.

query

privmx.endpoint.core.PagingQuery

A paging query object for filtering and paginating the results.

public func listThreads(
from contextId: String,
basedOn query: privmx.endpoint.core.PagingQuery
) throws -> privmx.ThreadList

Returns

privmx.ThreadList · A privmx.endpoint.thread.ThreadsList instance containing the list of Threads.

getThread(_:)

Retrieves detailed information about a specific Thread. This method returns metadata and details of a Thread identified by its unique thread ID.

Params

threadId

String

The unique identifier of the Thread to retrieve.

public func getThread(
_ threadId: String
) throws -> privmx.endpoint.thread.Thread

Returns

privmx.endpoint.thread.Thread · A privmx.endpoint.thread.Thread instance containing the Thread’s details.

deleteThread(_:)

Deletes a specific Thread from the platform. This method removes a Thread, identified by its thread ID, from the platform.

Params

threadId

String

The unique identifier of the Thread to delete.

public func deleteThread(
_ threadId: String
) throws -> Void

createThread(in:for:managedBy:withPublicMeta:withPrivateMeta:withPolicies:)

Creates a new Thread in a specified context. This method creates a new Thread with specified users, managers, and metadata in the given context. Note: Managers do not automatically have access to the thread unless explicitly added as users. Note: when no policies are supplied, the default ones inherited from the context will be used instead.

Params

contextId

String

The unique identifier of the context in which to create the Thread.

users

[privmx.endpoint.core.UserWithPubKey]

A list of UserWithPubKey objects representing users who will have access to the Thread.

managers

[privmx.endpoint.core.UserWithPubKey]

A list of UserWithPubKey objects representing managers responsible for the Thread.

publicMeta

Data

The public metadata associated with the Thread, which will not be encrypted.

privateMeta

Data

The private metadata associated with the Thread, which will be encrypted.

policies

privmx.endpoint.core.ContainerPolicy?

The policies governing the Container, as well as the items within.

public func createThread(
in contextId: String,
for users: [privmx.endpoint.core.UserWithPubKey],
managedBy managers: [privmx.endpoint.core.UserWithPubKey],
withPublicMeta publicMeta: Data,
withPrivateMeta privateMeta: Data,
withPolicies policies:privmx.endpoint.core.ContainerPolicy? = nil
) throws -> String

Returns

String · A String representing the ID of the newly created Thread.

listMessages(from:basedOn:)

Lists Messages from a specific Thread. This method retrieves a list of Messages from the specified Thread, filtered and paginated based on the query.

Params

threadId

String

The unique identifier of the Thread from which to list Messages.

query

privmx.endpoint.core.PagingQuery

A paging query object for filtering and paginating the results.

public func listMessages(
from threadId: String,
basedOn query: privmx.endpoint.core.PagingQuery
) throws -> privmx.MessageList

Returns

privmx.MessageList · A privmx.endpoint.core.MessageList instance containing the list of Messages.

getMessage(_:)

Retrieves a specific Message by its ID. This method returns the details of a Message identified by its message ID.

Params

messageId

String

The unique identifier of the Message to retrieve.

public func getMessage(
_ messageId: String
) throws -> privmx.endpoint.thread.Message

Returns

privmx.endpoint.thread.Message · A privmx.endpoint.thread.Message instance containing the Message’s details.

sendMessage(in:withPublicMeta:withPrivateMeta:containing:)

Sends a Message in a Thread. This method sends a Message to the specified Thread, with the option to include both public and private metadata.

Params

threadId

String

The unique identifier of the Thread to send the Message to.

publicMeta

Data

The public metadata associated with the Message, which will not be encrypted.

privateMeta

Data

The private metadata associated with the Message, which will be encrypted.

data

Data

The actual content of the Message as Data, which will be encrypted.

public func sendMessage(
in threadId: String,
withPublicMeta publicMeta: Data,
withPrivateMeta privateMeta: Data,
containing data: Data
) throws -> String

Returns

String · A String representing the ID of the created Message.

updateMessage(_:replacingData:replacingPublicMeta:replacingPrivateMeta:)

Updates an existing Message. This method updates a Message by replacing its data and metadata with new values.

Params

messageId

String

The unique identifier of the Message to update.

data

Data

The new content of the Message as Data, which will be encrypted.

publicMeta

Data

The new public metadata of the Message, which will not be encrypted.

privMeta

Data

public func updateMessage(
_ messageId: String,
replacingData data: Data,
replacingPublicMeta publicMeta: Data,
replacingPrivateMeta privMeta: Data
) throws -> Void

deleteMessage(_:)

Deletes a specific Message. This method deletes a Message identified by its unique message ID from the platform.

Params

messageId

String

The unique identifier of the Message to delete.

public func deleteMessage(
_ messageId: String
) throws -> Void

updateThread(_:atVersion:replacingUsers:replacingManagers:replacingPublicMeta:replacingPrivateMeta:force:forceGenerateNewKey:replacingPolicies:)

Updates an existing Thread with new users, managers, and metadata. This method updates a Thread, replacing its existing users, managers, and metadata with new values. The update can be forced and a new key can be generated if necessary.

Params

threadId

String

The unique identifier of the Thread to update.

version

Int64

The current version of the Thread, used to ensure version consistency.

users

[privmx.endpoint.core.UserWithPubKey]

A new list of UserWithPubKey objects representing users who will have access to the Thread.

managers

[privmx.endpoint.core.UserWithPubKey]

A new list of UserWithPubKey objects representing managers responsible for the Thread.

publicMeta

Data

The new public metadata of the Thread, which will not be encrypted.

privateMeta

Data

The new private metadata of the Thread, which will be encrypted.

force

Bool

A boolean indicating whether to force the update, bypassing version control.

forceGenerateNewKey

Bool

A boolean indicating whether a new key should be generated for the Thread.

policies

privmx.endpoint.core.ContainerPolicy?

The new policies for the Container.

public func updateThread(
_ threadId: String,
atVersion version: Int64,
replacingUsers users:[privmx.endpoint.core.UserWithPubKey],
replacingManagers managers:[privmx.endpoint.core.UserWithPubKey],
replacingPublicMeta publicMeta:Data,
replacingPrivateMeta privateMeta:Data,
force: Bool,
forceGenerateNewKey: Bool,
replacingPolicies policies: privmx.endpoint.core.ContainerPolicy? = nil
) throws -> Void

subscribeForMessageEvents(in:)

Subscribes to receive events related to Messages in a specific Thread. This method subscribes to message-related events, allowing the client to receive notifications about changes in the Messages of the specified Thread.

Params

threadId

String

The unique identifier of the Thread for which to subscribe to message events.

public func subscribeForMessageEvents(
in threadId: String
) throws -> Void

unsubscribeFromMessageEvents(in:)

Unsubscribes from receiving events related to Messages in a specific Thread. This method unsubscribes from message-related events for the specified Thread, stopping further notifications.

Params

threadId

String

The unique identifier of the Thread for which to unsubscribe from message events.

public func unsubscribeFromMessageEvents(
in threadId: String
) throws -> Void

We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.