One Logo Pool Ball
Network · IOS API REFERENCE

NWParameters.PrivacyContext

class · iOS 14.0+ · SDK 27.1

class PrivacyContext

A Network Privacy Context can contain various connections and listeners that share various privacy settings and protocol caches. Any in-process cached state, such as TLS sessions, will only be shared within privacy contexts and will not cross privacy context boundaries. Besides defining caching boundaries, privacy contexts also allow restricting the behavior of connections within a context to improve their privacy stance with regards to the system and the local network. For example, a privacy context can disable logging to ensure that sensitive connections do not contribute to the system logs. A privacy context can also require that DNS resolutions are encrypted so that names are not transmitted in the clear on the network during resolution. Some settings, such as DNS settings, can also be applied to the default privacy context for the process using NW_DEFAULT_PRIVACY_CONTEXT. Such settings will be inherited by other resolutions in the same process. Any privacy context set directly on an NWParameters will take precedence over the default context settings.

Members (8)

method · iOS 14.0+

flushCache

TypeScript
flushCache(): void
Swift declaration
func flushCache()

Flush any cached state stored in this privacy context. The act of flushing the cache may be asynchronous, which means that it will take effect shortly after the function is invoked.

init · iOS 14.0+

init

TypeScript
static init(description: string): NWParameters_PrivacyContext
Swift declaration
init(description: String)

Create a new privacy context. This object can be added to connections and listeners by applying the privacy context to NWParameters. Each privacy context can have unique settings for logging and resolution, and implicitly has an isolated cache for items like TLS sessions. - Parameter description: A string used to describe this privacy context for debugging. - Returns: Privacy context object that can be applied to NWParameters

method · iOS 14.0+

disableLogging

TypeScript
disableLogging(): void
Swift declaration
func disableLogging()

Disable logging for connections and listeners associated with this context. Logging may not be disabled on the default privacy context.

get · iOS 14.0+

debugDescription

TypeScript
get debugDescription(): string
Swift declaration
var debugDescription: String { get }

A textual representation of this instance, suitable for debugging. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(reflecting:)` initializer. This initializer works with any type, and uses the custom `debugDescription` property for types that conform to `CustomDebugStringConvertible`: struct Point: CustomDebugStringConvertible { let x: Int, y: Int var debugDescription: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(reflecting: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `debugDescription` property.

get · iOS 17.0+

proxyConfigurations

TypeScript
get proxyConfigurations(): Array<ProxyConfiguration>
Swift declaration
var proxyConfigurations: [ProxyConfiguration] { get set }

An array of proxy configurations to apply to all connections that participate in this context. If set on `default`, this will additionally apply to other networking APIs used by the calling process.

set · iOS 17.0+

proxyConfigurations

TypeScript
set proxyConfigurations(value: Array<ProxyConfiguration>)
Swift declaration
var proxyConfigurations: [ProxyConfiguration] { get set }

An array of proxy configurations to apply to all connections that participate in this context. If set on `default`, this will additionally apply to other networking APIs used by the calling process.

method · iOS 14.0+

requireEncryptedNameResolution

TypeScript
requireEncryptedNameResolution(requireEncryption: boolean, fallbackResolver?: (NWParameters_PrivacyContext_ResolverConfiguration) | null): void
Swift declaration
func requireEncryptedNameResolution(_ requireEncryption: Bool, fallbackResolver: NWParameters.PrivacyContext.ResolverConfiguration?)

Require that any DNS name resolution occurring for connections associated with this context use encrypted transports, such as TLS or HTTPS. - Parameter requireEncryption: Any unencrypted queries will be blocked if set to true. - Parameter fallbackResolver: An optional configuration that can be provided to use instead of blocking queries, when requireEncryption is set to true.

get · iOS 14.0+

default

TypeScript
static get default(): NWParameters_PrivacyContext
Swift declaration
static let `default`: NWParameters.PrivacyContext

The default privacy context represents the default privacy settings used throughout the currently running process. Logging may not be disabled on the default privacy context. Flushing the cache on the default privacy context will not affect other privacy contexts. Changing name resolution settings will only affect privacy contexts that did not already explicitly configure name resolution requirements.

Skipped declarations

No declarations were skipped in this snapshot.

All Network types →