@capacitor/geolocation 1.2.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
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
|
|
6
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)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/geolocation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "d378c00d51b1c9fb978772906448fa0ec9cb81d0"
|
|
83
83
|
}
|