Functions
The following functions are available globally.
-
applySignatureRequest(api:
AsynchronoussignatureRequest: ) Static apply a signature request
Declaration
Swift
public func applySignatureRequest(api: XmtpApiClient, signatureRequest: FfiSignatureRequest) async throws
-
connectToBackend(host:
AsynchronousisSecure: appVersion: ) Undocumented
Declaration
Swift
public func connectToBackend(host: String, isSecure: Bool, appVersion: String?) async throws -> XmtpApiClient
-
createClient(api:
AsynchronoussyncApi: db: encryptionKey: inboxId: accountIdentifier: nonce: legacySignedPrivateKeyProto: deviceSyncServerUrl: deviceSyncMode: allowOffline: disableEvents: ) It returns a new client of the specified
inbox_id
. Note that theinbox_id
must be either brand new or already associated with theaccount_identifier
. i.e.inbox_id
cannot be associated with another account address.Prior to calling this function, it’s suggested to form
inbox_id
,account_identifier
, andnonce
like below.inbox_id = get_inbox_id_for_address(account_identifier) nonce = 0 // if inbox_id is not associated, we will create new one. if !inbox_id { if !legacy_key { nonce = random_u64() } inbox_id = generate_inbox_id(account_identifier, nonce) } // Otherwise, we will just use the inbox and ignore the nonce. db_path = $inbox_id-$env xmtp.create_client(account_identifier, nonce, inbox_id, Option<legacy_signed_private_key_proto>)
Declaration
Swift
public func createClient(api: XmtpApiClient, syncApi: XmtpApiClient, db: String?, encryptionKey: Data?, inboxId: String, accountIdentifier: FfiIdentifier, nonce: UInt64, legacySignedPrivateKeyProto: Data?, deviceSyncServerUrl: String?, deviceSyncMode: FfiSyncWorkerMode?, allowOffline: Bool?, disableEvents: Bool?) async throws -> FfiXmtpClient
-
Undocumented
Declaration
Swift
public func decodeAttachment(bytes: Data) throws -> FfiAttachment
-
Undocumented
Declaration
Swift
public func decodeMultiRemoteAttachment(bytes: Data) throws -> FfiMultiRemoteAttachment
-
Undocumented
Declaration
Swift
public func decodeReaction(bytes: Data) throws -> FfiReactionPayload
-
Undocumented
Declaration
Swift
public func decodeReadReceipt(bytes: Data) throws -> FfiReadReceipt
-
Undocumented
Declaration
Swift
public func decodeRemoteAttachment(bytes: Data) throws -> FfiRemoteAttachment
-
Undocumented
Declaration
Swift
public func decodeReply(bytes: Data) throws -> FfiReply
-
Undocumented
Declaration
Swift
public func decodeTransactionReference(bytes: Data) throws -> FfiTransactionReference
-
Undocumented
Declaration
Swift
public func encodeAttachment(attachment: FfiAttachment) throws -> Data
-
Undocumented
Declaration
Swift
public func encodeMultiRemoteAttachment(ffiMultiRemoteAttachment: FfiMultiRemoteAttachment) throws -> Data
-
Undocumented
Declaration
Swift
public func encodeReaction(reaction: FfiReactionPayload) throws -> Data
-
Undocumented
Declaration
Swift
public func encodeReadReceipt(readReceipt: FfiReadReceipt) throws -> Data
-
Undocumented
Declaration
Swift
public func encodeRemoteAttachment(remoteAttachment: FfiRemoteAttachment) throws -> Data
-
Undocumented
Declaration
Swift
public func encodeReply(reply: FfiReply) throws -> Data
-
Undocumented
Declaration
Swift
public func encodeTransactionReference(reference: FfiTransactionReference) throws -> Data
-
turns on logging to a file on-disk in the directory specified. files will be prefixed with ‘libxmtp.log’ and suffixed with the timestamp, i.e “libxmtp.log.2025-04-02” A maximum of ‘max_files’ log files are kept.
Declaration
Swift
public func enterDebugWriter(directory: String, logLevel: FfiLogLevel, rotation: FfiLogRotation, maxFiles: UInt32) throws
-
turns on logging to a file on-disk with a specified log level. files will be prefixed with ‘libxmtp.log’ and suffixed with the timestamp, i.e “libxmtp.log.2025-04-02” A maximum of ‘max_files’ log files are kept.
Declaration
Swift
public func enterDebugWriterWithLevel(directory: String, rotation: FfiLogRotation, maxFiles: UInt32, logLevel: FfiLogLevel) throws
-
3) Ethereum address from public key (accepts 65-byte 0x04||XY or 64-byte XY).
Declaration
Swift
public func ethereumAddressFromPubkey(pubkey: Data) throws -> String
-
1) Ethereum compatible public key from 32-byte private key. Returns 65-byte uncompressed (0x04 || X || Y) Private key is automatically zeroized after use for security
Declaration
Swift
public func ethereumGeneratePublicKey(privateKey32: Data) throws -> Data
-
4) EIP-191 personal message hash: keccak256(“\x19Ethereum Signed Message:\n{len}” || message)
Declaration
Swift
public func ethereumHashPersonal(message: String) throws -> Data
-
2) Ethereum recoverable signature (FFI). Returns 65 bytes
r || s || v
, with v ∈ {27,28} (legacy/Electrum encoding where v = 27 + parity, parity ∈ {0,1}).- If
hashing == true
: signs per EIP-191 (“Ethereum Signed Message:\n{len(msg)}” || msg, then keccak256). - If
hashing == false
:msg
must be a 32-byte prehash (e.g., keccak256/EIP-712 digest). - Private key is automatically zeroized after signing for security
Declaration
Swift
public func ethereumSignRecoverable(msg: Data, privateKey32: Data, hashing: Bool) throws -> Data
- If
-
Flush loglines from libxmtp log writer to the file, ensuring logs are written. This should be called before the program exits, to ensure all the logs in memory have been written. this ends the writer thread.
Declaration
Swift
public func exitDebugWriter() throws
-
Undocumented
Declaration
Swift
public func generateInboxId(accountIdentifier: FfiIdentifier, nonce: UInt64) throws -> String
-
getInboxIdForIdentifier(api:
AsynchronousaccountIdentifier: ) Undocumented
Declaration
Swift
public func getInboxIdForIdentifier(api: XmtpApiClient, accountIdentifier: FfiIdentifier) async throws -> String?
-
Undocumented
Declaration
Swift
public func getVersionInfo() -> String
-
inboxStateFromInboxIds(api:
AsynchronousinboxIds: ) Static Get the inbox state for each
inbox_id
.Declaration
Swift
public func inboxStateFromInboxIds(api: XmtpApiClient, inboxIds: [String]) async throws -> [FfiInboxState]
-
isConnected(api:
Asynchronous) Undocumented
Declaration
Swift
public func isConnected(api: XmtpApiClient) async -> Bool
-
Static revoke a list of installations
Declaration
Swift
public func revokeInstallations(api: XmtpApiClient, recoveryIdentifier: FfiIdentifier, inboxId: String, installationIds: [Data]) async throws -> FfiSignatureRequest
-
Undocumented
Declaration
Swift
public func uniffiEnsureXmtpv3Initialized()