@capacitor/geolocation 1.1.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +28 -11
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/capacitorjs/plugins/geolocation/Geolocation.java +38 -31
- package/android/src/main/java/com/capacitorjs/plugins/geolocation/GeolocationPlugin.java +35 -13
- package/dist/docs.json +65 -6
- package/dist/esm/definitions.d.ts +32 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.js +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/GeolocationPlugin.swift +2 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.3.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.3.0...@capacitor/geolocation@1.3.1) (2022-01-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* inline source code in esm map files ([#760](https://github.com/ionic-team/capacitor-plugins/issues/760)) ([a960489](https://github.com/ionic-team/capacitor-plugins/commit/a960489a19db0182b90d187a50deff9dfbe51038))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [1.3.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.2.0...@capacitor/geolocation@1.3.0) (2021-12-08)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **geolocation:** Error if Google Play Services are not available ([#709](https://github.com/ionic-team/capacitor-plugins/issues/709)) ([fc79c43](https://github.com/ionic-team/capacitor-plugins/commit/fc79c4319c54cbcd5dbbb7221dfdd03d0515805b))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [1.2.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.1.3...@capacitor/geolocation@1.2.0) (2021-11-17)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* **geolocation:** Add new alias for coarse location ([#684](https://github.com/ionic-team/capacitor-plugins/issues/684)) ([7563040](https://github.com/ionic-team/capacitor-plugins/commit/7563040983ad397e28616246e7ed5ffce69727c2))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [1.1.3](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.1.2...@capacitor/geolocation@1.1.3) (2021-11-03)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @capacitor/geolocation
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
6
47
|
## [1.1.2](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.1.1...@capacitor/geolocation@1.1.2) (2021-10-14)
|
|
7
48
|
|
|
8
49
|
|
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ const printCurrentPosition = async () => {
|
|
|
59
59
|
* [`watchPosition(...)`](#watchposition)
|
|
60
60
|
* [`clearWatch(...)`](#clearwatch)
|
|
61
61
|
* [`checkPermissions()`](#checkpermissions)
|
|
62
|
-
* [`requestPermissions()`](#requestpermissions)
|
|
62
|
+
* [`requestPermissions(...)`](#requestpermissions)
|
|
63
63
|
* [Interfaces](#interfaces)
|
|
64
64
|
* [Type Aliases](#type-aliases)
|
|
65
65
|
|
|
@@ -140,14 +140,18 @@ Check location permissions
|
|
|
140
140
|
--------------------
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
### requestPermissions()
|
|
143
|
+
### requestPermissions(...)
|
|
144
144
|
|
|
145
145
|
```typescript
|
|
146
|
-
requestPermissions() => Promise<PermissionStatus>
|
|
146
|
+
requestPermissions(permissions?: GeolocationPluginPermissions | undefined) => Promise<PermissionStatus>
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
Request location permissions
|
|
150
150
|
|
|
151
|
+
| Param | Type |
|
|
152
|
+
| ----------------- | ------------------------------------------------------------------------------------- |
|
|
153
|
+
| **`permissions`** | <code><a href="#geolocationpluginpermissions">GeolocationPluginPermissions</a></code> |
|
|
154
|
+
|
|
151
155
|
**Returns:** <code>Promise<<a href="#permissionstatus">PermissionStatus</a>></code>
|
|
152
156
|
|
|
153
157
|
**Since:** 1.0.0
|
|
@@ -168,11 +172,11 @@ Request location permissions
|
|
|
168
172
|
|
|
169
173
|
#### PositionOptions
|
|
170
174
|
|
|
171
|
-
| Prop | Type | Description
|
|
172
|
-
| ------------------------ | -------------------- |
|
|
173
|
-
| **`enableHighAccuracy`** | <code>boolean</code> | High accuracy mode (such as GPS, if available)
|
|
174
|
-
| **`timeout`** | <code>number</code> | The maximum wait time in milliseconds for location updates
|
|
175
|
-
| **`maximumAge`** | <code>number</code> | The maximum age in milliseconds of a possible cached position that is acceptable to return
|
|
175
|
+
| Prop | Type | Description | Default | Since |
|
|
176
|
+
| ------------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
|
|
177
|
+
| **`enableHighAccuracy`** | <code>boolean</code> | High accuracy mode (such as GPS, if available) On Android 12+ devices it will be ignored if users didn't grant ACCESS_FINE_LOCATION permissions (can be checked with location alias). | <code>false</code> | 1.0.0 |
|
|
178
|
+
| **`timeout`** | <code>number</code> | The maximum wait time in milliseconds for location updates | <code>10000</code> | 1.0.0 |
|
|
179
|
+
| **`maximumAge`** | <code>number</code> | The maximum age in milliseconds of a possible cached position that is acceptable to return | <code>0</code> | 1.0.0 |
|
|
176
180
|
|
|
177
181
|
|
|
178
182
|
#### ClearWatchOptions
|
|
@@ -184,9 +188,17 @@ Request location permissions
|
|
|
184
188
|
|
|
185
189
|
#### PermissionStatus
|
|
186
190
|
|
|
187
|
-
| Prop
|
|
188
|
-
|
|
|
189
|
-
| **`location`**
|
|
191
|
+
| Prop | Type | Description | Since |
|
|
192
|
+
| -------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
|
|
193
|
+
| **`location`** | <code><a href="#permissionstate">PermissionState</a></code> | Permission state for location alias. On Android it requests/checks both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions. On iOS and web it requests/checks location permission. | 1.0.0 |
|
|
194
|
+
| **`coarseLocation`** | <code><a href="#permissionstate">PermissionState</a></code> | Permission state for coarseLocation alias. On Android it requests/checks ACCESS_COARSE_LOCATION. On Android 12+, users can choose between Approximate location (ACCESS_COARSE_LOCATION) or Precise location (ACCESS_FINE_LOCATION), so this alias can be used if the app doesn't need high accuracy. On iOS and web it will have the same value as location alias. | 1.2.0 |
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
#### GeolocationPluginPermissions
|
|
198
|
+
|
|
199
|
+
| Prop | Type |
|
|
200
|
+
| ----------------- | ---------------------------------------- |
|
|
201
|
+
| **`permissions`** | <code>GeolocationPermissionType[]</code> |
|
|
190
202
|
|
|
191
203
|
|
|
192
204
|
### Type Aliases
|
|
@@ -206,4 +218,9 @@ Request location permissions
|
|
|
206
218
|
|
|
207
219
|
<code>'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'</code>
|
|
208
220
|
|
|
221
|
+
|
|
222
|
+
#### GeolocationPermissionType
|
|
223
|
+
|
|
224
|
+
<code>'location' | 'coarseLocation'</code>
|
|
225
|
+
|
|
209
226
|
</docgen-api>
|
package/android/build.gradle
CHANGED
|
@@ -5,6 +5,8 @@ import android.location.Location;
|
|
|
5
5
|
import android.location.LocationManager;
|
|
6
6
|
import android.os.SystemClock;
|
|
7
7
|
import androidx.core.location.LocationManagerCompat;
|
|
8
|
+
import com.google.android.gms.common.ConnectionResult;
|
|
9
|
+
import com.google.android.gms.common.GoogleApiAvailability;
|
|
8
10
|
import com.google.android.gms.location.FusedLocationProviderClient;
|
|
9
11
|
import com.google.android.gms.location.LocationCallback;
|
|
10
12
|
import com.google.android.gms.location.LocationRequest;
|
|
@@ -38,44 +40,49 @@ public class Geolocation {
|
|
|
38
40
|
final boolean getCurrentPosition,
|
|
39
41
|
final LocationResultCallback resultCallback
|
|
40
42
|
) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
int resultCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
|
|
44
|
+
if (resultCode == ConnectionResult.SUCCESS) {
|
|
45
|
+
clearLocationUpdates();
|
|
46
|
+
fusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
|
49
|
+
if (LocationManagerCompat.isLocationEnabled(lm)) {
|
|
50
|
+
boolean networkEnabled = false;
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
try {
|
|
53
|
+
networkEnabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
|
54
|
+
} catch (Exception ex) {}
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
LocationRequest locationRequest = new LocationRequest();
|
|
57
|
+
locationRequest.setMaxWaitTime(timeout);
|
|
58
|
+
locationRequest.setInterval(10000);
|
|
59
|
+
locationRequest.setFastestInterval(5000);
|
|
60
|
+
int lowPriority = networkEnabled ? LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY : LocationRequest.PRIORITY_LOW_POWER;
|
|
61
|
+
int priority = enableHighAccuracy ? LocationRequest.PRIORITY_HIGH_ACCURACY : lowPriority;
|
|
62
|
+
locationRequest.setPriority(priority);
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
locationCallback =
|
|
65
|
+
new LocationCallback() {
|
|
66
|
+
@Override
|
|
67
|
+
public void onLocationResult(LocationResult locationResult) {
|
|
68
|
+
if (getCurrentPosition) {
|
|
69
|
+
clearLocationUpdates();
|
|
70
|
+
}
|
|
71
|
+
Location lastLocation = locationResult.getLastLocation();
|
|
72
|
+
if (lastLocation == null) {
|
|
73
|
+
resultCallback.error("location unavailable");
|
|
74
|
+
} else {
|
|
75
|
+
resultCallback.success(lastLocation);
|
|
76
|
+
}
|
|
72
77
|
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
78
|
+
};
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, null);
|
|
81
|
+
} else {
|
|
82
|
+
resultCallback.error("location disabled");
|
|
83
|
+
}
|
|
77
84
|
} else {
|
|
78
|
-
resultCallback.error("
|
|
85
|
+
resultCallback.error("Google Play Services not available");
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
88
|
|
|
@@ -17,11 +17,17 @@ import java.util.Map;
|
|
|
17
17
|
@CapacitorPlugin(
|
|
18
18
|
name = "Geolocation",
|
|
19
19
|
permissions = {
|
|
20
|
-
@Permission(
|
|
20
|
+
@Permission(
|
|
21
|
+
strings = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION },
|
|
22
|
+
alias = GeolocationPlugin.LOCATION
|
|
23
|
+
),
|
|
24
|
+
@Permission(strings = { Manifest.permission.ACCESS_COARSE_LOCATION }, alias = GeolocationPlugin.COARSE_LOCATION)
|
|
21
25
|
}
|
|
22
26
|
)
|
|
23
27
|
public class GeolocationPlugin extends Plugin {
|
|
24
28
|
|
|
29
|
+
static final String LOCATION = "location";
|
|
30
|
+
static final String COARSE_LOCATION = "coarseLocation";
|
|
25
31
|
private Geolocation implementation;
|
|
26
32
|
private Map<String, PluginCall> watchingCalls = new HashMap<>();
|
|
27
33
|
|
|
@@ -38,8 +44,9 @@ public class GeolocationPlugin extends Plugin {
|
|
|
38
44
|
*/
|
|
39
45
|
@PluginMethod
|
|
40
46
|
public void getCurrentPosition(final PluginCall call) {
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
String alias = getAlias(call);
|
|
48
|
+
if (getPermissionState(alias) != PermissionState.GRANTED) {
|
|
49
|
+
requestPermissionForAlias(alias, call, "completeCurrentPosition");
|
|
43
50
|
} else {
|
|
44
51
|
getPosition(call);
|
|
45
52
|
}
|
|
@@ -52,12 +59,11 @@ public class GeolocationPlugin extends Plugin {
|
|
|
52
59
|
*/
|
|
53
60
|
@PermissionCallback
|
|
54
61
|
private void completeCurrentPosition(PluginCall call) {
|
|
55
|
-
if (getPermissionState(
|
|
56
|
-
boolean enableHighAccuracy = call.getBoolean("enableHighAccuracy", false);
|
|
62
|
+
if (getPermissionState(GeolocationPlugin.COARSE_LOCATION) == PermissionState.GRANTED) {
|
|
57
63
|
int timeout = call.getInt("timeout", 10000);
|
|
58
64
|
|
|
59
65
|
implementation.sendLocation(
|
|
60
|
-
|
|
66
|
+
isHighAccuracy(call),
|
|
61
67
|
timeout,
|
|
62
68
|
true,
|
|
63
69
|
new LocationResultCallback() {
|
|
@@ -86,8 +92,9 @@ public class GeolocationPlugin extends Plugin {
|
|
|
86
92
|
@PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
|
|
87
93
|
public void watchPosition(PluginCall call) {
|
|
88
94
|
call.setKeepAlive(true);
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
String alias = getAlias(call);
|
|
96
|
+
if (getPermissionState(alias) != PermissionState.GRANTED) {
|
|
97
|
+
requestPermissionForAlias(alias, call, "completeWatchPosition");
|
|
91
98
|
} else {
|
|
92
99
|
startWatch(call);
|
|
93
100
|
}
|
|
@@ -100,7 +107,7 @@ public class GeolocationPlugin extends Plugin {
|
|
|
100
107
|
*/
|
|
101
108
|
@PermissionCallback
|
|
102
109
|
private void completeWatchPosition(PluginCall call) {
|
|
103
|
-
if (getPermissionState(
|
|
110
|
+
if (getPermissionState(GeolocationPlugin.COARSE_LOCATION) == PermissionState.GRANTED) {
|
|
104
111
|
startWatch(call);
|
|
105
112
|
} else {
|
|
106
113
|
call.reject("Location permission was denied");
|
|
@@ -109,7 +116,6 @@ public class GeolocationPlugin extends Plugin {
|
|
|
109
116
|
|
|
110
117
|
@SuppressWarnings("MissingPermission")
|
|
111
118
|
private void getPosition(PluginCall call) {
|
|
112
|
-
boolean enableHighAccuracy = call.getBoolean("enableHighAccuracy", false);
|
|
113
119
|
int timeout = call.getInt("timeout", 10000);
|
|
114
120
|
int maximumAge = call.getInt("maximumAge", 0);
|
|
115
121
|
Location location = implementation.getLastLocation(maximumAge);
|
|
@@ -117,7 +123,7 @@ public class GeolocationPlugin extends Plugin {
|
|
|
117
123
|
call.resolve(getJSObjectForLocation(location));
|
|
118
124
|
} else {
|
|
119
125
|
implementation.sendLocation(
|
|
120
|
-
|
|
126
|
+
isHighAccuracy(call),
|
|
121
127
|
timeout,
|
|
122
128
|
true,
|
|
123
129
|
new LocationResultCallback() {
|
|
@@ -137,11 +143,10 @@ public class GeolocationPlugin extends Plugin {
|
|
|
137
143
|
|
|
138
144
|
@SuppressWarnings("MissingPermission")
|
|
139
145
|
private void startWatch(final PluginCall call) {
|
|
140
|
-
boolean enableHighAccuracy = call.getBoolean("enableHighAccuracy", false);
|
|
141
146
|
int timeout = call.getInt("timeout", 10000);
|
|
142
147
|
|
|
143
148
|
implementation.requestLocationUpdates(
|
|
144
|
-
|
|
149
|
+
isHighAccuracy(call),
|
|
145
150
|
timeout,
|
|
146
151
|
false,
|
|
147
152
|
new LocationResultCallback() {
|
|
@@ -202,4 +207,21 @@ public class GeolocationPlugin extends Plugin {
|
|
|
202
207
|
coords.put("heading", location.getBearing());
|
|
203
208
|
return ret;
|
|
204
209
|
}
|
|
210
|
+
|
|
211
|
+
private String getAlias(PluginCall call) {
|
|
212
|
+
String alias = GeolocationPlugin.LOCATION;
|
|
213
|
+
// TODO replace with Build.VERSION_CODES.S once we target SDK 31
|
|
214
|
+
if (Build.VERSION.SDK_INT >= 31) {
|
|
215
|
+
boolean enableHighAccuracy = call.getBoolean("enableHighAccuracy", false);
|
|
216
|
+
if (!enableHighAccuracy) {
|
|
217
|
+
alias = GeolocationPlugin.COARSE_LOCATION;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return alias;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private boolean isHighAccuracy(PluginCall call) {
|
|
224
|
+
boolean enableHighAccuracy = call.getBoolean("enableHighAccuracy", false);
|
|
225
|
+
return enableHighAccuracy && getPermissionState(GeolocationPlugin.LOCATION) == PermissionState.GRANTED;
|
|
226
|
+
}
|
|
205
227
|
}
|
package/dist/docs.json
CHANGED
|
@@ -101,8 +101,14 @@
|
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
"name": "requestPermissions",
|
|
104
|
-
"signature": "() => Promise<PermissionStatus>",
|
|
105
|
-
"parameters": [
|
|
104
|
+
"signature": "(permissions?: GeolocationPluginPermissions | undefined) => Promise<PermissionStatus>",
|
|
105
|
+
"parameters": [
|
|
106
|
+
{
|
|
107
|
+
"name": "permissions",
|
|
108
|
+
"docs": "",
|
|
109
|
+
"type": "GeolocationPluginPermissions | undefined"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
106
112
|
"returns": "Promise<PermissionStatus>",
|
|
107
113
|
"tags": [
|
|
108
114
|
{
|
|
@@ -112,7 +118,8 @@
|
|
|
112
118
|
],
|
|
113
119
|
"docs": "Request location permissions",
|
|
114
120
|
"complexTypes": [
|
|
115
|
-
"PermissionStatus"
|
|
121
|
+
"PermissionStatus",
|
|
122
|
+
"GeolocationPluginPermissions"
|
|
116
123
|
],
|
|
117
124
|
"slug": "requestpermissions"
|
|
118
125
|
}
|
|
@@ -172,7 +179,7 @@
|
|
|
172
179
|
"name": "since"
|
|
173
180
|
}
|
|
174
181
|
],
|
|
175
|
-
"docs": "High accuracy mode (such as GPS, if available)",
|
|
182
|
+
"docs": "High accuracy mode (such as GPS, if available)\n\nOn Android 12+ devices it will be ignored if users didn't grant\nACCESS_FINE_LOCATION permissions (can be checked with location alias).",
|
|
176
183
|
"complexTypes": [],
|
|
177
184
|
"type": "boolean | undefined"
|
|
178
185
|
},
|
|
@@ -237,14 +244,51 @@
|
|
|
237
244
|
"properties": [
|
|
238
245
|
{
|
|
239
246
|
"name": "location",
|
|
240
|
-
"tags": [
|
|
241
|
-
|
|
247
|
+
"tags": [
|
|
248
|
+
{
|
|
249
|
+
"text": "1.0.0",
|
|
250
|
+
"name": "since"
|
|
251
|
+
}
|
|
252
|
+
],
|
|
253
|
+
"docs": "Permission state for location alias.\n\nOn Android it requests/checks both ACCESS_COARSE_LOCATION and\nACCESS_FINE_LOCATION permissions.\n\nOn iOS and web it requests/checks location permission.",
|
|
254
|
+
"complexTypes": [
|
|
255
|
+
"PermissionState"
|
|
256
|
+
],
|
|
257
|
+
"type": "PermissionState"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"name": "coarseLocation",
|
|
261
|
+
"tags": [
|
|
262
|
+
{
|
|
263
|
+
"text": "1.2.0",
|
|
264
|
+
"name": "since"
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"docs": "Permission state for coarseLocation alias.\n\nOn Android it requests/checks ACCESS_COARSE_LOCATION.\n\nOn Android 12+, users can choose between Approximate location (ACCESS_COARSE_LOCATION) or\nPrecise location (ACCESS_FINE_LOCATION), so this alias can be used if the app doesn't\nneed high accuracy.\n\nOn iOS and web it will have the same value as location alias.",
|
|
242
268
|
"complexTypes": [
|
|
243
269
|
"PermissionState"
|
|
244
270
|
],
|
|
245
271
|
"type": "PermissionState"
|
|
246
272
|
}
|
|
247
273
|
]
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"name": "GeolocationPluginPermissions",
|
|
277
|
+
"slug": "geolocationpluginpermissions",
|
|
278
|
+
"docs": "",
|
|
279
|
+
"tags": [],
|
|
280
|
+
"methods": [],
|
|
281
|
+
"properties": [
|
|
282
|
+
{
|
|
283
|
+
"name": "permissions",
|
|
284
|
+
"tags": [],
|
|
285
|
+
"docs": "",
|
|
286
|
+
"complexTypes": [
|
|
287
|
+
"GeolocationPermissionType"
|
|
288
|
+
],
|
|
289
|
+
"type": "GeolocationPermissionType[]"
|
|
290
|
+
}
|
|
291
|
+
]
|
|
248
292
|
}
|
|
249
293
|
],
|
|
250
294
|
"enums": [],
|
|
@@ -295,6 +339,21 @@
|
|
|
295
339
|
"complexTypes": []
|
|
296
340
|
}
|
|
297
341
|
]
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"name": "GeolocationPermissionType",
|
|
345
|
+
"slug": "geolocationpermissiontype",
|
|
346
|
+
"docs": "",
|
|
347
|
+
"types": [
|
|
348
|
+
{
|
|
349
|
+
"text": "'location'",
|
|
350
|
+
"complexTypes": []
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"text": "'coarseLocation'",
|
|
354
|
+
"complexTypes": []
|
|
355
|
+
}
|
|
356
|
+
]
|
|
298
357
|
}
|
|
299
358
|
],
|
|
300
359
|
"pluginConfigs": []
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
import type { PermissionState } from '@capacitor/core';
|
|
2
2
|
export declare type CallbackID = string;
|
|
3
3
|
export interface PermissionStatus {
|
|
4
|
+
/**
|
|
5
|
+
* Permission state for location alias.
|
|
6
|
+
*
|
|
7
|
+
* On Android it requests/checks both ACCESS_COARSE_LOCATION and
|
|
8
|
+
* ACCESS_FINE_LOCATION permissions.
|
|
9
|
+
*
|
|
10
|
+
* On iOS and web it requests/checks location permission.
|
|
11
|
+
*
|
|
12
|
+
* @since 1.0.0
|
|
13
|
+
*/
|
|
4
14
|
location: PermissionState;
|
|
15
|
+
/**
|
|
16
|
+
* Permission state for coarseLocation alias.
|
|
17
|
+
*
|
|
18
|
+
* On Android it requests/checks ACCESS_COARSE_LOCATION.
|
|
19
|
+
*
|
|
20
|
+
* On Android 12+, users can choose between Approximate location (ACCESS_COARSE_LOCATION) or
|
|
21
|
+
* Precise location (ACCESS_FINE_LOCATION), so this alias can be used if the app doesn't
|
|
22
|
+
* need high accuracy.
|
|
23
|
+
*
|
|
24
|
+
* On iOS and web it will have the same value as location alias.
|
|
25
|
+
*
|
|
26
|
+
* @since 1.2.0
|
|
27
|
+
*/
|
|
28
|
+
coarseLocation: PermissionState;
|
|
29
|
+
}
|
|
30
|
+
export declare type GeolocationPermissionType = 'location' | 'coarseLocation';
|
|
31
|
+
export interface GeolocationPluginPermissions {
|
|
32
|
+
permissions: GeolocationPermissionType[];
|
|
5
33
|
}
|
|
6
34
|
export interface GeolocationPlugin {
|
|
7
35
|
/**
|
|
@@ -34,7 +62,7 @@ export interface GeolocationPlugin {
|
|
|
34
62
|
*
|
|
35
63
|
* @since 1.0.0
|
|
36
64
|
*/
|
|
37
|
-
requestPermissions(): Promise<PermissionStatus>;
|
|
65
|
+
requestPermissions(permissions?: GeolocationPluginPermissions): Promise<PermissionStatus>;
|
|
38
66
|
}
|
|
39
67
|
export interface ClearWatchOptions {
|
|
40
68
|
id: CallbackID;
|
|
@@ -102,6 +130,9 @@ export interface PositionOptions {
|
|
|
102
130
|
/**
|
|
103
131
|
* High accuracy mode (such as GPS, if available)
|
|
104
132
|
*
|
|
133
|
+
* On Android 12+ devices it will be ignored if users didn't grant
|
|
134
|
+
* ACCESS_FINE_LOCATION permissions (can be checked with location alias).
|
|
135
|
+
*
|
|
105
136
|
* @default false
|
|
106
137
|
* @since 1.0.0
|
|
107
138
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\nexport type CallbackID = string;\n\nexport interface PermissionStatus {\n /**\n * Permission state for location alias.\n *\n * On Android it requests/checks both ACCESS_COARSE_LOCATION and\n * ACCESS_FINE_LOCATION permissions.\n *\n * On iOS and web it requests/checks location permission.\n *\n * @since 1.0.0\n */\n location: PermissionState;\n\n /**\n * Permission state for coarseLocation alias.\n *\n * On Android it requests/checks ACCESS_COARSE_LOCATION.\n *\n * On Android 12+, users can choose between Approximate location (ACCESS_COARSE_LOCATION) or\n * Precise location (ACCESS_FINE_LOCATION), so this alias can be used if the app doesn't\n * need high accuracy.\n *\n * On iOS and web it will have the same value as location alias.\n *\n * @since 1.2.0\n */\n coarseLocation: PermissionState;\n}\n\nexport type GeolocationPermissionType = 'location' | 'coarseLocation';\n\nexport interface GeolocationPluginPermissions {\n permissions: GeolocationPermissionType[];\n}\n\nexport interface GeolocationPlugin {\n /**\n * Get the current GPS location of the device\n *\n * @since 1.0.0\n */\n getCurrentPosition(options?: PositionOptions): Promise<Position>;\n\n /**\n * Set up a watch for location changes. Note that watching for location changes\n * can consume a large amount of energy. Be smart about listening only when you need to.\n *\n * @since 1.0.0\n */\n watchPosition(\n options: PositionOptions,\n callback: WatchPositionCallback,\n ): Promise<CallbackID>;\n\n /**\n * Clear a given watch\n *\n * @since 1.0.0\n */\n clearWatch(options: ClearWatchOptions): Promise<void>;\n\n /**\n * Check location permissions\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request location permissions\n *\n * @since 1.0.0\n */\n requestPermissions(\n permissions?: GeolocationPluginPermissions,\n ): Promise<PermissionStatus>;\n}\n\nexport interface ClearWatchOptions {\n id: CallbackID;\n}\n\nexport interface Position {\n /**\n * Creation timestamp for coords\n *\n * @since 1.0.0\n */\n timestamp: number;\n\n /**\n * The GPS coordinates along with the accuracy of the data\n *\n * @since 1.0.0\n */\n coords: {\n /**\n * Latitude in decimal degrees\n *\n * @since 1.0.0\n */\n latitude: number;\n\n /**\n * longitude in decimal degrees\n *\n * @since 1.0.0\n */\n longitude: number;\n\n /**\n * Accuracy level of the latitude and longitude coordinates in meters\n *\n * @since 1.0.0\n */\n accuracy: number;\n\n /**\n * Accuracy level of the altitude coordinate in meters, if available.\n *\n * Available on all iOS versions and on Android 8.0+.\n *\n * @since 1.0.0\n */\n altitudeAccuracy: number | null | undefined;\n\n /**\n * The altitude the user is at (if available)\n *\n * @since 1.0.0\n */\n altitude: number | null;\n\n /**\n * The speed the user is traveling (if available)\n *\n * @since 1.0.0\n */\n speed: number | null;\n\n /**\n * The heading the user is facing (if available)\n *\n * @since 1.0.0\n */\n heading: number | null;\n };\n}\n\nexport interface PositionOptions {\n /**\n * High accuracy mode (such as GPS, if available)\n *\n * On Android 12+ devices it will be ignored if users didn't grant\n * ACCESS_FINE_LOCATION permissions (can be checked with location alias).\n *\n * @default false\n * @since 1.0.0\n */\n enableHighAccuracy?: boolean;\n\n /**\n * The maximum wait time in milliseconds for location updates\n *\n * @default 10000\n * @since 1.0.0\n */\n timeout?: number;\n\n /**\n * The maximum age in milliseconds of a possible cached position that is acceptable to return\n *\n * @default 0\n * @since 1.0.0\n */\n maximumAge?: number;\n}\n\nexport type WatchPositionCallback = (\n position: Position | null,\n err?: any,\n) => void;\n\n/**\n * @deprecated Use `PositionOptions`.\n * @since 1.0.0\n */\nexport type GeolocationOptions = PositionOptions;\n\n/**\n * @deprecated Use `WatchPositionCallback`.\n * @since 1.0.0\n */\nexport type GeolocationWatchCallback = WatchPositionCallback;\n\n/**\n * @deprecated Use `Position`.\n * @since 1.0.0\n */\nexport type GeolocationPosition = Position;\n"]}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,WAAW,GAAG,cAAc,CAAoB,aAAa,EAAE;IACnE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC7D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,WAAW,GAAG,cAAc,CAAoB,aAAa,EAAE;IACnE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC7D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { GeolocationPlugin } from './definitions';\n\nconst Geolocation = registerPlugin<GeolocationPlugin>('Geolocation', {\n web: () => import('./web').then(m => new m.GeolocationWeb()),\n});\n\nexport * from './definitions';\nexport { Geolocation };\n"]}
|
package/dist/esm/web.js
CHANGED
|
@@ -27,7 +27,7 @@ export class GeolocationWeb extends WebPlugin {
|
|
|
27
27
|
const permission = await window.navigator.permissions.query({
|
|
28
28
|
name: 'geolocation',
|
|
29
29
|
});
|
|
30
|
-
return { location: permission.state };
|
|
30
|
+
return { location: permission.state, coarseLocation: permission.state };
|
|
31
31
|
}
|
|
32
32
|
async requestPermissions() {
|
|
33
33
|
throw this.unimplemented('Not implemented on web.');
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C,KAAK,CAAC,kBAAkB,CAAC,OAAyB;QAChD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,SAAS,CAAC,WAAW,CAAC,kBAAkB,CACtC,GAAG,CAAC,EAAE;gBACJ,OAAO,CAAC,GAAG,CAAC,CAAC;YACf,CAAC,EACD,GAAG,CAAC,EAAE;gBACJ,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,kBAEC,kBAAkB,EAAE,KAAK,EACzB,OAAO,EAAE,KAAK,EACd,UAAU,EAAE,CAAC,IACV,OAAO,EAEb,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,OAAwB,EACxB,QAA+B;QAE/B,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,aAAa,CAC5C,GAAG,CAAC,EAAE;YACJ,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC,EACD,GAAG,CAAC,EAAE;YACJ,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACtB,CAAC,kBAEC,kBAAkB,EAAE,KAAK,EACzB,OAAO,EAAE,KAAK,EACd,UAAU,EAAE,CAAC,IACV,OAAO,EAEb,CAAC;QAEF,OAAO,GAAG,EAAE,EAAE,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAuB;QACtC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,EAA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B,EAAE,KAAK,EACzB,OAAO,EAAE,KAAK,EACd,UAAU,EAAE,CAAC,IACV,OAAO,EAEb,CAAC;QAEF,OAAO,GAAG,EAAE,EAAE,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAuB;QACtC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YAC9D,MAAM,IAAI,CAAC,WAAW,CAAC,+CAA+C,CAAC,CAAC;SACzE;QAED,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;YAC1D,IAAI,EAAE,aAAa;SACpB,CAAC,CAAC;QACH,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF;AAED,MAAM,WAAW,GAAG,IAAI,cAAc,EAAE,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n CallbackID,\n GeolocationPlugin,\n PermissionStatus,\n Position,\n PositionOptions,\n WatchPositionCallback,\n} from './definitions';\n\nexport class GeolocationWeb extends WebPlugin implements GeolocationPlugin {\n async getCurrentPosition(options?: PositionOptions): Promise<Position> {\n return new Promise((resolve, reject) => {\n navigator.geolocation.getCurrentPosition(\n pos => {\n resolve(pos);\n },\n err => {\n reject(err);\n },\n {\n enableHighAccuracy: false,\n timeout: 10000,\n maximumAge: 0,\n ...options,\n },\n );\n });\n }\n\n async watchPosition(\n options: PositionOptions,\n callback: WatchPositionCallback,\n ): Promise<CallbackID> {\n const id = navigator.geolocation.watchPosition(\n pos => {\n callback(pos);\n },\n err => {\n callback(null, err);\n },\n {\n enableHighAccuracy: false,\n timeout: 10000,\n maximumAge: 0,\n ...options,\n },\n );\n\n return `${id}`;\n }\n\n async clearWatch(options: { id: string }): Promise<void> {\n window.navigator.geolocation.clearWatch(parseInt(options.id, 10));\n }\n\n async checkPermissions(): Promise<PermissionStatus> {\n if (typeof navigator === 'undefined' || !navigator.permissions) {\n throw this.unavailable('Permissions API not available in this browser');\n }\n\n const permission = await window.navigator.permissions.query({\n name: 'geolocation',\n });\n return { location: permission.state, coarseLocation: permission.state };\n }\n\n async requestPermissions(): Promise<PermissionStatus> {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n\nconst Geolocation = new GeolocationWeb();\n\nexport { Geolocation };\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -36,7 +36,7 @@ class GeolocationWeb extends core.WebPlugin {
|
|
|
36
36
|
const permission = await window.navigator.permissions.query({
|
|
37
37
|
name: 'geolocation',
|
|
38
38
|
});
|
|
39
|
-
return { location: permission.state };
|
|
39
|
+
return { location: permission.state, coarseLocation: permission.state };
|
|
40
40
|
}
|
|
41
41
|
async requestPermissions() {
|
|
42
42
|
throw this.unimplemented('Not implemented on web.');
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Geolocation = registerPlugin('Geolocation', {\n web: () => import('./web').then(m => new m.GeolocationWeb()),\n});\nexport * from './definitions';\nexport { Geolocation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class GeolocationWeb extends WebPlugin {\n async getCurrentPosition(options) {\n return new Promise((resolve, reject) => {\n navigator.geolocation.getCurrentPosition(pos => {\n resolve(pos);\n }, err => {\n reject(err);\n }, Object.assign({ enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }, options));\n });\n }\n async watchPosition(options, callback) {\n const id = navigator.geolocation.watchPosition(pos => {\n callback(pos);\n }, err => {\n callback(null, err);\n }, Object.assign({ enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }, options));\n return `${id}`;\n }\n async clearWatch(options) {\n window.navigator.geolocation.clearWatch(parseInt(options.id, 10));\n }\n async checkPermissions() {\n if (typeof navigator === 'undefined' || !navigator.permissions) {\n throw this.unavailable('Permissions API not available in this browser');\n }\n const permission = await window.navigator.permissions.query({\n name: 'geolocation',\n });\n return { location: permission.state };\n }\n async requestPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst Geolocation = new GeolocationWeb();\nexport { Geolocation };\n//# sourceMappingURL=web.js.map"],"names":["Geolocation","registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAACA,aAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAChE,CAAC;;ACFM,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;AACtC,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,IAAI;AAC5D,gBAAgB,OAAO,CAAC,GAAG,CAAC,CAAC;AAC7B,aAAa,EAAE,GAAG,IAAI;AACtB,gBAAgB,MAAM,CAAC,GAAG,CAAC,CAAC;AAC5B,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;AACrG,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE;AAC3C,QAAQ,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,IAAI;AAC9D,YAAY,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC1B,SAAS,EAAE,GAAG,IAAI;AAClB,YAAY,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAChC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;AACjG,QAAQ,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;AAC9B,QAAQ,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1E,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;AACxE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,+CAA+C,CAAC,CAAC;AACpF,SAAS;AACT,QAAQ,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;AACpE,YAAY,IAAI,EAAE,aAAa;AAC/B,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Geolocation = registerPlugin('Geolocation', {\n web: () => import('./web').then(m => new m.GeolocationWeb()),\n});\nexport * from './definitions';\nexport { Geolocation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class GeolocationWeb extends WebPlugin {\n async getCurrentPosition(options) {\n return new Promise((resolve, reject) => {\n navigator.geolocation.getCurrentPosition(pos => {\n resolve(pos);\n }, err => {\n reject(err);\n }, Object.assign({ enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }, options));\n });\n }\n async watchPosition(options, callback) {\n const id = navigator.geolocation.watchPosition(pos => {\n callback(pos);\n }, err => {\n callback(null, err);\n }, Object.assign({ enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }, options));\n return `${id}`;\n }\n async clearWatch(options) {\n window.navigator.geolocation.clearWatch(parseInt(options.id, 10));\n }\n async checkPermissions() {\n if (typeof navigator === 'undefined' || !navigator.permissions) {\n throw this.unavailable('Permissions API not available in this browser');\n }\n const permission = await window.navigator.permissions.query({\n name: 'geolocation',\n });\n return { location: permission.state, coarseLocation: permission.state };\n }\n async requestPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst Geolocation = new GeolocationWeb();\nexport { Geolocation };\n//# sourceMappingURL=web.js.map"],"names":["Geolocation","registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAACA,aAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAChE,CAAC;;ACFM,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;AACtC,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,IAAI;AAC5D,gBAAgB,OAAO,CAAC,GAAG,CAAC,CAAC;AAC7B,aAAa,EAAE,GAAG,IAAI;AACtB,gBAAgB,MAAM,CAAC,GAAG,CAA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AAC,KAAK,EAAE,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC;AAChF,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL,CAAC;AACD,MAAM,WAAW,GAAG,IAAI,cAAc,EAAE;;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -33,7 +33,7 @@ var capacitorGeolocation = (function (exports, core) {
|
|
|
33
33
|
const permission = await window.navigator.permissions.query({
|
|
34
34
|
name: 'geolocation',
|
|
35
35
|
});
|
|
36
|
-
return { location: permission.state };
|
|
36
|
+
return { location: permission.state, coarseLocation: permission.state };
|
|
37
37
|
}
|
|
38
38
|
async requestPermissions() {
|
|
39
39
|
throw this.unimplemented('Not implemented on web.');
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Geolocation = registerPlugin('Geolocation', {\n web: () => import('./web').then(m => new m.GeolocationWeb()),\n});\nexport * from './definitions';\nexport { Geolocation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class GeolocationWeb extends WebPlugin {\n async getCurrentPosition(options) {\n return new Promise((resolve, reject) => {\n navigator.geolocation.getCurrentPosition(pos => {\n resolve(pos);\n }, err => {\n reject(err);\n }, Object.assign({ enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }, options));\n });\n }\n async watchPosition(options, callback) {\n const id = navigator.geolocation.watchPosition(pos => {\n callback(pos);\n }, err => {\n callback(null, err);\n }, Object.assign({ enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }, options));\n return `${id}`;\n }\n async clearWatch(options) {\n window.navigator.geolocation.clearWatch(parseInt(options.id, 10));\n }\n async checkPermissions() {\n if (typeof navigator === 'undefined' || !navigator.permissions) {\n throw this.unavailable('Permissions API not available in this browser');\n }\n const permission = await window.navigator.permissions.query({\n name: 'geolocation',\n });\n return { location: permission.state };\n }\n async requestPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst Geolocation = new GeolocationWeb();\nexport { Geolocation };\n//# sourceMappingURL=web.js.map"],"names":["Geolocation","registerPlugin","WebPlugin"],"mappings":";;;AACK,UAACA,aAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;IAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;IAChE,CAAC;;ICFM,MAAM,cAAc,SAASC,cAAS,CAAC;IAC9C,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;IACtC,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;IAChD,YAAY,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,IAAI;IAC5D,gBAAgB,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7B,aAAa,EAAE,GAAG,IAAI;IACtB,gBAAgB,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;IACrG,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,MAAM,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE;IAC3C,QAAQ,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,IAAI;IAC9D,YAAY,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC1B,SAAS,EAAE,GAAG,IAAI;IAClB,YAAY,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;IACjG,QAAQ,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;IAC9B,QAAQ,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1E,KAAK;IACL,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;IACxE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,+CAA+C,CAAC,CAAC;IACpF,SAAS;IACT,QAAQ,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;IACpE,YAAY,IAAI,EAAE,aAAa;IAC/B,SAAS,CAAC,CAAC;IACX,QAAQ,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Geolocation = registerPlugin('Geolocation', {\n web: () => import('./web').then(m => new m.GeolocationWeb()),\n});\nexport * from './definitions';\nexport { Geolocation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class GeolocationWeb extends WebPlugin {\n async getCurrentPosition(options) {\n return new Promise((resolve, reject) => {\n navigator.geolocation.getCurrentPosition(pos => {\n resolve(pos);\n }, err => {\n reject(err);\n }, Object.assign({ enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }, options));\n });\n }\n async watchPosition(options, callback) {\n const id = navigator.geolocation.watchPosition(pos => {\n callback(pos);\n }, err => {\n callback(null, err);\n }, Object.assign({ enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }, options));\n return `${id}`;\n }\n async clearWatch(options) {\n window.navigator.geolocation.clearWatch(parseInt(options.id, 10));\n }\n async checkPermissions() {\n if (typeof navigator === 'undefined' || !navigator.permissions) {\n throw this.unavailable('Permissions API not available in this browser');\n }\n const permission = await window.navigator.permissions.query({\n name: 'geolocation',\n });\n return { location: permission.state, coarseLocation: permission.state };\n }\n async requestPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst Geolocation = new GeolocationWeb();\nexport { Geolocation };\n//# sourceMappingURL=web.js.map"],"names":["Geolocation","registerPlugin","WebPlugin"],"mappings":";;;AACK,UAACA,aAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;IAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;IAChE,CAAC;;ICFM,MAAM,cAAc,SAASC,cAAS,CAAC;IAC9C,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;IACtC,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;IAChD,YAAY,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,IAAI;IAC5D,gBAAgB,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7B,aAAa,EAAE,GAAG,IAAI;IACtB,gBAAgB,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;IACrG,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,MAAM,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE;IAC3C,QAAQ,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,I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"@capacitor/geolocation",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "The Geolocation API provides simple methods for getting and tracking the current position of the device using GPS, along with altitude, heading, and speed information if available.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
34
34
|
"verify:web": "npm run build",
|
|
35
35
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
36
|
-
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint --
|
|
36
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
37
37
|
"eslint": "eslint . --ext ts",
|
|
38
38
|
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
39
39
|
"swiftlint": "node-swiftlint",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "f18ee6482e1ec8e5fb0290d51f598397133af990"
|
|
83
83
|
}
|