@capacitor/geolocation 1.1.0 → 1.3.0
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 +53 -0
- package/README.md +28 -11
- package/android/src/main/java/com/capacitorjs/plugins/geolocation/Geolocation.java +59 -31
- package/android/src/main/java/com/capacitorjs/plugins/geolocation/GeolocationPlugin.java +54 -27
- package/dist/docs.json +65 -6
- package/dist/esm/definitions.d.ts +32 -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 +2 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/GeolocationPlugin.swift +2 -1
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,59 @@
|
|
|
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.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.2.0...@capacitor/geolocation@1.3.0) (2021-12-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **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))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [1.2.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.1.3...@capacitor/geolocation@1.2.0) (2021-11-17)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **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))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [1.1.3](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.1.2...@capacitor/geolocation@1.1.3) (2021-11-03)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @capacitor/geolocation
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [1.1.2](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.1.1...@capacitor/geolocation@1.1.2) (2021-10-14)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* remove postpublish scripts ([#656](https://github.com/ionic-team/capacitor-plugins/issues/656)) ([ed6ac49](https://github.com/ionic-team/capacitor-plugins/commit/ed6ac499ebf4a47525071ccbfc36c27503e11f60))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## [1.1.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.1.0...@capacitor/geolocation@1.1.1) (2021-10-13)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* correct addListeners links ([#655](https://github.com/ionic-team/capacitor-plugins/issues/655)) ([f9871e7](https://github.com/ionic-team/capacitor-plugins/commit/f9871e7bd53478addb21155e148829f550c0e457))
|
|
53
|
+
* **geolocation:** return cached location if newer than maximumAge ([#639](https://github.com/ionic-team/capacitor-plugins/issues/639)) ([7b08eea](https://github.com/ionic-team/capacitor-plugins/commit/7b08eea9729bbf2b2b6b881cc81389cf108b3a2c))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
6
59
|
# [1.1.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/geolocation@1.0.2...@capacitor/geolocation@1.1.0) (2021-09-01)
|
|
7
60
|
|
|
8
61
|
|
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>
|
|
@@ -3,7 +3,10 @@ package com.capacitorjs.plugins.geolocation;
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.location.Location;
|
|
5
5
|
import android.location.LocationManager;
|
|
6
|
+
import android.os.SystemClock;
|
|
6
7
|
import androidx.core.location.LocationManagerCompat;
|
|
8
|
+
import com.google.android.gms.common.ConnectionResult;
|
|
9
|
+
import com.google.android.gms.common.GoogleApiAvailability;
|
|
7
10
|
import com.google.android.gms.location.FusedLocationProviderClient;
|
|
8
11
|
import com.google.android.gms.location.LocationCallback;
|
|
9
12
|
import com.google.android.gms.location.LocationRequest;
|
|
@@ -37,44 +40,49 @@ public class Geolocation {
|
|
|
37
40
|
final boolean getCurrentPosition,
|
|
38
41
|
final LocationResultCallback resultCallback
|
|
39
42
|
) {
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
int resultCode = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
|
|
44
|
+
if (resultCode == ConnectionResult.SUCCESS) {
|
|
45
|
+
clearLocationUpdates();
|
|
46
|
+
fusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
|
49
|
+
if (LocationManagerCompat.isLocationEnabled(lm)) {
|
|
50
|
+
boolean networkEnabled = false;
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
try {
|
|
53
|
+
networkEnabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
|
54
|
+
} catch (Exception ex) {}
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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);
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
}
|
|
71
77
|
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
78
|
+
};
|
|
74
79
|
|
|
75
|
-
|
|
80
|
+
fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, null);
|
|
81
|
+
} else {
|
|
82
|
+
resultCallback.error("location disabled");
|
|
83
|
+
}
|
|
76
84
|
} else {
|
|
77
|
-
resultCallback.error("
|
|
85
|
+
resultCallback.error("Google Play Services not available");
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
88
|
|
|
@@ -84,4 +92,24 @@ public class Geolocation {
|
|
|
84
92
|
locationCallback = null;
|
|
85
93
|
}
|
|
86
94
|
}
|
|
95
|
+
|
|
96
|
+
@SuppressWarnings("MissingPermission")
|
|
97
|
+
public Location getLastLocation(int maximumAge) {
|
|
98
|
+
Location lastLoc = null;
|
|
99
|
+
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
|
100
|
+
for (String provider : lm.getAllProviders()) {
|
|
101
|
+
Location tmpLoc = lm.getLastKnownLocation(provider);
|
|
102
|
+
if (tmpLoc != null) {
|
|
103
|
+
long locationAge = SystemClock.elapsedRealtimeNanos() - tmpLoc.getElapsedRealtimeNanos();
|
|
104
|
+
long maximumAgeNanoSec = maximumAge * 1000000L;
|
|
105
|
+
if (
|
|
106
|
+
locationAge <= maximumAgeNanoSec &&
|
|
107
|
+
(lastLoc == null || lastLoc.getElapsedRealtimeNanos() > tmpLoc.getElapsedRealtimeNanos())
|
|
108
|
+
) {
|
|
109
|
+
lastLoc = tmpLoc;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return lastLoc;
|
|
114
|
+
}
|
|
87
115
|
}
|
|
@@ -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,34 +116,37 @@ 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);
|
|
120
|
+
int maximumAge = call.getInt("maximumAge", 0);
|
|
121
|
+
Location location = implementation.getLastLocation(maximumAge);
|
|
122
|
+
if (location != null) {
|
|
123
|
+
call.resolve(getJSObjectForLocation(location));
|
|
124
|
+
} else {
|
|
125
|
+
implementation.sendLocation(
|
|
126
|
+
isHighAccuracy(call),
|
|
127
|
+
timeout,
|
|
128
|
+
true,
|
|
129
|
+
new LocationResultCallback() {
|
|
130
|
+
@Override
|
|
131
|
+
public void success(Location location) {
|
|
132
|
+
call.resolve(getJSObjectForLocation(location));
|
|
133
|
+
}
|
|
114
134
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
new LocationResultCallback() {
|
|
120
|
-
@Override
|
|
121
|
-
public void success(Location location) {
|
|
122
|
-
call.resolve(getJSObjectForLocation(location));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@Override
|
|
126
|
-
public void error(String message) {
|
|
127
|
-
call.reject(message);
|
|
135
|
+
@Override
|
|
136
|
+
public void error(String message) {
|
|
137
|
+
call.reject(message);
|
|
138
|
+
}
|
|
128
139
|
}
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
);
|
|
141
|
+
}
|
|
131
142
|
}
|
|
132
143
|
|
|
133
144
|
@SuppressWarnings("MissingPermission")
|
|
134
145
|
private void startWatch(final PluginCall call) {
|
|
135
|
-
boolean enableHighAccuracy = call.getBoolean("enableHighAccuracy", false);
|
|
136
146
|
int timeout = call.getInt("timeout", 10000);
|
|
137
147
|
|
|
138
148
|
implementation.requestLocationUpdates(
|
|
139
|
-
|
|
149
|
+
isHighAccuracy(call),
|
|
140
150
|
timeout,
|
|
141
151
|
false,
|
|
142
152
|
new LocationResultCallback() {
|
|
@@ -197,4 +207,21 @@ public class GeolocationPlugin extends Plugin {
|
|
|
197
207
|
coords.put("heading", location.getBearing());
|
|
198
208
|
return ret;
|
|
199
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
|
+
}
|
|
200
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
|
*/
|
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,E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;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"}
|
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,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;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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.');
|
|
@@ -53,5 +53,5 @@ var capacitorGeolocation = (function (exports, core) {
|
|
|
53
53
|
|
|
54
54
|
return exports;
|
|
55
55
|
|
|
56
|
-
}({}, capacitorExports)
|
|
56
|
+
})({}, capacitorExports);
|
|
57
57
|
//# sourceMappingURL=plugin.js.map
|
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,IAAI;IAC9D,YAAY,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC1B,SAAS,EAAE,G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
|
"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",
|
|
@@ -42,13 +42,12 @@
|
|
|
42
42
|
"clean": "rimraf ./dist",
|
|
43
43
|
"watch": "tsc --watch",
|
|
44
44
|
"prepublishOnly": "npm run build",
|
|
45
|
-
"postpublish": "npm run publish:cocoapod",
|
|
46
45
|
"publish:cocoapod": "pod trunk push ./CapacitorGeolocation.podspec --allow-warnings"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@capacitor/android": "^3.0.0",
|
|
50
49
|
"@capacitor/core": "^3.0.0",
|
|
51
|
-
"@capacitor/docgen": "0.0.
|
|
50
|
+
"@capacitor/docgen": "0.0.18",
|
|
52
51
|
"@capacitor/ios": "^3.0.0",
|
|
53
52
|
"@ionic/eslint-config": "^0.3.0",
|
|
54
53
|
"@ionic/prettier-config": "~1.0.1",
|
|
@@ -80,5 +79,5 @@
|
|
|
80
79
|
"publishConfig": {
|
|
81
80
|
"access": "public"
|
|
82
81
|
},
|
|
83
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "d378c00d51b1c9fb978772906448fa0ec9cb81d0"
|
|
84
83
|
}
|