diff --git a/bitchat.xcodeproj/project.pbxproj b/bitchat.xcodeproj/project.pbxproj index 5eaf6abc..5567e99e 100644 --- a/bitchat.xcodeproj/project.pbxproj +++ b/bitchat.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 63; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -36,7 +36,7 @@ 6DC1563390A15C042D059CF9 /* EncryptionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionService.swift; sourceTree = ""; }; 763E0DBA9492A654FC0CDCB9 /* AppInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfoView.swift; sourceTree = ""; }; 7EEBDA723E1CFD88758DA4AC /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 997D512074C64904D75DDD40 /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 997D512074C64904D75DDD40 /* bitchat.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; }; A08E03AA0C63E97C91749AEC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; A2136C3E22D02D4A8DBE7EAB /* BinaryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryProtocol.swift; sourceTree = ""; }; D5C3D880FF8AE1673B20E1E3 /* BluetoothMeshService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothMeshService.swift; sourceTree = ""; }; @@ -179,6 +179,7 @@ ); mainGroup = 18198ED912AAF495D8AF7763; minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 54; projectDirPath = ""; projectRoot = ""; targets = ( @@ -252,11 +253,8 @@ CODE_SIGNING_REQUIRED = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = L3N5LHJD5Y; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = bitchat/Info.plist; - INFOPLIST_KEY_CFBundleDisplayName = bitchat; - INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -266,12 +264,9 @@ PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; PRODUCT_NAME = bitchat; SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; - SUPPORTS_MACCATALYST = NO; - SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; - SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -284,11 +279,8 @@ CODE_SIGNING_REQUIRED = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = L3N5LHJD5Y; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = bitchat/Info.plist; - INFOPLIST_KEY_CFBundleDisplayName = bitchat; - INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -298,12 +290,9 @@ PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; PRODUCT_NAME = bitchat; SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; - SUPPORTS_MACCATALYST = NO; - SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; - SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; @@ -324,7 +313,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - PRODUCT_BUNDLE_IDENTIFIER = com.bitchat.app; + PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; PRODUCT_NAME = bitchat; SDKROOT = macosx; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; @@ -407,7 +396,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - PRODUCT_BUNDLE_IDENTIFIER = com.bitchat.app; + PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; PRODUCT_NAME = bitchat; SDKROOT = macosx; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; diff --git a/bitchat/Info.plist b/bitchat/Info.plist index 4943de82..6b60e722 100644 --- a/bitchat/Info.plist +++ b/bitchat/Info.plist @@ -40,12 +40,5 @@ UIInterfaceOrientationPortrait - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - diff --git a/bitchat/Services/BluetoothMeshService.swift b/bitchat/Services/BluetoothMeshService.swift index 09961089..e3b2c2ca 100644 --- a/bitchat/Services/BluetoothMeshService.swift +++ b/bitchat/Services/BluetoothMeshService.swift @@ -88,10 +88,6 @@ class BluetoothMeshService: NSObject { private var peerListUpdateTimer: Timer? private let peerListUpdateDebounceInterval: TimeInterval = 0.1 // 100ms debounce for more responsive updates - // Stale peer cleanup - private var stalePeerCleanupTimer: Timer? - private var peerLastSeenTimestamps: [String: Date] = [:] // Track when we last saw each peer - // Cover traffic for privacy private var coverTrafficTimer: Timer? private let coverTrafficPrefix = "☂DUMMY☂" // Prefix to identify dummy messages after decryption @@ -850,7 +846,7 @@ class BluetoothMeshService: NSObject { peerRSSI.removeValue(forKey: peerID) announcedPeers.remove(peerID) announcedToPeers.remove(peerID) - processedKeyExchanges.removeAll { $0.contains(peerID) } + processedKeyExchanges = processedKeyExchanges.filter { !$0.contains(peerID) } peerNicknamesLock.lock() let nickname = peerNicknames[peerID] @@ -1504,7 +1500,7 @@ class BluetoothMeshService: NSObject { peerLastSeenTimestamps.removeValue(forKey: stalePeerID) // Remove from processed key exchanges - processedKeyExchanges.removeAll { $0.contains(stalePeerID) } + processedKeyExchanges = processedKeyExchanges.filter { !$0.contains(stalePeerID) } } // If we had stale peers, notify the UI immediately @@ -2393,68 +2389,6 @@ extension BluetoothMeshService: CBPeripheralManagerDelegate { return coverTrafficPrefix + (templates.randomElement() ?? "ok") } - // MARK: - Stale Peer Cleanup - - private func cleanupStalePeers() { - let staleThreshold: TimeInterval = 60.0 // Consider peers stale after 60 seconds of no activity - let now = Date() - - var peersToRemove: [String] = [] - - // Check for stale peers - activePeersLock.lock() - for peerID in activePeers { - if let lastSeen = peerLastSeenTimestamps[peerID] { - if now.timeIntervalSince(lastSeen) > staleThreshold { - peersToRemove.append(peerID) - } - } else { - // No timestamp recorded, consider it stale - peersToRemove.append(peerID) - } - } - activePeersLock.unlock() - - // Remove stale peers - for peerID in peersToRemove { - print("[CLEANUP] Removing stale peer \(peerID) - last seen: \(peerLastSeenTimestamps[peerID]?.description ?? "never")") - - // Remove from all tracking structures - activePeersLock.lock() - activePeers.remove(peerID) - activePeersLock.unlock() - - peerNicknamesLock.lock() - let nickname = peerNicknames[peerID] - peerNicknames.removeValue(forKey: peerID) - peerNicknamesLock.unlock() - - // Remove from other tracking - announcedPeers.remove(peerID) - announcedToPeers.remove(peerID) - peerRSSI.removeValue(forKey: peerID) - peerLastSeenTimestamps.removeValue(forKey: peerID) - cachedMessagesSentToPeer.remove(peerID) - - // Disconnect any associated peripherals - if let peripheral = connectedPeripherals[peerID] { - intentionalDisconnects.insert(peripheral.identifier.uuidString) - centralManager.cancelPeripheralConnection(peripheral) - connectedPeripherals.removeValue(forKey: peerID) - peripheralCharacteristics.removeValue(forKey: peripheral) - } - - // Log the cleanup - if let nick = nickname { - print("[CLEANUP] Removed stale peer: \(nick) (\(peerID))") - } - } - - // Notify UI if any peers were removed - if !peersToRemove.isEmpty { - notifyPeerListUpdate() - } - } private func updatePeerLastSeen(_ peerID: String) { peerLastSeenTimestamps[peerID] = Date() diff --git a/bitchat/Services/NotificationService.swift b/bitchat/Services/NotificationService.swift index 896eed4a..89ec352c 100644 --- a/bitchat/Services/NotificationService.swift +++ b/bitchat/Services/NotificationService.swift @@ -1,3 +1,11 @@ +// +// NotificationService.swift +// bitchat +// +// This is free and unencumbered software released into the public domain. +// For more information, see +// + import Foundation import UserNotifications #if os(iOS) @@ -12,11 +20,9 @@ class NotificationService { private init() {} func requestAuthorization() { - UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in + UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in if granted { // Permission granted - } else if let error = error { - // print("[NOTIFICATIONS] Permission error: \(error)") } } } @@ -49,12 +55,8 @@ class NotificationService { trigger: nil // Deliver immediately ) - UNUserNotificationCenter.current().add(request) { error in - if let error = error { - // print("[NOTIFICATIONS] Error sending notification: \(error)") - } else { - // Notification sent - } + UNUserNotificationCenter.current().add(request) { _ in + // Notification added } } diff --git a/project.yml b/project.yml index d5dcdade..66478453 100644 --- a/project.yml +++ b/project.yml @@ -1,6 +1,6 @@ name: bitchat options: - bundleIdPrefix: com.bitchat + bundleIdPrefix: chat.bitchat deploymentTarget: iOS: 16.0 macOS: 13.0