Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,33 @@ private struct BackgroundTaskSystemInfo {
}

private static func getNetworkInfo() async -> NetworkInfo {
return await withCheckedContinuation { continuation in
let monitor = NWPathMonitor()
let monitor = NWPathMonitor()
let queue = DispatchQueue(label: "network.monitor.queue")

monitor.pathUpdateHandler = { path in
monitor.cancel()
continuation.resume(returning: NetworkInfo(path: path))
}
let (stream, continuation) = AsyncStream.makeStream(of: NWPath.self)

monitor.pathUpdateHandler = { path in
continuation.yield(path)
}

let queue = DispatchQueue(label: "network.monitor.queue")
monitor.start(queue: queue)
monitor.start(queue: queue)

defer {
continuation.finish()
monitor.cancel()
}

let timeoutTask = Task {
try await Task.sleep(nanoseconds: 1 * NSEC_PER_SEC)
continuation.finish()
}

if let path = await stream.first(where: { _ in true }) {
timeoutTask.cancel()
return NetworkInfo(path: path)
} else {
// Fallback in case no path is received.
return NetworkInfo(type: "unknown", isExpensive: false, isLowDataMode: false)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion config/Version.Public.xcconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CURRENT_PROJECT_VERSION = $VERSION_LONG
MARKETING_VERSION = $VERSION_SHORT
VERSION_LONG = 23.3.0.1
VERSION_LONG = 23.3.0.2
VERSION_SHORT = 23.3
Loading