Contents

activatePreferredSliceForCategory(_:)

Activates a preferred network slice for new connections.

Declaration

final func activatePreferredSliceForCategory(_ appCategory: CTSlicingManager.AppCategory) async throws

Parameters

  • appCategory:

    The Appcategory to activate. Available categories include:

    • communication: An app category for communication apps like messaging and voice calls.

    • gaming: An app category for gaming apps that require low latency and high performance.

    • streaming: An app category for streaming apps that require high bandwidth and consistent throughput.

Discussion

Call this method before establishing network connections to route your app’s traffic through a specific network slice. After calling this method, new network connections that your app establishes use the specified slice category.

The array that availableSliceAppCategories returns must include the specified category for activation to succeed.

do {
    // Activate the gaming slice before starting a multiplayer session.
    try await CTSlicingManager.shared.activatePreferredSliceForCategory(.gaming)

    // Establish network connections for gaming traffic.
    // New connections route through the gaming network slice.
    // Existing connections remain on their current routing.
} catch POSIXError.ENOTSUP {
    print("Network slicing isn't currently available.")
} catch {
    print("Failed to activate slice: \(error)")
}

See Also

Managing network slicing