Contents

CTSlicingManager

A manager that provides network-slicing capabilities for controlling and monitoring cellular network traffic routing.

Declaration

final class CTSlicingManager

Overview

Use CTSlicingManager to control how your app’s network traffic routes through cellular network slices. Network slicing allows carriers to partition their network resources to provide different levels of service quality for specific types of apps. For example, a gaming slice might prioritize low latency, and a streaming slice might focus on consistent bandwidth. Your app can activate a preferred slice to ensure its traffic receives the appropriate quality of service.

Query availableSliceAppCategories to discover which slice categories your app can use.

let manager = CTSlicingManager.shared
do {
    let categories = try await manager.availableSliceAppCategories
    if categories.contains(.gaming) {
        // The gaming slice is available.
    }
} catch {
    // Handle the error.
}

Activate your preferred slice before creating network connections. New connections automatically route through the activated slice. Call activatePreferredSliceForCategory(_:) before establishing network connections.

do {
    try await manager.activatePreferredSliceForCategory(.gaming)
    // Establish your network connections.
} catch POSIXError.ENOTSUP {
    // Network slicing isn't available.
} catch {
    // Handle other errors.
}

Query activeSlices to verify activation and monitor network slice usage.

do {
    let slices = try await manager.activeSlices
    for slice in slices {
        print("Category: \(slice.appCategory)")
        print("Traffic Class: \(slice.trafficClass)")
        print("Interface: \(slice.networkInterfaceName)")
    }
} catch {
    // Handle the error.
}

Call disableSlicing() to return to the default cellular connection when you no longer need slice-specific routing.

do {
    try await manager.disableSlicing()
    // New connections use the default cellular internet.
} catch {
    // Handle the error.
}

Topics

Getting the shared instance

Querying available slices

Managing network slicing

Monitoring active slices

Representing slice information

Representing app categories

Representing traffic classification