2
2
// SPDX-License-Identifier: Apache-2.0
3
3
// SPDX-License-Identifier: MIT
4
4
5
+ import CoreLocation
5
6
import SwiftRs
6
7
import Tauri
7
8
import UIKit
8
9
import WebKit
9
- import CoreLocation
10
10
11
11
class GetPositionArgs : Decodable {
12
- let enableHighAccuracy : Bool ?
12
+ var enableHighAccuracy : Bool ?
13
13
}
14
14
15
15
class WatchPositionArgs : Decodable {
@@ -101,14 +101,14 @@ class GeolocationPlugin: Plugin, CLLocationManagerDelegate {
101
101
if CLLocationManager . locationServicesEnabled ( ) {
102
102
// TODO: Use the authorizationStatus instance property with locationManagerDidChangeAuthorization(_:) instead.
103
103
switch CLLocationManager . authorizationStatus ( ) {
104
- case . notDetermined:
105
- status = " prompt "
106
- case . restricted, . denied:
107
- status = " denied "
108
- case . authorizedAlways, . authorizedWhenInUse:
109
- status = " granted "
110
- @unknown default :
111
- status = " prompt "
104
+ case . notDetermined:
105
+ status = " prompt "
106
+ case . restricted, . denied:
107
+ status = " denied "
108
+ case . authorizedAlways, . authorizedWhenInUse:
109
+ status = " granted "
110
+ @unknown default :
111
+ status = " prompt "
112
112
}
113
113
} else {
114
114
invoke. reject ( " Location services are not enabled. " )
@@ -161,16 +161,18 @@ class GeolocationPlugin: Plugin, CLLocationManagerDelegate {
161
161
}
162
162
}
163
163
164
- public func locationManager( _ manager: CLLocationManager , didUpdateLocations locations: [ CLLocation ] ) {
164
+ public func locationManager(
165
+ _ manager: CLLocationManager , didUpdateLocations locations: [ CLLocation ]
166
+ ) {
165
167
// Respond to all getCurrentPosition() calls.
166
168
for request in self . positionRequests {
167
- // The capacitor plugin uses locations.first but .last should be the most current one
168
- // and i don't see a reason to use old locations
169
- if let location = locations. last {
170
- let result = convertLocation ( location)
171
- request. resolve ( result)
172
- } else {
173
- request. reject ( " Location service returned an empty Location array. " )
169
+ // The capacitor plugin uses locations.first but .last should be the most current one
170
+ // and i don't see a reason to use old locations
171
+ if let location = locations. last {
172
+ let result = convertLocation ( location)
173
+ request. resolve ( result)
174
+ } else {
175
+ request. reject ( " Location service returned an empty Location array. " )
174
176
}
175
177
}
176
178
@@ -194,7 +196,9 @@ class GeolocationPlugin: Plugin, CLLocationManagerDelegate {
194
196
}
195
197
}
196
198
197
- public func locationManager( _ manager: CLLocationManager , didChangeAuthorization status: CLAuthorizationStatus ) {
199
+ public func locationManager(
200
+ _ manager: CLLocationManager , didChangeAuthorization status: CLAuthorizationStatus
201
+ ) {
198
202
let requests = self . permissionRequests
199
203
self . permissionRequests. removeAll ( )
200
204
0 commit comments