expo-location 13.0.3 → 14.0.2
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 +25 -3
- package/README.md +1 -1
- package/android/build.gradle +16 -18
- package/android/src/main/java/expo/modules/location/LocationHelpers.java +1 -0
- package/android/src/main/java/expo/modules/location/exceptions/LocationUnavailableException.java +1 -1
- package/android/src/main/java/expo/modules/location/taskConsumers/GeofencingTaskConsumer.java +10 -1
- package/android/src/main/java/expo/modules/location/taskConsumers/LocationTaskConsumer.java +4 -0
- package/build/GeolocationPolyfill.d.ts +3 -0
- package/build/GeolocationPolyfill.js +4 -2
- package/build/GeolocationPolyfill.js.map +1 -1
- package/build/Location.d.ts +160 -29
- package/build/Location.js +183 -32
- package/build/Location.js.map +1 -1
- package/build/Location.types.d.ts +265 -18
- package/build/Location.types.js +57 -0
- package/build/Location.types.js.map +1 -1
- package/build/LocationGoogleGeocoding.d.ts +8 -0
- package/build/LocationGoogleGeocoding.js +13 -0
- package/build/LocationGoogleGeocoding.js.map +1 -1
- package/build/LocationSubscribers.d.ts +1 -1
- package/build/LocationSubscribers.js +1 -1
- package/build/LocationSubscribers.js.map +1 -1
- package/ios/EXLocation/EXLocation.m +3 -2
- package/ios/EXLocation.xcframework/Info.plist +5 -5
- package/ios/EXLocation.xcframework/ios-arm64/EXLocation.framework/EXLocation +0 -0
- package/ios/EXLocation.xcframework/ios-arm64/EXLocation.framework/Info.plist +0 -0
- package/ios/EXLocation.xcframework/ios-arm64_x86_64-simulator/EXLocation.framework/EXLocation +0 -0
- package/ios/EXLocation.xcframework/ios-arm64_x86_64-simulator/EXLocation.framework/Info.plist +0 -0
- package/package.json +6 -3
- package/plugin/build/withLocation.js +3 -3
- package/src/GeolocationPolyfill.ts +4 -2
- package/src/Location.ts +188 -35
- package/src/Location.types.ts +291 -26
- package/src/LocationGoogleGeocoding.ts +13 -0
- package/src/LocationSubscribers.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,14 +10,35 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## 14.0.2 — 2022-02-01
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
- Fix `Plugin with id 'maven' not found` build error from Android Gradle 7. ([#16080](https://github.com/expo/expo/pull/16080) by [@kudo](https://github.com/kudo))
|
|
18
|
+
|
|
19
|
+
## 14.0.1 — 2021-12-15
|
|
18
20
|
|
|
19
21
|
_This version does not introduce any user-facing changes._
|
|
20
22
|
|
|
23
|
+
## 14.0.0 — 2021-12-03
|
|
24
|
+
|
|
25
|
+
### 🛠 Breaking changes
|
|
26
|
+
|
|
27
|
+
- Remove deprecated `setApiKey` method. ([#14672](https://github.com/expo/expo/pull/14672) by [@Simek](https://github.com/Simek))
|
|
28
|
+
|
|
29
|
+
### 🎉 New features
|
|
30
|
+
|
|
31
|
+
- Added steetNumber to `reverseGeocodeAsync` for iOS ([#13556](https://github.com/expo/expo/pull/13556) by [@chrisdrackett](https://github.com/chrisdrackett))
|
|
32
|
+
|
|
33
|
+
### 🐛 Bug fixes
|
|
34
|
+
|
|
35
|
+
- Call `jobService.jobFinished` for the finished geofencing jobs. ([#14786](https://github.com/expo/expo/pull/14786) by [@mdmitry01](https://github.com/mdmitry01))
|
|
36
|
+
- Check for null value of `mLocationClient` to prevent a crash ([#15023](https://github.com/expo/expo/pull/15023) by [@zakharchenkoAndrii](https://github.com/zakharchenkoAndrii))
|
|
37
|
+
|
|
38
|
+
### 💡 Others
|
|
39
|
+
|
|
40
|
+
- Extract nested `foregroundService` object from `LocationTaskOptions` type to the separate type `LocationTaskServiceOptions`. ([#14672](https://github.com/expo/expo/pull/14672) by [@Simek](https://github.com/Simek))
|
|
41
|
+
|
|
21
42
|
## 13.0.1 — 2021-10-01
|
|
22
43
|
|
|
23
44
|
_This version does not introduce any user-facing changes._
|
|
@@ -38,6 +59,7 @@ _This version does not introduce any user-facing changes._
|
|
|
38
59
|
|
|
39
60
|
- Fixed `Location.getCurrentPositionAsync` throwing `Location provider is unavailable.` error. ([#14281](https://github.com/expo/expo/pull/14281) by [@m1st4ke](https://github.com/m1st4ke))
|
|
40
61
|
- Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo))
|
|
62
|
+
- Update error message for `LocationUnavailableException` on Android. ([#14539](https://github.com/expo/expo/pull/14539) by [@kylerjensen](https://github.com/kylerjensen))
|
|
41
63
|
|
|
42
64
|
### 💡 Others
|
|
43
65
|
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-
|
|
|
13
13
|
|
|
14
14
|
# Installation in bare React Native projects
|
|
15
15
|
|
|
16
|
-
For bare React Native projects, you must ensure that you have [installed and configured the `
|
|
16
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
17
17
|
|
|
18
18
|
### Add the package to your npm dependencies
|
|
19
19
|
|
package/android/build.gradle
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
apply plugin: 'kotlin-android'
|
|
3
|
-
apply plugin: 'maven'
|
|
3
|
+
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '
|
|
6
|
+
version = '14.0.2'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
// Simple helper that allows the root project to override versions declared by this library.
|
|
@@ -20,27 +20,25 @@ buildscript {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
// Upload android library to maven with javadoc and android sources
|
|
24
|
-
configurations {
|
|
25
|
-
deployerJars
|
|
26
|
-
}
|
|
27
|
-
|
|
28
23
|
// Creating sources with comments
|
|
29
24
|
task androidSourcesJar(type: Jar) {
|
|
30
25
|
classifier = 'sources'
|
|
31
26
|
from android.sourceSets.main.java.srcDirs
|
|
32
27
|
}
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
afterEvaluate {
|
|
30
|
+
publishing {
|
|
31
|
+
publications {
|
|
32
|
+
release(MavenPublication) {
|
|
33
|
+
from components.release
|
|
34
|
+
// Add additional sourcesJar to artifacts
|
|
35
|
+
artifact(androidSourcesJar)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
repositories {
|
|
39
|
+
maven {
|
|
40
|
+
url = mavenLocal().url
|
|
41
|
+
}
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
}
|
|
@@ -57,7 +55,7 @@ android {
|
|
|
57
55
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
58
56
|
targetSdkVersion safeExtGet("targetSdkVersion", 30)
|
|
59
57
|
versionCode 29
|
|
60
|
-
versionName "
|
|
58
|
+
versionName "14.0.2"
|
|
61
59
|
}
|
|
62
60
|
lintOptions {
|
|
63
61
|
abortOnError false
|
|
@@ -96,6 +96,7 @@ public class LocationHelpers {
|
|
|
96
96
|
|
|
97
97
|
map.putString("city", address.getLocality());
|
|
98
98
|
map.putString("district", address.getSubLocality());
|
|
99
|
+
map.putString("streetNumber", address.getSubThoroughfare());
|
|
99
100
|
map.putString("street", address.getThoroughfare());
|
|
100
101
|
map.putString("region", address.getAdminArea());
|
|
101
102
|
map.putString("subregion", address.getSubAdminArea());
|
package/android/src/main/java/expo/modules/location/exceptions/LocationUnavailableException.java
CHANGED
|
@@ -5,7 +5,7 @@ import expo.modules.core.errors.CodedException;
|
|
|
5
5
|
|
|
6
6
|
public class LocationUnavailableException extends CodedException implements CodedThrowable {
|
|
7
7
|
public LocationUnavailableException() {
|
|
8
|
-
super("Location
|
|
8
|
+
super("Location is unavailable. Make sure that location services are enabled.");
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
@Override
|
package/android/src/main/java/expo/modules/location/taskConsumers/GeofencingTaskConsumer.java
CHANGED
|
@@ -26,6 +26,7 @@ import java.util.UUID;
|
|
|
26
26
|
import org.unimodules.interfaces.taskManager.TaskConsumer;
|
|
27
27
|
import org.unimodules.interfaces.taskManager.TaskManagerUtilsInterface;
|
|
28
28
|
import org.unimodules.interfaces.taskManager.TaskConsumerInterface;
|
|
29
|
+
import org.unimodules.interfaces.taskManager.TaskExecutionCallback;
|
|
29
30
|
import org.unimodules.interfaces.taskManager.TaskInterface;
|
|
30
31
|
import expo.modules.location.LocationHelpers;
|
|
31
32
|
import expo.modules.location.LocationModule;
|
|
@@ -135,8 +136,16 @@ public class GeofencingTaskConsumer extends TaskConsumer implements TaskConsumer
|
|
|
135
136
|
if (mTask == null) {
|
|
136
137
|
return false;
|
|
137
138
|
}
|
|
138
|
-
mTask.execute(bundle, null)
|
|
139
|
+
mTask.execute(bundle, null, new TaskExecutionCallback() {
|
|
140
|
+
@Override
|
|
141
|
+
public void onFinished(Map<String, Object> response) {
|
|
142
|
+
jobService.jobFinished(params, false);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
139
145
|
}
|
|
146
|
+
|
|
147
|
+
// Returning `true` indicates that the job is still running, but in async mode.
|
|
148
|
+
// In that case we're obligated to call `jobService.jobFinished` as soon as the async block finishes.
|
|
140
149
|
return true;
|
|
141
150
|
}
|
|
142
151
|
|
|
@@ -111,6 +111,10 @@ public class LocationTaskConsumer extends TaskConsumer implements TaskConsumerIn
|
|
|
111
111
|
maybeReportDeferredLocations();
|
|
112
112
|
} else {
|
|
113
113
|
try {
|
|
114
|
+
if(mLocationClient == null){
|
|
115
|
+
Log.w(TAG, "LocationClient is null.");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
114
118
|
mLocationClient.getLastLocation().addOnCompleteListener(new OnCompleteListener<Location>() {
|
|
115
119
|
@Override
|
|
116
120
|
public void onComplete(@NonNull Task<Location> task) {
|
|
@@ -2,10 +2,12 @@ import { Platform } from 'expo-modules-core';
|
|
|
2
2
|
import ExpoLocation from './ExpoLocation';
|
|
3
3
|
import { LocationAccuracy } from './Location.types';
|
|
4
4
|
import { LocationSubscriber } from './LocationSubscribers';
|
|
5
|
+
// @needsAudit
|
|
6
|
+
/**
|
|
7
|
+
* Polyfills `navigator.geolocation` for interop with the core React Native and Web API approach to geolocation.
|
|
8
|
+
*/
|
|
5
9
|
export function installWebGeolocationPolyfill() {
|
|
6
10
|
if (Platform.OS !== 'web') {
|
|
7
|
-
// Polyfill navigator.geolocation for interop with the core react-native and web API approach to
|
|
8
|
-
// geolocation
|
|
9
11
|
// @ts-ignore
|
|
10
12
|
window.navigator.geolocation = {
|
|
11
13
|
getCurrentPosition,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeolocationPolyfill.js","sourceRoot":"","sources":["../src/GeolocationPolyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAkB,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAS3D,MAAM,UAAU,6BAA6B;IAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,
|
|
1
|
+
{"version":3,"file":"GeolocationPolyfill.js","sourceRoot":"","sources":["../src/GeolocationPolyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAkB,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAS3D,cAAc;AACd;;GAEG;AACH,MAAM,UAAU,6BAA6B;IAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,aAAa;QACb,MAAM,CAAC,SAAS,CAAC,WAAW,GAAG;YAC7B,kBAAkB;YAClB,aAAa;YACb,UAAU;YAEV,kGAAkG;YAClG,uBAAuB;YACvB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;SACxB,CAAC;KACH;AACH,CAAC;AAED,SAAS,yBAAyB,CAAC,OAA2B;IAC5D,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,QAAQ;KACzF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,OAAmC,EACnC,QAAkC,GAAG,EAAE,GAAE,CAAC,EAC1C,UAA8B,EAAE;IAEhC,+BAA+B,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED,mGAAmG;AACnG,0DAA0D;AAC1D,KAAK,UAAU,+BAA+B,CAC5C,OAAmC,EACnC,KAA+B,EAC/B,OAA2B;IAE3B,IAAI;QACF,MAAM,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,uBAAuB,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9F,OAAO,CAAC,MAAM,CAAC,CAAC;KACjB;IAAC,OAAO,CAAC,EAAE;QACV,KAAK,CAAC,CAAC,CAAC,CAAC;KACV;AACH,CAAC;AAED,gDAAgD;AAChD,SAAS,aAAa,CACpB,OAAmC,EACnC,KAA+B,EAC/B,OAA2B;IAE3B,MAAM,OAAO,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE7D,YAAY,CAAC,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QAClE,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6CAA6C;AAC7C,SAAS,UAAU,CAAC,OAAe;IACjC,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\n\nimport ExpoLocation from './ExpoLocation';\nimport { LocationObject, LocationAccuracy, LocationOptions } from './Location.types';\nimport { LocationSubscriber } from './LocationSubscribers';\n\ntype GeolocationSuccessCallback = (data: LocationObject) => void;\ntype GeolocationErrorCallback = (error: any) => void;\n\ntype GeolocationOptions = {\n enableHighAccuracy?: boolean;\n};\n\n// @needsAudit\n/**\n * Polyfills `navigator.geolocation` for interop with the core React Native and Web API approach to geolocation.\n */\nexport function installWebGeolocationPolyfill(): void {\n if (Platform.OS !== 'web') {\n // @ts-ignore\n window.navigator.geolocation = {\n getCurrentPosition,\n watchPosition,\n clearWatch,\n\n // We don't polyfill stopObserving, this is an internal method that probably should not even exist\n // in react-native docs\n stopObserving: () => {},\n };\n }\n}\n\nfunction convertGeolocationOptions(options: GeolocationOptions): LocationOptions {\n return {\n accuracy: options.enableHighAccuracy ? LocationAccuracy.High : LocationAccuracy.Balanced,\n };\n}\n\nfunction getCurrentPosition(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback = () => {},\n options: GeolocationOptions = {}\n): void {\n _getCurrentPositionAsyncWrapper(success, error, options);\n}\n\n// This function exists to let us continue to return undefined from getCurrentPosition, while still\n// using async/await for the internal implementation of it\nasync function _getCurrentPositionAsyncWrapper(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback,\n options: GeolocationOptions\n): Promise<any> {\n try {\n await ExpoLocation.requestPermissionsAsync();\n const result = await ExpoLocation.getCurrentPositionAsync(convertGeolocationOptions(options));\n success(result);\n } catch (e) {\n error(e);\n }\n}\n\n// Polyfill: navigator.geolocation.watchPosition\nfunction watchPosition(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback,\n options: GeolocationOptions\n) {\n const watchId = LocationSubscriber.registerCallback(success);\n\n ExpoLocation.watchPositionImplAsync(watchId, options).catch((err) => {\n LocationSubscriber.unregisterCallback(watchId);\n error({ watchId, message: err.message, code: err.code });\n });\n\n return watchId;\n}\n\n// Polyfill: navigator.geolocation.clearWatch\nfunction clearWatch(watchId: number) {\n LocationSubscriber.unregisterCallback(watchId);\n}\n"]}
|
package/build/Location.d.ts
CHANGED
|
@@ -3,62 +3,110 @@ import { LocationAccuracy, LocationCallback, LocationGeocodedAddress, LocationGe
|
|
|
3
3
|
import { LocationEventEmitter } from './LocationEventEmitter';
|
|
4
4
|
import { setGoogleApiKey } from './LocationGoogleGeocoding';
|
|
5
5
|
import { _getCurrentWatchId } from './LocationSubscribers';
|
|
6
|
+
/**
|
|
7
|
+
* Check status of location providers.
|
|
8
|
+
* @return A promise which fulfills with an object of type [LocationProviderStatus](#locationproviderstatus).
|
|
9
|
+
*/
|
|
6
10
|
export declare function getProviderStatusAsync(): Promise<LocationProviderStatus>;
|
|
11
|
+
/**
|
|
12
|
+
* Asks the user to turn on high accuracy location mode which enables network provider that uses
|
|
13
|
+
* Google Play services to improve location accuracy and location-based services.
|
|
14
|
+
* @return A promise resolving as soon as the user accepts the dialog. Rejects if denied.
|
|
15
|
+
*/
|
|
7
16
|
export declare function enableNetworkProviderAsync(): Promise<void>;
|
|
8
17
|
/**
|
|
9
18
|
* Requests for one-time delivery of the user's current location.
|
|
10
19
|
* Depending on given `accuracy` option it may take some time to resolve,
|
|
11
20
|
* especially when you're inside a building.
|
|
21
|
+
* > __Note:__ Calling it causes the location manager to obtain a location fix which may take several
|
|
22
|
+
* > seconds. Consider using [`Location.getLastKnownPositionAsync`](#locationgetlastknownpositionasyncoptions)
|
|
23
|
+
* > if you expect to get a quick response and high accuracy is not required.
|
|
24
|
+
* @param options
|
|
25
|
+
* @return A promise which fulfills with an object of type [`LocationObject`](#locationobject).
|
|
12
26
|
*/
|
|
13
27
|
export declare function getCurrentPositionAsync(options?: LocationOptions): Promise<LocationObject>;
|
|
14
28
|
/**
|
|
15
|
-
* Gets the last known position of the device or `null` if it's not available
|
|
16
|
-
*
|
|
17
|
-
* It's considered to be faster than `getCurrentPositionAsync` as it doesn't request for the current
|
|
29
|
+
* Gets the last known position of the device or `null` if it's not available or doesn't match given
|
|
30
|
+
* requirements such as maximum age or required accuracy.
|
|
31
|
+
* It's considered to be faster than `getCurrentPositionAsync` as it doesn't request for the current
|
|
32
|
+
* location, but keep in mind the returned location may not be up-to-date.
|
|
33
|
+
* @param options
|
|
34
|
+
* @return A promise which fulfills with an object of type [LocationObject](#locationobject) or
|
|
35
|
+
* `null` if it's not available or doesn't match given requirements such as maximum age or required
|
|
36
|
+
* accuracy.
|
|
18
37
|
*/
|
|
19
38
|
export declare function getLastKnownPositionAsync(options?: LocationLastKnownOptions): Promise<LocationObject | null>;
|
|
20
39
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
40
|
+
* Subscribe to location updates from the device. Please note that updates will only occur while the
|
|
41
|
+
* application is in the foreground. To get location updates while in background you'll need to use
|
|
42
|
+
* [Location.startLocationUpdatesAsync](#locationstartlocationupdatesasynctaskname-options).
|
|
43
|
+
* @param options
|
|
44
|
+
* @param callback This function is called on each location update. It receives an object of type
|
|
45
|
+
* [`LocationObject`](#locationobject) as the first argument.
|
|
46
|
+
* @return A promise which fulfills with a [`LocationSubscription`](#locationsubscription) object.
|
|
23
47
|
*/
|
|
24
|
-
export declare function watchPositionAsync(options: LocationOptions, callback: LocationCallback): Promise<
|
|
25
|
-
remove(): void;
|
|
26
|
-
}>;
|
|
48
|
+
export declare function watchPositionAsync(options: LocationOptions, callback: LocationCallback): Promise<LocationSubscription>;
|
|
27
49
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
50
|
+
* Gets the current heading information from the device. To simplify, it calls `watchHeadingAsync`
|
|
51
|
+
* and waits for a couple of updates, and then returns the one that is accurate enough.
|
|
52
|
+
* @return A promise which fulfills with an object of type [LocationHeadingObject](#locationheadingobject).
|
|
31
53
|
*/
|
|
32
54
|
export declare function getHeadingAsync(): Promise<LocationHeadingObject>;
|
|
33
55
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
56
|
+
* Subscribe to compass updates from the device.
|
|
57
|
+
* @param callback This function is called on each compass update. It receives an object of type
|
|
58
|
+
* [LocationHeadingObject](#locationheadingobject) as the first argument.
|
|
59
|
+
* @return A promise which fulfills with a [`LocationSubscription`](#locationsubscription) object.
|
|
36
60
|
*/
|
|
37
61
|
export declare function watchHeadingAsync(callback: LocationHeadingCallback): Promise<LocationSubscription>;
|
|
38
62
|
/**
|
|
39
|
-
*
|
|
63
|
+
* Geocode an address string to latitude-longitude location.
|
|
64
|
+
* > **Note**: Geocoding is resource consuming and has to be used reasonably. Creating too many
|
|
65
|
+
* > requests at a time can result in an error, so they have to be managed properly.
|
|
66
|
+
* > It's also discouraged to use geocoding while the app is in the background and its results won't
|
|
67
|
+
* > be shown to the user immediately.
|
|
68
|
+
*
|
|
69
|
+
* > On Android, you must request a location permission (`Permissions.LOCATION`) from the user
|
|
70
|
+
* > before geocoding can be used.
|
|
71
|
+
* @param address A string representing address, eg. `"Baker Street London"`.
|
|
72
|
+
* @param options
|
|
73
|
+
* @return A promise which fulfills with an array (in most cases its size is 1) of [`LocationGeocodedLocation`](#locationgeocodedlocation) objects.
|
|
40
74
|
*/
|
|
41
75
|
export declare function geocodeAsync(address: string, options?: LocationGeocodingOptions): Promise<LocationGeocodedLocation[]>;
|
|
42
76
|
/**
|
|
43
|
-
*
|
|
77
|
+
* Reverse geocode a location to postal address.
|
|
78
|
+
* > **Note**: Geocoding is resource consuming and has to be used reasonably. Creating too many
|
|
79
|
+
* > requests at a time can result in an error, so they have to be managed properly.
|
|
80
|
+
* > It's also discouraged to use geocoding while the app is in the background and its results won't
|
|
81
|
+
* > be shown to the user immediately.
|
|
82
|
+
*
|
|
83
|
+
* > On Android, you must request a location permission (`Permissions.LOCATION`) from the user
|
|
84
|
+
* > before geocoding can be used.
|
|
85
|
+
* @param location An object representing a location.
|
|
86
|
+
* @param options
|
|
87
|
+
* @return A promise which fulfills with an array (in most cases its size is 1) of [`LocationGeocodedAddress`](#locationgeocodedaddress) objects.
|
|
44
88
|
*/
|
|
45
89
|
export declare function reverseGeocodeAsync(location: Pick<LocationGeocodedLocation, 'latitude' | 'longitude'>, options?: LocationGeocodingOptions): Promise<LocationGeocodedAddress[]>;
|
|
46
90
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @
|
|
91
|
+
* Checks user's permissions for accessing location.
|
|
92
|
+
* @return A promise that fulfills with an object of type [LocationPermissionResponse](#locationpermissionresponse).
|
|
93
|
+
* @deprecated __Deprecated.__ Use [`getForegroundPermissionsAsync`](#locationgetforegroundpermissionsasync) or [`getBackgroundPermissionsAsync`](#locationgetbackgroundpermissionsasync) instead.
|
|
49
94
|
*/
|
|
50
95
|
export declare function getPermissionsAsync(): Promise<LocationPermissionResponse>;
|
|
51
96
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
97
|
+
* Asks the user to grant permissions for location.
|
|
98
|
+
* @return A promise that fulfills with an object of type [LocationPermissionResponse](#locationpermissionresponse).
|
|
99
|
+
* @deprecated __Deprecated.__ Use [`requestForegroundPermissionsAsync`](#locationrequestforegroundpermissionsasync) or [`requestBackgroundPermissionsAsync`](#locationrequestbackgroundpermissionsasync) instead.
|
|
54
100
|
*/
|
|
55
101
|
export declare function requestPermissionsAsync(): Promise<LocationPermissionResponse>;
|
|
56
102
|
/**
|
|
57
|
-
*
|
|
103
|
+
* Checks user's permissions for accessing location while the app is in the foreground.
|
|
104
|
+
* @return A promise that fulfills with an object of type [PermissionResponse](#permissionresponse).
|
|
58
105
|
*/
|
|
59
106
|
export declare function getForegroundPermissionsAsync(): Promise<LocationPermissionResponse>;
|
|
60
107
|
/**
|
|
61
|
-
*
|
|
108
|
+
* Asks the user to grant permissions for location while the app is in the foreground.
|
|
109
|
+
* @return A promise that fulfills with an object of type [PermissionResponse](#permissionresponse).
|
|
62
110
|
*/
|
|
63
111
|
export declare function requestForegroundPermissionsAsync(): Promise<LocationPermissionResponse>;
|
|
64
112
|
/**
|
|
@@ -72,16 +120,24 @@ export declare function requestForegroundPermissionsAsync(): Promise<LocationPer
|
|
|
72
120
|
*/
|
|
73
121
|
export declare const useForegroundPermissions: (options?: PermissionHookOptions<object> | undefined) => [LocationPermissionResponse | null, () => Promise<LocationPermissionResponse>, () => Promise<LocationPermissionResponse>];
|
|
74
122
|
/**
|
|
75
|
-
*
|
|
123
|
+
* Checks user's permissions for accessing location while the app is in the background.
|
|
124
|
+
* @return A promise that fulfills with an object of type [PermissionResponse](#permissionresponse).
|
|
76
125
|
*/
|
|
77
126
|
export declare function getBackgroundPermissionsAsync(): Promise<PermissionResponse>;
|
|
78
127
|
/**
|
|
79
|
-
*
|
|
128
|
+
* Asks the user to grant permissions for location while the app is in the background.
|
|
129
|
+
* On __Android 11 or higher__: this method will open the system settings page - before that happens
|
|
130
|
+
* you should explain to the user why your application needs background location permission.
|
|
131
|
+
* For example, you can use `Modal` component from `react-native` to do that.
|
|
132
|
+
* > __Note__: Foreground permissions should be granted before asking for the background permissions
|
|
133
|
+
* (your app can't obtain background permission without foreground permission).
|
|
134
|
+
* @return A promise that fulfills with an object of type [PermissionResponse](#permissionresponse).
|
|
80
135
|
*/
|
|
81
136
|
export declare function requestBackgroundPermissionsAsync(): Promise<PermissionResponse>;
|
|
82
137
|
/**
|
|
83
138
|
* Check or request permissions for the foreground location.
|
|
84
|
-
* This uses both `requestBackgroundPermissionsAsync` and `getBackgroundPermissionsAsync` to
|
|
139
|
+
* This uses both `requestBackgroundPermissionsAsync` and `getBackgroundPermissionsAsync` to
|
|
140
|
+
* interact with the permissions.
|
|
85
141
|
*
|
|
86
142
|
* @example
|
|
87
143
|
* ```ts
|
|
@@ -90,21 +146,96 @@ export declare function requestBackgroundPermissionsAsync(): Promise<PermissionR
|
|
|
90
146
|
*/
|
|
91
147
|
export declare const useBackgroundPermissions: (options?: PermissionHookOptions<object> | undefined) => [PermissionResponse | null, () => Promise<PermissionResponse>, () => Promise<PermissionResponse>];
|
|
92
148
|
/**
|
|
93
|
-
*
|
|
149
|
+
* Checks whether location services are enabled by the user.
|
|
150
|
+
* @return A promise which fulfills to `true` if location services are enabled on the device,
|
|
151
|
+
* or `false` if not.
|
|
94
152
|
*/
|
|
95
153
|
export declare function hasServicesEnabledAsync(): Promise<boolean>;
|
|
96
154
|
export declare function isBackgroundLocationAvailableAsync(): Promise<boolean>;
|
|
155
|
+
/**
|
|
156
|
+
* Registers for receiving location updates that can also come when the app is in the background.
|
|
157
|
+
* @param taskName Name of the task receiving location updates.
|
|
158
|
+
* @param options An object of options passed to the location manager.
|
|
159
|
+
* @return A promise resolving once the task with location updates is registered.
|
|
160
|
+
*
|
|
161
|
+
* # Task parameters
|
|
162
|
+
*
|
|
163
|
+
* Background location task will be receiving following data:
|
|
164
|
+
* - `locations` - An array of the new locations.
|
|
165
|
+
*
|
|
166
|
+
* ```ts
|
|
167
|
+
* import * as TaskManager from 'expo-task-manager';
|
|
168
|
+
*
|
|
169
|
+
* TaskManager.defineTask(YOUR_TASK_NAME, ({ data: { locations }, error }) => {
|
|
170
|
+
* if (error) {
|
|
171
|
+
* // check `error.message` for more details.
|
|
172
|
+
* return;
|
|
173
|
+
* }
|
|
174
|
+
* console.log('Received new locations', locations);
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
97
178
|
export declare function startLocationUpdatesAsync(taskName: string, options?: LocationTaskOptions): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Stops geofencing for specified task.
|
|
181
|
+
* @param taskName Name of the background location task to stop.
|
|
182
|
+
* @return A promise resolving as soon as the task is unregistered.
|
|
183
|
+
*/
|
|
98
184
|
export declare function stopLocationUpdatesAsync(taskName: string): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* @param taskName Name of the location task to check.
|
|
187
|
+
* @return A promise which fulfills with boolean value indicating whether the location task is
|
|
188
|
+
* started or not.
|
|
189
|
+
*/
|
|
99
190
|
export declare function hasStartedLocationUpdatesAsync(taskName: string): Promise<boolean>;
|
|
191
|
+
/**
|
|
192
|
+
* Starts geofencing for given regions. When the new event comes, the task with specified name will
|
|
193
|
+
* be called with the region that the device enter to or exit from.
|
|
194
|
+
* If you want to add or remove regions from already running geofencing task, you can just call
|
|
195
|
+
* `startGeofencingAsync` again with the new array of regions.
|
|
196
|
+
* @param taskName Name of the task that will be called when the device enters or exits from specified regions.
|
|
197
|
+
* @param regions Array of region objects to be geofenced.
|
|
198
|
+
* @return A promise resolving as soon as the task is registered.
|
|
199
|
+
*
|
|
200
|
+
* # Task parameters
|
|
201
|
+
*
|
|
202
|
+
* Geofencing task will be receiving following data:
|
|
203
|
+
* - `eventType` - Indicates the reason for calling the task, which can be triggered by entering or exiting the region.
|
|
204
|
+
* See [GeofencingEventType](#geofencingeventtype).
|
|
205
|
+
* - `region` - Object containing details about updated region. See [LocationRegion](#locationregion) for more details.
|
|
206
|
+
*
|
|
207
|
+
* # Example
|
|
208
|
+
* ```ts
|
|
209
|
+
* import { GeofencingEventType } from 'expo-location';
|
|
210
|
+
* import * as TaskManager from 'expo-task-manager';
|
|
211
|
+
*
|
|
212
|
+
* TaskManager.defineTask(YOUR_TASK_NAME, ({ data: { eventType, region }, error }) => {
|
|
213
|
+
* if (error) {
|
|
214
|
+
* // check `error.message` for more details.
|
|
215
|
+
* return;
|
|
216
|
+
* }
|
|
217
|
+
* if (eventType === GeofencingEventType.Enter) {
|
|
218
|
+
* console.log("You've entered region:", region);
|
|
219
|
+
* } else if (eventType === GeofencingEventType.Exit) {
|
|
220
|
+
* console.log("You've left region:", region);
|
|
221
|
+
* }
|
|
222
|
+
* });
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
100
225
|
export declare function startGeofencingAsync(taskName: string, regions?: LocationRegion[]): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Stops geofencing for specified task. It unregisters the background task so the app will not be
|
|
228
|
+
* receiving any updates, especially in the background.
|
|
229
|
+
* @param taskName Name of the task to unregister.
|
|
230
|
+
* @return A promise resolving as soon as the task is unregistered.
|
|
231
|
+
*/
|
|
101
232
|
export declare function stopGeofencingAsync(taskName: string): Promise<void>;
|
|
102
|
-
export declare function hasStartedGeofencingAsync(taskName: string): Promise<boolean>;
|
|
103
233
|
/**
|
|
104
|
-
* @
|
|
105
|
-
*
|
|
234
|
+
* @param taskName Name of the geofencing task to check.
|
|
235
|
+
* @return A promise which fulfills with boolean value indicating whether the geofencing task is
|
|
236
|
+
* started or not.
|
|
106
237
|
*/
|
|
107
|
-
export declare function
|
|
238
|
+
export declare function hasStartedGeofencingAsync(taskName: string): Promise<boolean>;
|
|
108
239
|
export { LocationEventEmitter as EventEmitter, _getCurrentWatchId };
|
|
109
240
|
export { LocationAccuracy as Accuracy, LocationActivityType as ActivityType, LocationGeofencingEventType as GeofencingEventType, LocationGeofencingRegionState as GeofencingRegionState, PermissionStatus, PermissionHookOptions, setGoogleApiKey, };
|
|
110
241
|
export { installWebGeolocationPolyfill } from './GeolocationPolyfill';
|