diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index bf5f71ba..307fa716 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -1332,12 +1332,12 @@ INFOPLIST_FILE = Meshtastic/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Meshtastic; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; - IPHONEOS_DEPLOYMENT_TARGET = 16.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.1; + MARKETING_VERSION = 2.2.2; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1366,12 +1366,12 @@ INFOPLIST_FILE = Meshtastic/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Meshtastic; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; - IPHONEOS_DEPLOYMENT_TARGET = 16.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.2.1; + MARKETING_VERSION = 2.2.2; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; @@ -1391,7 +1391,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GCH7VS5Y9R; INFOPLIST_FILE = MeshtasticTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1416,7 +1416,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GCH7VS5Y9R; INFOPLIST_FILE = MeshtasticTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1437,6 +1437,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GCH7VS5Y9R; INFOPLIST_FILE = MeshtasticUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1457,6 +1458,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = GCH7VS5Y9R; INFOPLIST_FILE = MeshtasticUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1484,7 +1486,7 @@ INFOPLIST_FILE = Widgets/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Widgets; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1515,7 +1517,7 @@ INFOPLIST_FILE = Widgets/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Widgets; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index c3384193..7eb6daaf 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -701,7 +701,6 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage } // Update our live activity if there is one running, not available on mac iOS >= 16.2 #if !targetEnvironment(macCatalyst) - if #available(iOS 16.2, *) { let oneMinuteLater = Calendar.current.date(byAdding: .minute, value: (Int(1) ), to: Date())! let date = Date.now...oneMinuteLater @@ -717,7 +716,6 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage print("Updated live activity.") } } - } #endif } } catch { diff --git a/Meshtastic/Views/Bluetooth/Connect.swift b/Meshtastic/Views/Bluetooth/Connect.swift index 33725aca..c696ee8b 100644 --- a/Meshtastic/Views/Bluetooth/Connect.swift +++ b/Meshtastic/Views/Bluetooth/Connect.swift @@ -89,22 +89,20 @@ struct Connect: View { if node != nil { #if !targetEnvironment(macCatalyst) - if #available(iOS 16.2, *) { - Button { - if !liveActivityStarted { + Button { + if !liveActivityStarted { + #if canImport(ActivityKit) + print("Start live activity.") + startNodeActivity() + #endif + } else { #if canImport(ActivityKit) - print("Start live activity.") - startNodeActivity() - #endif - } else { - #if canImport(ActivityKit) - print("Stop live activity.") - endActivity() - #endif - } - } label: { - Label("mesh.live.activity", systemImage: liveActivityStarted ? "stop" : "play") + print("Stop live activity.") + endActivity() + #endif } + } label: { + Label("mesh.live.activity", systemImage: liveActivityStarted ? "stop" : "play") } #endif Text("Num: \(String(node!.num))") @@ -293,40 +291,36 @@ struct Connect: View { } #if canImport(ActivityKit) func startNodeActivity() { - if #available(iOS 16.2, *) { - liveActivityStarted = true - let timerSeconds = 60 - - let deviceMetrics = node?.telemetries?.filtered(using: NSPredicate(format: "metricsType == 0")) - let mostRecent = deviceMetrics?.lastObject as? TelemetryEntity + liveActivityStarted = true + let timerSeconds = 60 + + let deviceMetrics = node?.telemetries?.filtered(using: NSPredicate(format: "metricsType == 0")) + let mostRecent = deviceMetrics?.lastObject as? TelemetryEntity - let activityAttributes = MeshActivityAttributes(nodeNum: Int(node?.num ?? 0), name: node?.user?.longName ?? "unknown") + let activityAttributes = MeshActivityAttributes(nodeNum: Int(node?.num ?? 0), name: node?.user?.longName ?? "unknown") - let future = Date(timeIntervalSinceNow: Double(timerSeconds)) + let future = Date(timeIntervalSinceNow: Double(timerSeconds)) - let initialContentState = MeshActivityAttributes.ContentState(timerRange: Date.now...future, connected: true, channelUtilization: mostRecent?.channelUtilization ?? 0.0, airtime: mostRecent?.airUtilTx ?? 0.0, batteryLevel: UInt32(mostRecent?.batteryLevel ?? 0)) + let initialContentState = MeshActivityAttributes.ContentState(timerRange: Date.now...future, connected: true, channelUtilization: mostRecent?.channelUtilization ?? 0.0, airtime: mostRecent?.airUtilTx ?? 0.0, batteryLevel: UInt32(mostRecent?.batteryLevel ?? 0)) - let activityContent = ActivityContent(state: initialContentState, staleDate: Calendar.current.date(byAdding: .minute, value: 2, to: Date())!) + let activityContent = ActivityContent(state: initialContentState, staleDate: Calendar.current.date(byAdding: .minute, value: 2, to: Date())!) - do { - let myActivity = try Activity.request(attributes: activityAttributes, content: activityContent, - pushType: nil) - print(" Requested MyActivity live activity. ID: \(myActivity.id)") - } catch let error { - print("Error requesting live activity: \(error.localizedDescription)") - } + do { + let myActivity = try Activity.request(attributes: activityAttributes, content: activityContent, + pushType: nil) + print(" Requested MyActivity live activity. ID: \(myActivity.id)") + } catch let error { + print("Error requesting live activity: \(error.localizedDescription)") } } func endActivity() { liveActivityStarted = false Task { - if #available(iOS 16.2, *) { - for activity in Activity.activities { - // Check if this is the activity associated with this order. - if activity.attributes.nodeNum == node?.num ?? 0 { - await activity.end(nil, dismissalPolicy: .immediate) - } + for activity in Activity.activities { + // Check if this is the activity associated with this order. + if activity.attributes.nodeNum == node?.num ?? 0 { + await activity.end(nil, dismissalPolicy: .immediate) } } }