优化首次启动app的网络权限体验

This commit is contained in:
joywayer
2026-07-04 17:37:23 +08:00
parent d76064c4c5
commit 842ca2b9dc
2 changed files with 44 additions and 1 deletions
+1 -1
View File
@@ -17,7 +17,7 @@
<key>agent</key>
<string>veRa0qrBf0df2K1G4de2tgfmVxB2jxpv</string>
<key>appversion</key>
<string>43</string>
<string>44</string>
<key>other</key>
<string></string>
<key>appleconfig</key>
@@ -194,6 +194,21 @@ public final class WebContainerViewController: UIViewController {
// snapshot NWPath """" kind
let path = await Self.currentPathSnapshot()
let kind = Self.classifyBootError(error, path: path)
// iOS ,pipeline
// ; timeout "", fail NWPath
// wifiDenied / cellularDenied ""
// ""("")
//
// kind.isPermissionDenied , NWPath5s
// satisfied pipeline();
// "" 5s
if kind.isPermissionDenied,
await Self.waitForNetworkPermissionResolution(timeout: 5.0) {
await runBootPipeline()
return
}
presentBootError(error, kind: kind)
}
}
@@ -698,6 +713,34 @@ public final class WebContainerViewController: UIViewController {
monitor.start(queue: DispatchQueue.global(qos: .userInitiated))
}
}
/// `timeout` NWPath
/// `.satisfied`""
/// true ( pipeline);false
/// ()
private static func waitForNetworkPermissionResolution(timeout: TimeInterval) async -> Bool {
await withCheckedContinuation { (cont: CheckedContinuation<Bool, Never>) in
let monitor = NWPathMonitor()
nonisolated(unsafe) var resumed = false
DispatchQueue.main.asyncAfter(deadline: .now() + timeout) {
guard !resumed else { return }
resumed = true
monitor.cancel()
cont.resume(returning: false)
}
monitor.pathUpdateHandler = { path in
guard !resumed else { return }
if path.status == .satisfied {
resumed = true
monitor.cancel()
cont.resume(returning: true)
}
}
monitor.start(queue: DispatchQueue.global(qos: .userInitiated))
}
}
}
// MARK: - WKNavigationDelegate