Skip to content

Commit

Permalink
Disable new liveUpdates method usage temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
daneden committed Jul 7, 2024
1 parent c919cda commit c72f7ff
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
9 changes: 7 additions & 2 deletions Solstice.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
7106C86F29A276B40007A7EC /* WidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7106C86E29A276B40007A7EC /* WidgetBundle.swift */; };
7106C87329A276B40007A7EC /* Widget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7106C87229A276B40007A7EC /* Widget.swift */; };
7106C87629A276B40007A7EC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7106C87529A276B40007A7EC /* Assets.xcassets */; };
7106C87C29A276B40007A7EC /* Widget Extension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 7106C86829A276B30007A7EC /* Widget Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
7106C87C29A276B40007A7EC /* Widget Extension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 7106C86829A276B30007A7EC /* Widget Extension.appex */; platformFilters = (ios, macos, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
7106C88129A277460007A7EC /* CurrentLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 719846AF28EEE48900E866CE /* CurrentLocation.swift */; };
7106C88229A2774A0007A7EC /* TimeMachine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71F641C0299FCCFF00FE5AB5 /* TimeMachine.swift */; };
7106C88329A277550007A7EC /* Solstice.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 7198468F28E5895F00E866CE /* Solstice.xcdatamodeld */; };
Expand Down Expand Up @@ -49,7 +49,7 @@
713F7FFF29BE88E800BEA156 /* DaylightSummaryTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 713F7FFE29BE88E800BEA156 /* DaylightSummaryTitle.swift */; };
713F800029BE88E800BEA156 /* DaylightSummaryTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 713F7FFE29BE88E800BEA156 /* DaylightSummaryTitle.swift */; };
713F800129BE88E800BEA156 /* DaylightSummaryTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 713F7FFE29BE88E800BEA156 /* DaylightSummaryTitle.swift */; };
71475FE729ACF87E0031D576 /* Solstice watchOS Watch App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 719F924329ACD1CC00C06921 /* Solstice watchOS Watch App.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
71475FE729ACF87E0031D576 /* Solstice watchOS Watch App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 719F924329ACD1CC00C06921 /* Solstice watchOS Watch App.app */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
714A944629C7318D00C67A4A /* SidebarListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 714A944529C7318D00C67A4A /* SidebarListView.swift */; };
7150CC5A29AB7B3000E6B90C /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71BD5E3F29A785FE00E40C01 /* NotificationManager.swift */; };
7150CC5B29AB7B3C00E6B90C /* AppStorage++.swift in Sources */ = {isa = PBXBuildFile; fileRef = 717F8BB829A8CAFC0015ECCB /* AppStorage++.swift */; };
Expand Down Expand Up @@ -1156,6 +1156,10 @@
/* Begin PBXTargetDependency section */
7106C87B29A276B40007A7EC /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
platformFilters = (
ios,
macos,
);
target = 7106C86729A276B30007A7EC /* Widget Extension */;
targetProxy = 7106C87A29A276B40007A7EC /* PBXContainerItemProxy */;
};
Expand All @@ -1166,6 +1170,7 @@
};
71AEB7AF29AD0F2100A7952D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
platformFilter = ios;
target = 719F924229ACD1CC00C06921 /* Solstice watchOS Watch App */;
targetProxy = 71AEB7AE29AD0F2100A7952D /* PBXContainerItemProxy */;
};
Expand Down
26 changes: 13 additions & 13 deletions Solstice/Helpers/CurrentLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ class CurrentLocation: NSObject, ObservableObject, CLLocationManagerDelegate {

func requestLocation() {
guard isAuthorized else { return }

if #available(iOS 17, watchOS 10, macOS 14, visionOS 1, *) {
Task {
do {
try await requestLocation()
} catch {
print("Error requesting location: \(error.localizedDescription)")
}
}
} else {
legacyRequestLocation()
}
legacyRequestLocation()
// if #available(iOS 17, watchOS 10, macOS 14, visionOS 1, *) {
// Task {
// do {
// try await requestLocationFromLiveUpdates()
// } catch {
// print("Error requesting location: \(error.localizedDescription)")
// }
// }
// } else {
// legacyRequestLocation()
// }
}

@available(iOS 17, watchOS 10, macOS 14, visionOS 1, *)
func requestLocation() async throws {
func requestLocationFromLiveUpdates() async throws {
let updates = CLLocationUpdate.liveUpdates()
for try await update in updates {
guard let location = update.location else { return }
Expand Down
28 changes: 15 additions & 13 deletions Widget/Helpers/SolsticeWidgetTimelineProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,24 @@ fileprivate class LocationManager: NSObject, CLLocationManagerDelegate {
}

updateLocationsCallbacks = []
locationManager.stopUpdatingLocation()
}

func requestLocation() {
if #available(iOSApplicationExtension 17, watchOSApplicationExtension 10, macOSApplicationExtension 14, *) {
Task {
for try await update in CLLocationUpdate.liveUpdates() {
guard let location = update.location else { return }
for callback in updateLocationsCallbacks {
callback([location])
}
break
}
}
} else {
locationManager.requestLocation()
}
locationManager.startUpdatingLocation()
// if #available(iOSApplicationExtension 17, watchOSApplicationExtension 10, macOSApplicationExtension 14, *) {
// Task {
// for try await update in CLLocationUpdate.liveUpdates() {
// guard let location = update.location else { return }
// for callback in updateLocationsCallbacks {
// callback([location])
// }
// break
// }
// }
// } else {
// locationManager.requestLocation()
// }
}

var location: CLLocation? { locationManager.location }
Expand Down

0 comments on commit c72f7ff

Please sign in to comment.