Improve dashboard & Request network on China iPhone model

This commit is contained in:
世界
2023-07-17 12:25:16 +08:00
parent f441b89efb
commit 2d3c0aa15d
9 changed files with 256 additions and 66 deletions
+23
View File
@@ -15,6 +15,29 @@ class ApplicationDelegate: NSObject, UIApplicationDelegate {
NSLog("setup background task error: \(error.localizedDescription)")
}
}
Task.detached {
await self.requestNetworkPermission()
}
return true
}
private func requestNetworkPermission() {
if UIDevice.current.userInterfaceIdiom != .phone {
return
}
if SharedPreferences.networkPermissionRequested {
return
}
if !DeviceCensorship.isChinaDevice() {
SharedPreferences.networkPermissionRequested = true
return
}
URLSession.shared.dataTask(with: URL(string: "http://captive.apple.com")!) { _, response, _ in
if let response = response as? HTTPURLResponse {
if response.statusCode == 200 {
SharedPreferences.networkPermissionRequested = true
}
}
}.resume()
}
}