Skip to content

Commit

Permalink
Re-instate compatibility with iOS 13 (#243)
Browse files Browse the repository at this point in the history
(Get-off alerts remain iOS 14+)
  • Loading branch information
nighthawk authored Jan 26, 2023
1 parent 5ac8e89 commit 0b3e7cd
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"repositoryURL": "https://github.com/skedgo/GeoMonitor.git",
"state": {
"branch": null,
"revision": "c411962eded60edc0e4104c29a361b747c9113cd",
"version": "0.1.0"
"revision": "03f3cab0eec2f1c8eb8ce00c64900e6033afba3a",
"version": "0.1.2"
}
},
{
"package": "Kingfisher",
"repositoryURL": "https://github.com/onevcat/Kingfisher.git",
"state": {
"branch": null,
"revision": "44e891bdb61426a95e31492a67c7c0dfad1f87c5",
"version": "7.4.1"
"revision": "90135885ef506506620c4911cefb55a95ca2a9a2",
"version": "7.5.0"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let package = Package(
name: "TripKit",
defaultLocalization: "en",
platforms: [
.iOS(.v14),
.iOS(.v13),
.macOS(.v11),
],
products: [
Expand All @@ -22,7 +22,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "6.1.0")),
.package(url: "https://github.com/onevcat/Kingfisher.git", .upToNextMajor(from: "7.0.0")),
.package(url: "https://github.com/skedgo/GeoMonitor.git", .upToNextMajor(from: "0.1.0")),
.package(url: "https://github.com/skedgo/GeoMonitor.git", .upToNextMajor(from: "0.1.2")),
.package(url: "https://github.com/skedgo/TGCardViewController.git", .upToNextMajor(from: "2.1.0")),
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Sources/TripKitUI/cards/TKUITripOverviewCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ extension TKUITripOverviewCard {
extension TKUITripOverviewCard {

private func showNotification(for notificationKinds: Set<TKAPI.TripNotification.MessageKind>, in tableView: UITableView) {
guard TKUINotificationManager.shared.isSubscribed(to: .tripAlerts),
guard #available(iOS 14.0, *), TKUINotificationManager.shared.isSubscribed(to: .tripAlerts),
let tableFooterView = tableView.tableFooterView as? UIStackView
else {
return
Expand Down
3 changes: 3 additions & 0 deletions Sources/TripKitUI/managers/TKUITripMonitorManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import TripKit
/// - Project > Your Target > Capabilities > Background Modes: Enable "Location Updates"
/// - Project > Your Target > Info: Include both `NSLocationAlwaysAndWhenInUseUsageDescription` and `NSLocationWhenInUseUsageDescription`
/// - Then call `TKUINotificationManager.shared.subscribe(to: .tripAlerts) { ... }` in your app.
@available(iOS 14.0, *)
public class TKUITripMonitorManager: NSObject {

private enum Keys {
Expand Down Expand Up @@ -148,6 +149,7 @@ public class TKUITripMonitorManager: NSObject {

// MARK: - Geofence-based alerts

@available(iOS 14.0, *)
extension TKUITripMonitorManager {

private func startMonitoringRegions(from notifications: [TKAPI.TripNotification]) {
Expand Down Expand Up @@ -186,6 +188,7 @@ extension TKUITripMonitorManager {

// MARK: - Time-based alerts

@available(iOS 14.0, *)
extension TKUITripMonitorManager {

private func scheduleTimeBased(from notifications: [TKAPI.TripNotification]) {
Expand Down
25 changes: 15 additions & 10 deletions Sources/TripKitUI/view model/TKUITripOverviewViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,22 @@ class TKUITripOverviewViewModel {
}
.asDriver(onErrorDriveWith: .never())

let nextFromAlertToggle = inputs.alertsEnabled.asObservable()
.withLatestFrom(tripUpdated) { ($1, $0) }
.compactMap { trip, enabled -> Next? in
if enabled {
TKUITripMonitorManager.shared.monitorRegions(from: trip)
} else {
TKUITripMonitorManager.shared.stopMonitoring()
let nextFromAlertToggle: Signal<Next>
if #available(iOS 14.0, *) {
nextFromAlertToggle = inputs.alertsEnabled.asObservable()
.withLatestFrom(tripUpdated) { ($1, $0) }
.compactMap { trip, enabled -> Next? in
if enabled {
TKUITripMonitorManager.shared.monitorRegions(from: trip)
} else {
TKUITripMonitorManager.shared.stopMonitoring()
}
return nil
}
return nil
}
.asSignal { _ in .empty() }
.asSignal { _ in .empty() }
} else {
nextFromAlertToggle = .empty()
}

let nextFromSelection = inputs.selected.compactMap { item -> Next? in
switch item {
Expand Down
8 changes: 2 additions & 6 deletions TripKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4485,7 +4485,6 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Sources/TripKitInterApp/Supporting Files//Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -4513,7 +4512,6 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Sources/TripKitInterApp/Supporting Files//Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -4580,7 +4578,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited)";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = YES;
Expand Down Expand Up @@ -4642,7 +4640,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited)";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
Expand Down Expand Up @@ -4777,7 +4775,6 @@
"$(inherited)",
);
INFOPLIST_FILE = "$(SRCROOT)/Examples/TripKitUIExample/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -4813,7 +4810,6 @@
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "$(SRCROOT)/Examples/TripKitUIExample/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/skedgo/GeoMonitor",
"state" : {
"revision" : "c411962eded60edc0e4104c29a361b747c9113cd",
"version" : "0.1.0"
"revision" : "03f3cab0eec2f1c8eb8ce00c64900e6033afba3a",
"version" : "0.1.2"
}
},
{
Expand Down

0 comments on commit 0b3e7cd

Please # to comment.