From e62aca46db897f1585a691617b2256c2c5819f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Thu, 14 Aug 2025 14:48:47 +0200 Subject: [PATCH] WIP: Add sending to iOS app --- QuickDrop.xcodeproj/project.pbxproj | 2 ++ QuickDrop/Plus/DistributionDetector.swift | 7 ++++++- QuickDropiOS/ContentView.swift | 2 +- QuickDropiOS/Model.swift | 7 ++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 424fb63..b884c65 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -1065,6 +1065,7 @@ ENABLE_PREVIEWS = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSLocalNetworkUsageDescription = "Local network access is required to scan and connect to devices."; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -1101,6 +1102,7 @@ ENABLE_PREVIEWS = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSLocalNetworkUsageDescription = "Local network access is required to scan and connect to devices."; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; diff --git a/QuickDrop/Plus/DistributionDetector.swift b/QuickDrop/Plus/DistributionDetector.swift index fcfd345..2324c3b 100644 --- a/QuickDrop/Plus/DistributionDetector.swift +++ b/QuickDrop/Plus/DistributionDetector.swift @@ -12,6 +12,7 @@ class DistributionDetector { static var isDirectDistributionEnabled: Bool { get { + #if os(macOS) if let cached = _directDistributionCached { return cached } @@ -21,13 +22,16 @@ class DistributionDetector { log("[DistributionDetector] isDirectDistribution: \(result)") return result + #else + return false + #endif } } static var _directDistributionCached: Bool? = nil - + #if os(macOS) private static func isDirectDistribution() -> Bool { // 1. Get dynamic code object for our process var code: SecCode? @@ -69,4 +73,5 @@ class DistributionDetector { return false } + #endif } diff --git a/QuickDropiOS/ContentView.swift b/QuickDropiOS/ContentView.swift index 387dbce..c804220 100644 --- a/QuickDropiOS/ContentView.swift +++ b/QuickDropiOS/ContentView.swift @@ -32,7 +32,7 @@ struct DeviceListView: View { Image(systemName: "smartphone") .resizable() .frame(width: 30, height: 30) - Text(device.name.isEmpty ? "Android" : device.name) + Text(device.name ?? "Android") Spacer() if model.selectedDevice == device { diff --git a/QuickDropiOS/Model.swift b/QuickDropiOS/Model.swift index 7081d46..724bbd2 100644 --- a/QuickDropiOS/Model.swift +++ b/QuickDropiOS/Model.swift @@ -17,7 +17,7 @@ class ShareViewModel: ObservableObject, ShareExtensionDelegate { @Published var progressValue: Double? = nil private var urls: [URL] = [] - private var textToSend: String? = nil + private var textToSend = "Test from QuickDrop iOS" //private var errorAlertHandler = ErrorAlertHandler.shared private var connectionEstablished = false @@ -25,6 +25,7 @@ class ShareViewModel: ObservableObject, ShareExtensionDelegate { init() { NearbyConnectionManager.shared.startDeviceDiscovery() + NearbyConnectionManager.shared.addShareExtensionDelegate(self) } func addDevice(device: RemoteDeviceInfo) { @@ -64,6 +65,10 @@ class ShareViewModel: ObservableObject, ShareExtensionDelegate { progressState = "TransferFinished".localized() } + func startTransferWithQrCode(device: RemoteDeviceInfo) { + selectDevice(device: device) + } + func selectDevice(device: RemoteDeviceInfo) { NearbyConnectionManager.shared.stopDeviceDiscovery()