fix requiring local network permission

pull/1061/head
Ryan ZHAO
parent 77d31d7817
commit 7af5b53433

@ -89,7 +89,7 @@
<key>NSCameraUsageDescription</key>
<string>Session needs camera access to take pictures and scan QR codes.</string>
<key>NSFaceIDUsageDescription</key>
<string>Session's Screen Lock feature uses Face ID.</string>
<string>Session&apos;s Screen Lock feature uses Face ID.</string>
<key>NSHumanReadableCopyright</key>
<string>com.loki-project.loki-messenger</string>
<key>NSMicrophoneUsageDescription</key>
@ -98,6 +98,8 @@
<string>Session needs access to your library to save photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Session needs access to your library to update your avatar and send photos.</string>
<key>NSLocalNetworkUsageDescription</key>
<string>Session needs access to local network to make voice and video calls.</string>
<key>PHPhotoLibraryPreventAutomaticLimitedAccessAlert</key>
<true/>
<key>UIAppFonts</key>

File diff suppressed because one or more lines are too long

@ -174,7 +174,7 @@ extension Permissions {
public static func checkLocalNetworkPermission(using dependencies: Dependencies) {
Task {
do {
if try await requestLocalNetworkAuthorization() {
if try await checkLocalNetworkPermissionWithBonjour() {
// Permission is granted, continue to next onboarding step
dependencies[defaults: .appGroup, key: .lastSeenHasLocalNetworkPermission] = true
} else {
@ -187,8 +187,8 @@ extension Permissions {
}
}
public static func requestLocalNetworkAuthorization() async throws -> Bool {
let type = "_session_local_network_access_check._tcp"
public static func checkLocalNetworkPermissionWithBonjour() async throws -> Bool {
let type = "_session_local_network_access_check._tcp" // stringlint:ignore
let queue = DispatchQueue(label: "localNetworkAuthCheck")
let listener = try NWListener(using: NWParameters(tls: .none, tcp: NWProtocolTCP.Options()))
@ -265,13 +265,13 @@ extension Permissions {
resume(with: .failure(error))
case let .waiting(error):
switch error {
case .dns(DNSServiceErrorType(kDNSServiceErr_PolicyDenied)):
print("Browser permission denied, reporting failure.")
resume(with: .success(false))
default:
print("Browser waiting, stopping. \(error)")
resume(with: .failure(error))
}
case .dns(DNSServiceErrorType(kDNSServiceErr_PolicyDenied)):
print("Browser permission denied, reporting failure.")
resume(with: .success(false))
default:
print("Browser waiting, stopping. \(error)")
resume(with: .failure(error))
}
@unknown default:
print("Ignoring unknown browser state: \(String(describing: newState))")
return

Loading…
Cancel
Save