Skip to content

Commit

Permalink
Merge pull request #378 from jonasrottmann/master
Browse files Browse the repository at this point in the history
Fix validating Bundle for whenInUse permission
  • Loading branch information
malcommac committed Feb 29, 2024
2 parents df1c1e8 + f1dd3fe commit fb082a7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Sources/SwiftLocation/Support/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension CLLocationManager: LocationManagerProtocol {
switch permission {
#if !os(tvOS)
case .always:
if !Bundle.hasAlwaysPermission() {
if !Bundle.hasAlwaysAndWhenInUsePermission() {
throw LocationErrors.plistNotConfigured
}
#endif
Expand Down Expand Up @@ -103,8 +103,8 @@ extension CLAuthorizationStatus: CustomStringConvertible {

extension Bundle {

private static let always = "NSLocationAlwaysUsageDescription"
private static let whenInUse = "NSLocationAlwaysAndWhenInUseUsageDescription"
private static let alwaysAndWhenInUse = "NSLocationAlwaysAndWhenInUseUsageDescription"
private static let whenInUse = "NSLocationWhenInUseUsageDescription"
private static let temporary = "NSLocationTemporaryUsageDescriptionDictionary"

static func hasTemporaryPermission(purposeKey: String) -> Bool {
Expand All @@ -120,9 +120,8 @@ extension Bundle {
!(Bundle.main.object(forInfoDictionaryKey: whenInUse) as? String ?? "").isEmpty
}

static func hasAlwaysPermission() -> Bool {
!(Bundle.main.object(forInfoDictionaryKey: always) as? String ?? "").isEmpty &&
!( Bundle.main.object(forInfoDictionaryKey: whenInUse) as? String ?? "").isEmpty
static func hasAlwaysAndWhenInUsePermission() -> Bool {
!(Bundle.main.object(forInfoDictionaryKey: alwaysAndWhenInUse) as? String ?? "").isEmpty
}

}
Expand Down

0 comments on commit fb082a7

Please sign in to comment.