expo-location 58.0.11 → 58.0.13
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 +19 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/location/next/LocationModuleNext.kt +2 -2
- package/android/src/main/java/expo/modules/location/next/LocationPermissions.kt +1 -1
- package/android/src/main/java/expo/modules/location/next/LocationRecords.kt +1 -1
- package/android/src/main/java/expo/modules/location/next/WatchPosition.kt +11 -2
- package/build/Location.types.d.ts +4 -1
- package/build/Location.types.js.map +1 -1
- package/build/next/Location.d.ts +1 -0
- package/build/next/Location.js +3 -0
- package/build/next/Location.js.map +1 -0
- package/build/next/index.d.ts +3 -0
- package/build/next/index.js +5 -0
- package/build/next/index.js.map +1 -0
- package/build/next/js/LocationProvider.d.ts +9 -0
- package/build/next/js/LocationProvider.js +20 -0
- package/build/next/js/LocationProvider.js.map +1 -0
- package/build/next/js/LocationUpdatesHandle.d.ts +15 -0
- package/build/next/js/LocationUpdatesHandle.js +39 -0
- package/build/next/js/LocationUpdatesHandle.js.map +1 -0
- package/build/next/js/Permissions.d.ts +7 -0
- package/build/next/js/Permissions.js +24 -0
- package/build/next/js/Permissions.js.map +1 -0
- package/build/next/js/PositionWatchHandle.d.ts +16 -0
- package/build/next/js/PositionWatchHandle.js +50 -0
- package/build/next/js/PositionWatchHandle.js.map +1 -0
- package/build/next/js/getPosition.d.ts +2 -0
- package/build/next/js/getPosition.js +6 -0
- package/build/next/js/getPosition.js.map +1 -0
- package/build/next/js/index.d.ts +6 -0
- package/build/next/js/index.js +8 -0
- package/build/next/js/index.js.map +1 -0
- package/build/next/js/locationServices.d.ts +3 -0
- package/build/next/js/locationServices.js +35 -0
- package/build/next/js/locationServices.js.map +1 -0
- package/build/next/native/NativeLocationModuleNext.d.ts +5 -0
- package/build/next/native/NativeLocationModuleNext.js +7 -0
- package/build/next/native/NativeLocationModuleNext.js.map +1 -0
- package/build/next/native/index.d.ts +5 -0
- package/build/next/native/index.js +3 -0
- package/build/next/native/index.js.map +1 -0
- package/build/next/native/types/NativeLocationModuleNextClass.types.d.ts +21 -0
- package/build/next/native/types/NativeLocationModuleNextClass.types.js +3 -0
- package/build/next/native/types/NativeLocationModuleNextClass.types.js.map +1 -0
- package/build/next/native/types/NativeLocationProviderClass.types.d.ts +8 -0
- package/build/next/native/types/NativeLocationProviderClass.types.js +3 -0
- package/build/next/native/types/NativeLocationProviderClass.types.js.map +1 -0
- package/build/next/native/types/NativeLocationUpdatesHandleClass.types.d.ts +8 -0
- package/build/next/native/types/NativeLocationUpdatesHandleClass.types.js +3 -0
- package/build/next/native/types/NativeLocationUpdatesHandleClass.types.js.map +1 -0
- package/build/next/native/types/NativePositionWatchHandleClass.types.d.ts +12 -0
- package/build/next/native/types/NativePositionWatchHandleClass.types.js +3 -0
- package/build/next/native/types/NativePositionWatchHandleClass.types.js.map +1 -0
- package/build/next/types/LocationProvider.types.d.ts +1 -0
- package/build/next/types/LocationProvider.types.js +3 -0
- package/build/next/types/LocationProvider.types.js.map +1 -0
- package/build/next/types/Permissions.types.d.ts +22 -0
- package/build/next/types/Permissions.types.js +19 -0
- package/build/next/types/Permissions.types.js.map +1 -0
- package/build/next/types/Position.types.d.ts +55 -0
- package/build/next/types/Position.types.js +11 -0
- package/build/next/types/Position.types.js.map +1 -0
- package/build/next/types/index.d.ts +3 -0
- package/build/next/types/index.js +5 -0
- package/build/next/types/index.js.map +1 -0
- package/expo-module.config.json +1 -1
- package/ios/EXLocation.m +1 -0
- package/ios/ExpoLocation.podspec +9 -0
- package/ios/LocationUtils.swift +3 -1
- package/ios/next/LocationModuleNext.swift +110 -0
- package/ios/next/LocationNextExceptions.swift +118 -0
- package/ios/next/LocationUpdatesHandle/LocationUpdatesHandle.swift +52 -0
- package/ios/next/LocationUpdatesHandle/LocationUpdatesTaskConsumer.swift +40 -0
- package/ios/next/LocationUpdatesHandle/LocationUpdatesTaskOptions.swift +19 -0
- package/ios/next/LocationUpdatesHandle/SignificantLocationChangeMonitor.swift +20 -0
- package/ios/next/Permissions/BackgroundPermissionsRequester.swift +34 -0
- package/ios/next/Permissions/CLLocationManager+MainThread.swift +10 -0
- package/ios/next/Permissions/ForegroundPermissionsRequester.swift +38 -0
- package/ios/next/Permissions/LocationAccessGuard.swift +21 -0
- package/ios/next/Permissions/LocationAccuracyAuthorization.swift +9 -0
- package/ios/next/Permissions/LocationAccuracyOption.swift +6 -0
- package/ios/next/Permissions/LocationAuthorizationScope.swift +16 -0
- package/ios/next/Permissions/LocationManagerAlwaysAuthorizationRequest.swift +109 -0
- package/ios/next/Permissions/LocationPermissionKind.swift +26 -0
- package/ios/next/Permissions/LocationPermissionResponse.swift +51 -0
- package/ios/next/Permissions/LocationPermissionsDelegate.swift +85 -0
- package/ios/next/Permissions/LocationPermissionsRequester.swift +96 -0
- package/ios/next/Permissions/LocationPlistKeys.swift +10 -0
- package/ios/next/Permissions/PermissionsRequestOptions.swift +5 -0
- package/ios/next/Permissions/TemporaryFullAccuracyPlistKeys.swift +13 -0
- package/ios/next/Permissions/TemporaryFullAccuracyRequester.swift +28 -0
- package/ios/next/Position/Coordinates.swift +7 -0
- package/ios/next/Position/GetPositionOptions.swift +7 -0
- package/ios/next/Position/LocationUpdateDiagnostics.swift +41 -0
- package/ios/next/Position/Position.swift +43 -0
- package/ios/next/Position/PositionRequester.swift +55 -0
- package/ios/next/Position/PositionUpdatesCompatibilitySource.swift +43 -0
- package/ios/next/Position/PositionUpdatesLiveSource.swift +46 -0
- package/ios/next/Position/PositionUpdatesSource.swift +40 -0
- package/ios/next/Position/PositionUpdatesSubscription.swift +85 -0
- package/ios/next/PositionWatcher/PositionWatchStatus.swift +9 -0
- package/ios/next/PositionWatcher/PositionWatcher.swift +143 -0
- package/ios/next/Profile.swift +60 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.11/expo.modules.location-58.0.11-sources.jar → 58.0.13/expo.modules.location-58.0.13-sources.jar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.11/expo.modules.location-58.0.11.module → 58.0.13/expo.modules.location-58.0.13.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.11/expo.modules.location-58.0.11.pom → 58.0.13/expo.modules.location-58.0.13.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.sha512 +1 -0
- package/package.json +33 -4
- package/plugin/build/withLocation.d.ts +18 -0
- package/plugin/build/withLocation.js +28 -1
- package/plugin/build/withLocation.js.map +1 -1
- package/plugin/src/withLocation.ts +52 -0
- package/src/Location.types.ts +4 -1
- package/src/next/Location.ts +12 -0
- package/src/next/index.ts +28 -0
- package/src/next/js/LocationProvider.ts +28 -0
- package/src/next/js/LocationUpdatesHandle.ts +60 -0
- package/src/next/js/Permissions.ts +34 -0
- package/src/next/js/PositionWatchHandle.ts +75 -0
- package/src/next/js/getPosition.ts +6 -0
- package/src/next/js/index.ts +21 -0
- package/src/next/js/locationServices.ts +38 -0
- package/src/next/native/NativeLocationModuleNext.ts +9 -0
- package/src/next/native/index.ts +10 -0
- package/src/next/native/types/NativeLocationModuleNextClass.types.ts +34 -0
- package/src/next/native/types/NativeLocationProviderClass.types.ts +12 -0
- package/src/next/native/types/NativeLocationUpdatesHandleClass.types.ts +9 -0
- package/src/next/native/types/NativePositionWatchHandleClass.types.ts +14 -0
- package/src/next/types/LocationProvider.types.ts +1 -0
- package/src/next/types/Permissions.types.ts +27 -0
- package/src/next/types/Position.types.ts +58 -0
- package/src/next/types/index.ts +3 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.11/expo.modules.location-58.0.11.pom.sha512 +0 -1
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
ANDROID_RES_PATH: null,
|
|
7
7
|
FOREGROUND_SERVICE_ICON: null,
|
|
8
8
|
FOREGROUND_SERVICE_ICON_RESOURCE: null,
|
|
9
|
+
FULL_ACCURACY_PURPOSE_KEY: null,
|
|
9
10
|
META_DATA_FOREGROUND_SERVICE_ICON: null,
|
|
10
11
|
default: null,
|
|
11
12
|
dpiValues: null,
|
|
@@ -28,6 +29,9 @@ _export(exports, {
|
|
|
28
29
|
get FOREGROUND_SERVICE_ICON_RESOURCE () {
|
|
29
30
|
return FOREGROUND_SERVICE_ICON_RESOURCE;
|
|
30
31
|
},
|
|
32
|
+
get FULL_ACCURACY_PURPOSE_KEY () {
|
|
33
|
+
return FULL_ACCURACY_PURPOSE_KEY;
|
|
34
|
+
},
|
|
31
35
|
get META_DATA_FOREGROUND_SERVICE_ICON () {
|
|
32
36
|
return META_DATA_FOREGROUND_SERVICE_ICON;
|
|
33
37
|
},
|
|
@@ -75,6 +79,8 @@ function _path() {
|
|
|
75
79
|
const pkg = require('../../package.json');
|
|
76
80
|
const LOCATION_USAGE = 'Allow $(PRODUCT_NAME) to access your location';
|
|
77
81
|
const MOTION_USAGE = 'Allow $(PRODUCT_NAME) to detect your current motion activity';
|
|
82
|
+
const FULL_ACCURACY_USAGE = 'Allow $(PRODUCT_NAME) to access your precise location';
|
|
83
|
+
const FULL_ACCURACY_PURPOSE_KEY = 'ExpoLocationFullAccuracy';
|
|
78
84
|
const ANDROID_RES_PATH = 'android/app/src/main/res/';
|
|
79
85
|
const dpiValues = {
|
|
80
86
|
mdpi: {
|
|
@@ -181,7 +187,22 @@ function removeForegroundServiceIconImageFiles(projectRoot) {
|
|
|
181
187
|
}
|
|
182
188
|
});
|
|
183
189
|
}
|
|
184
|
-
const
|
|
190
|
+
const withTemporaryFullAccuracy = (config, message)=>{
|
|
191
|
+
return (0, _configplugins().withInfoPlist)(config, (config)=>{
|
|
192
|
+
config.modResults.NSLocationTemporaryUsageDescriptionDictionary = {
|
|
193
|
+
...config.modResults.NSLocationTemporaryUsageDescriptionDictionary,
|
|
194
|
+
[FULL_ACCURACY_PURPOSE_KEY]: message
|
|
195
|
+
};
|
|
196
|
+
return config;
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
const withReducedAccuracyDefault = (config)=>{
|
|
200
|
+
return (0, _configplugins().withInfoPlist)(config, (config)=>{
|
|
201
|
+
config.modResults.NSLocationDefaultAccuracyReduced = true;
|
|
202
|
+
return config;
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
const withLocation = (config, { locationAlwaysAndWhenInUsePermission, locationAlwaysPermission, locationWhenInUsePermission, motionUsagePermission, locationFullAccuracyPermission, isIosReducedAccuracyByDefault, isIosBackgroundLocationEnabled, isAndroidBackgroundLocationEnabled, isAndroidForegroundServiceEnabled, isAndroidMotionActivityEnabled, androidForegroundServiceIcon } = {})=>{
|
|
185
206
|
if (isIosBackgroundLocationEnabled) {
|
|
186
207
|
config = withBackgroundLocation(config);
|
|
187
208
|
}
|
|
@@ -193,6 +214,12 @@ const withLocation = (config, { locationAlwaysAndWhenInUsePermission, locationAl
|
|
|
193
214
|
}
|
|
194
215
|
return config;
|
|
195
216
|
});
|
|
217
|
+
if (locationFullAccuracyPermission !== false) {
|
|
218
|
+
config = withTemporaryFullAccuracy(config, locationFullAccuracyPermission || FULL_ACCURACY_USAGE);
|
|
219
|
+
}
|
|
220
|
+
if (isIosReducedAccuracyByDefault) {
|
|
221
|
+
config = withReducedAccuracyDefault(config);
|
|
222
|
+
}
|
|
196
223
|
config = withForegroundServiceIcon(config, {
|
|
197
224
|
icon: androidForegroundServiceIcon ?? null
|
|
198
225
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["withLocation.ts"],"sourcesContent":[null],"names":["ANDROID_RES_PATH","FOREGROUND_SERVICE_ICON","FOREGROUND_SERVICE_ICON_RESOURCE","META_DATA_FOREGROUND_SERVICE_ICON","dpiValues","setForegroundServiceIconAsync","withForegroundServiceIcon","pkg","require","LOCATION_USAGE","MOTION_USAGE","mdpi","folderName","scale","hdpi","xhdpi","xxhdpi","xxxhdpi","addMetaDataItemToMainApplication","getMainApplicationOrThrow","removeMetaDataItemFromMainApplication","AndroidConfig","Manifest","BASELINE_PIXEL_SIZE","ERROR_MSG_PREFIX","withBackgroundLocation","config","withInfoPlist","Array","isArray","modResults","UIBackgroundModes","includes","push","icon","configWithIconAssets","withDangerousMod","modRequest","projectRoot","withAndroidManifest","manifest","mainApplication","writeForegroundServiceIconImageFilesAsync","removeForegroundServiceIconImageFiles","Promise","all","Object","values","map","drawableFolderName","replace","dpiFolderPath","resolve","existsSync","mkdirSync","recursive","iconSizePx","resizedIcon","generateImageAsync","cacheType","src","width","height","resizeMode","backgroundColor","source","writeFileSync","e","Error","forEach","iconFile","unlinkSync","withLocation","locationAlwaysAndWhenInUsePermission","locationAlwaysPermission","locationWhenInUsePermission","motionUsagePermission","isIosBackgroundLocationEnabled","isAndroidBackgroundLocationEnabled","isAndroidForegroundServiceEnabled","isAndroidMotionActivityEnabled","androidForegroundServiceIcon","withPodfileProperties","IOSConfig","Permissions","createPermissionsPlugin","NSLocationAlwaysAndWhenInUseUsageDescription","NSLocationAlwaysUsageDescription","NSLocationWhenInUseUsageDescription","NSMotionUsageDescription","enableAndroidForegroundService","withPermissions","filter","Boolean","createRunOncePlugin","name","version"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["withLocation.ts"],"sourcesContent":[null],"names":["ANDROID_RES_PATH","FOREGROUND_SERVICE_ICON","FOREGROUND_SERVICE_ICON_RESOURCE","FULL_ACCURACY_PURPOSE_KEY","META_DATA_FOREGROUND_SERVICE_ICON","dpiValues","setForegroundServiceIconAsync","withForegroundServiceIcon","pkg","require","LOCATION_USAGE","MOTION_USAGE","FULL_ACCURACY_USAGE","mdpi","folderName","scale","hdpi","xhdpi","xxhdpi","xxxhdpi","addMetaDataItemToMainApplication","getMainApplicationOrThrow","removeMetaDataItemFromMainApplication","AndroidConfig","Manifest","BASELINE_PIXEL_SIZE","ERROR_MSG_PREFIX","withBackgroundLocation","config","withInfoPlist","Array","isArray","modResults","UIBackgroundModes","includes","push","icon","configWithIconAssets","withDangerousMod","modRequest","projectRoot","withAndroidManifest","manifest","mainApplication","writeForegroundServiceIconImageFilesAsync","removeForegroundServiceIconImageFiles","Promise","all","Object","values","map","drawableFolderName","replace","dpiFolderPath","resolve","existsSync","mkdirSync","recursive","iconSizePx","resizedIcon","generateImageAsync","cacheType","src","width","height","resizeMode","backgroundColor","source","writeFileSync","e","Error","forEach","iconFile","unlinkSync","withTemporaryFullAccuracy","message","NSLocationTemporaryUsageDescriptionDictionary","withReducedAccuracyDefault","NSLocationDefaultAccuracyReduced","withLocation","locationAlwaysAndWhenInUsePermission","locationAlwaysPermission","locationWhenInUsePermission","motionUsagePermission","locationFullAccuracyPermission","isIosReducedAccuracyByDefault","isIosBackgroundLocationEnabled","isAndroidBackgroundLocationEnabled","isAndroidForegroundServiceEnabled","isAndroidMotionActivityEnabled","androidForegroundServiceIcon","withPodfileProperties","IOSConfig","Permissions","createPermissionsPlugin","NSLocationAlwaysAndWhenInUseUsageDescription","NSLocationAlwaysUsageDescription","NSLocationWhenInUseUsageDescription","NSMotionUsageDescription","enableAndroidForegroundService","withPermissions","filter","Boolean","createRunOncePlugin","name","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;QAwBaA;eAAAA;;QAgBAC;eAAAA;;QACAC;eAAAA;;QAtBAC;eAAAA;;QAuBAC;eAAAA;;QAuRb;eAAA;;QAxSaC;eAAAA;;QAoESC;eAAAA;;QArCTC;eAAAA;;;;yBAxDsB;;;;;;;yBAU5B;;;;;;;yBAC0D;;;;;;;yBACzC;;;;;;AAExB,MAAMC,MAAMC,QAAQ;AACpB,MAAMC,iBAAiB;AACvB,MAAMC,eAAe;AACrB,MAAMC,sBAAsB;AAErB,MAAMT,4BAA4B;AAKlC,MAAMH,mBAAmB;AACzB,MAAMK,YAAoB;IAC/BQ,MAAM;QAAEC,YAAY;QAAeC,OAAO;IAAE;IAC5CC,MAAM;QAAEF,YAAY;QAAeC,OAAO;IAAI;IAC9CE,OAAO;QAAEH,YAAY;QAAgBC,OAAO;IAAE;IAC9CG,QAAQ;QAAEJ,YAAY;QAAiBC,OAAO;IAAE;IAChDI,SAAS;QAAEL,YAAY;QAAkBC,OAAO;IAAE;AACpD;AACA,MAAM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,gFAAgF;IAChF,qEAAqE;IACrE,MAAMgB,iCACJ,OAAOX,sCAAsC,cACzCD,qCACAC;IAEN,OAAOjE,8BAAa,CAACsE,WAAW,CAACO,eAAe,CAC9CxE,QACA;QACE,0EAA0E;QAC1E,mEAAmE;QACnE;QACA;QACA,oFAAoF;QACpF2D,sCAAsC;QACtCY,kCAAkC;QAClCA,kCAAkC;QAClCV,kCAAkC;QAClCA,kCAAkC;KACnC,CAACY,MAAM,CAACC;AAEb;MAEA,WAAeC,IAAAA,oCAAmB,EAACxB,cAAcvE,IAAIgG,IAAI,EAAEhG,IAAIiG,OAAO"}
|
|
@@ -15,6 +15,9 @@ import { resolve } from 'path';
|
|
|
15
15
|
const pkg = require('../../package.json');
|
|
16
16
|
const LOCATION_USAGE = 'Allow $(PRODUCT_NAME) to access your location';
|
|
17
17
|
const MOTION_USAGE = 'Allow $(PRODUCT_NAME) to detect your current motion activity';
|
|
18
|
+
const FULL_ACCURACY_USAGE = 'Allow $(PRODUCT_NAME) to access your precise location';
|
|
19
|
+
|
|
20
|
+
export const FULL_ACCURACY_PURPOSE_KEY = 'ExpoLocationFullAccuracy';
|
|
18
21
|
|
|
19
22
|
type DPIString = 'mdpi' | 'hdpi' | 'xhdpi' | 'xxhdpi' | 'xxxhdpi';
|
|
20
23
|
type dpiMap = Record<DPIString, { folderName: string; scale: number }>;
|
|
@@ -140,6 +143,25 @@ function removeForegroundServiceIconImageFiles(projectRoot: string) {
|
|
|
140
143
|
});
|
|
141
144
|
}
|
|
142
145
|
|
|
146
|
+
const withTemporaryFullAccuracy: ConfigPlugin<string> = (config, message) => {
|
|
147
|
+
return withInfoPlist(config, (config) => {
|
|
148
|
+
config.modResults.NSLocationTemporaryUsageDescriptionDictionary = {
|
|
149
|
+
...(config.modResults.NSLocationTemporaryUsageDescriptionDictionary as
|
|
150
|
+
| Record<string, string>
|
|
151
|
+
| undefined),
|
|
152
|
+
[FULL_ACCURACY_PURPOSE_KEY]: message,
|
|
153
|
+
};
|
|
154
|
+
return config;
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const withReducedAccuracyDefault: ConfigPlugin = (config) => {
|
|
159
|
+
return withInfoPlist(config, (config) => {
|
|
160
|
+
config.modResults.NSLocationDefaultAccuracyReduced = true;
|
|
161
|
+
return config;
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
143
165
|
export type Props = {
|
|
144
166
|
/**
|
|
145
167
|
* A string to set the `NSLocationAlwaysAndWhenInUseUsageDescription` permission message.
|
|
@@ -169,6 +191,23 @@ export type Props = {
|
|
|
169
191
|
* @platform ios
|
|
170
192
|
*/
|
|
171
193
|
motionUsagePermission?: string | false;
|
|
194
|
+
/**
|
|
195
|
+
* A string to set the message the system shows when a permission request from
|
|
196
|
+
* `expo-location/next` asks to raise a reduced accuracy authorization to full accuracy. It is written under the
|
|
197
|
+
* `ExpoLocationFullAccuracy` key of `NSLocationTemporaryUsageDescriptionDictionary`.
|
|
198
|
+
* Pass `false` to omit the key, which skips the raise.
|
|
199
|
+
* @default "Allow $(PRODUCT_NAME) to access your precise location"
|
|
200
|
+
* @platform ios
|
|
201
|
+
*/
|
|
202
|
+
locationFullAccuracyPermission?: string | false;
|
|
203
|
+
/**
|
|
204
|
+
* Whether the permission prompt offers reduced accuracy by default, by setting
|
|
205
|
+
* `NSLocationDefaultAccuracyReduced` in `Info.plist`. The app can still ask for full accuracy
|
|
206
|
+
* for a session with `accuracy: 'full'` in a permission request from `expo-location/next`.
|
|
207
|
+
* @default false
|
|
208
|
+
* @platform ios
|
|
209
|
+
*/
|
|
210
|
+
isIosReducedAccuracyByDefault?: boolean;
|
|
172
211
|
/**
|
|
173
212
|
* Whether to enable location in `UIBackgroundModes`.
|
|
174
213
|
* @default false
|
|
@@ -208,6 +247,8 @@ const withLocation: ConfigPlugin<Props | void> = (
|
|
|
208
247
|
locationAlwaysPermission,
|
|
209
248
|
locationWhenInUsePermission,
|
|
210
249
|
motionUsagePermission,
|
|
250
|
+
locationFullAccuracyPermission,
|
|
251
|
+
isIosReducedAccuracyByDefault,
|
|
211
252
|
isIosBackgroundLocationEnabled,
|
|
212
253
|
isAndroidBackgroundLocationEnabled,
|
|
213
254
|
isAndroidForegroundServiceEnabled,
|
|
@@ -228,6 +269,17 @@ const withLocation: ConfigPlugin<Props | void> = (
|
|
|
228
269
|
return config;
|
|
229
270
|
});
|
|
230
271
|
|
|
272
|
+
if (locationFullAccuracyPermission !== false) {
|
|
273
|
+
config = withTemporaryFullAccuracy(
|
|
274
|
+
config,
|
|
275
|
+
locationFullAccuracyPermission || FULL_ACCURACY_USAGE
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (isIosReducedAccuracyByDefault) {
|
|
280
|
+
config = withReducedAccuracyDefault(config);
|
|
281
|
+
}
|
|
282
|
+
|
|
231
283
|
config = withForegroundServiceIcon(config, { icon: androidForegroundServiceIcon ?? null });
|
|
232
284
|
|
|
233
285
|
IOSConfig.Permissions.createPermissionsPlugin({
|
package/src/Location.types.ts
CHANGED
|
@@ -265,8 +265,11 @@ export type LocationObject = {
|
|
|
265
265
|
*/
|
|
266
266
|
timestamp: number;
|
|
267
267
|
/**
|
|
268
|
-
* Whether the location coordinates is mocked or not.
|
|
268
|
+
* Whether the location coordinates is mocked or not. On Android, this is `true` when the location
|
|
269
|
+
* comes from a mock provider. On iOS, it is `true` when the location is simulated by software
|
|
270
|
+
* (for example, by Xcode or a location-spoofing tool).
|
|
269
271
|
* @platform android
|
|
272
|
+
* @platform ios
|
|
270
273
|
*/
|
|
271
274
|
mocked?: boolean;
|
|
272
275
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export {
|
|
2
|
+
getPosition,
|
|
3
|
+
watchPosition,
|
|
4
|
+
hasLocationServicesEnabled,
|
|
5
|
+
enableLocationServices,
|
|
6
|
+
getForegroundPermissions,
|
|
7
|
+
requestForegroundPermissions,
|
|
8
|
+
getBackgroundPermissions,
|
|
9
|
+
requestBackgroundPermissions,
|
|
10
|
+
setLocationProvider,
|
|
11
|
+
getSelectedLocationProviderName,
|
|
12
|
+
} from './js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * as Location from './Location';
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
useForegroundLocationPermissions,
|
|
5
|
+
useBackgroundLocationPermissions,
|
|
6
|
+
useLocationServices,
|
|
7
|
+
PositionWatchHandle,
|
|
8
|
+
LocationProvider,
|
|
9
|
+
LocationUpdatesHandle,
|
|
10
|
+
defineLocationTask,
|
|
11
|
+
} from './js';
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
LocationProfile,
|
|
15
|
+
LocationAccuracy,
|
|
16
|
+
LocationScope,
|
|
17
|
+
RequestPermissionsAccuracyOption,
|
|
18
|
+
type Coordinates,
|
|
19
|
+
type Position,
|
|
20
|
+
type PositionUpdate,
|
|
21
|
+
type PositionWatchError,
|
|
22
|
+
type PositionWatchStatus,
|
|
23
|
+
type WatchPositionParams,
|
|
24
|
+
type GetPositionOptions,
|
|
25
|
+
type LocationPermissionResponse,
|
|
26
|
+
type RequestPermissionsOptions,
|
|
27
|
+
type LocationProviderRefType,
|
|
28
|
+
} from './types';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SharedRef } from 'expo';
|
|
2
|
+
|
|
3
|
+
import { NativeLocationModuleNext, NativeLocationProvider } from '../native';
|
|
4
|
+
import type { LocationProviderRefType } from '../types';
|
|
5
|
+
|
|
6
|
+
export class LocationProvider {
|
|
7
|
+
static Gms(): SharedRef<LocationProviderRefType> {
|
|
8
|
+
return NativeLocationProvider.Gms();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static Android(): SharedRef<LocationProviderRefType> {
|
|
12
|
+
return NativeLocationProvider.Android();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static Fallback(
|
|
16
|
+
providers: SharedRef<LocationProviderRefType>[]
|
|
17
|
+
): SharedRef<LocationProviderRefType> {
|
|
18
|
+
return NativeLocationProvider.Fallback(providers);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setLocationProvider(provider: SharedRef<LocationProviderRefType>): void {
|
|
23
|
+
NativeLocationModuleNext.setLocationProvider(provider);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getSelectedLocationProviderName(): string {
|
|
27
|
+
return NativeLocationModuleNext.getSelectedLocationProviderName();
|
|
28
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { TaskManagerError } from 'expo-task-manager';
|
|
2
|
+
|
|
3
|
+
import { NativeLocationUpdatesHandle } from '../native';
|
|
4
|
+
import type { NativeLocationUpdatesHandleClass } from '../native';
|
|
5
|
+
import type { LocationProfile, Position } from '../types';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_LOCATION_TASK_NAME = 'expo-location-background-location';
|
|
8
|
+
|
|
9
|
+
export class LocationUpdatesHandle {
|
|
10
|
+
private readonly nativeHandle: NativeLocationUpdatesHandleClass;
|
|
11
|
+
|
|
12
|
+
constructor(taskName: string = DEFAULT_LOCATION_TASK_NAME) {
|
|
13
|
+
this.nativeHandle = new NativeLocationUpdatesHandle(taskName);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
withProfile(profile: LocationProfile): this {
|
|
17
|
+
this.nativeHandle.withProfile(profile);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
start(): Promise<void> {
|
|
22
|
+
return this.nativeHandle.start();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
stop(): Promise<void> {
|
|
26
|
+
return this.nativeHandle.stop();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
hasStarted(): Promise<boolean> {
|
|
30
|
+
return this.nativeHandle.hasStarted();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function defineLocationTask({
|
|
35
|
+
taskName = DEFAULT_LOCATION_TASK_NAME,
|
|
36
|
+
onPosition,
|
|
37
|
+
onError,
|
|
38
|
+
}: {
|
|
39
|
+
taskName?: string;
|
|
40
|
+
onPosition: (position: Position) => void;
|
|
41
|
+
onError?: (error: TaskManagerError) => void;
|
|
42
|
+
}): void {
|
|
43
|
+
requireTaskManager().defineTask<Position>(taskName, async ({ data, error }) => {
|
|
44
|
+
if (error) {
|
|
45
|
+
onError?.(error);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
onPosition(data);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function requireTaskManager(): typeof import('expo-task-manager') {
|
|
53
|
+
try {
|
|
54
|
+
return require('expo-task-manager');
|
|
55
|
+
} catch {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"defineLocationTask couldn't define the background location task because the 'expo-task-manager' package isn't installed. Background location updates are delivered through it. Install it with `npx expo install expo-task-manager` and rebuild the app."
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createPermissionHook } from 'expo-modules-core';
|
|
2
|
+
|
|
3
|
+
import { NativeLocationModuleNext } from '../native';
|
|
4
|
+
import type { LocationPermissionResponse, RequestPermissionsOptions } from '../types';
|
|
5
|
+
|
|
6
|
+
export async function getForegroundPermissions(): Promise<LocationPermissionResponse> {
|
|
7
|
+
return NativeLocationModuleNext.getForegroundPermissions();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function requestForegroundPermissions(
|
|
11
|
+
options?: RequestPermissionsOptions
|
|
12
|
+
): Promise<LocationPermissionResponse> {
|
|
13
|
+
return NativeLocationModuleNext.requestForegroundPermissions(options);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function getBackgroundPermissions(): Promise<LocationPermissionResponse> {
|
|
17
|
+
return NativeLocationModuleNext.getBackgroundPermissions();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function requestBackgroundPermissions(
|
|
21
|
+
options?: RequestPermissionsOptions
|
|
22
|
+
): Promise<LocationPermissionResponse> {
|
|
23
|
+
return NativeLocationModuleNext.requestBackgroundPermissions(options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const useForegroundLocationPermissions = createPermissionHook({
|
|
27
|
+
getMethod: getForegroundPermissions,
|
|
28
|
+
requestMethod: requestForegroundPermissions,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const useBackgroundLocationPermissions = createPermissionHook({
|
|
32
|
+
getMethod: getBackgroundPermissions,
|
|
33
|
+
requestMethod: requestBackgroundPermissions,
|
|
34
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { EventSubscription } from 'expo';
|
|
2
|
+
|
|
3
|
+
import { NativeLocationModuleNext } from '../native';
|
|
4
|
+
import type { NativePositionWatchHandleClass } from '../native';
|
|
5
|
+
import { LocationProfile } from '../types';
|
|
6
|
+
import type {
|
|
7
|
+
Position,
|
|
8
|
+
PositionWatchError,
|
|
9
|
+
PositionWatchStatus,
|
|
10
|
+
WatchPositionParams,
|
|
11
|
+
} from '../types';
|
|
12
|
+
|
|
13
|
+
export class PositionWatchHandle {
|
|
14
|
+
private readonly nativeHandle: NativePositionWatchHandleClass;
|
|
15
|
+
|
|
16
|
+
constructor(profile: LocationProfile = LocationProfile.DEFAULT) {
|
|
17
|
+
this.nativeHandle = NativeLocationModuleNext.watchPosition(profile);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
pause(): void {
|
|
21
|
+
this.nativeHandle.pause();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
resume(): boolean {
|
|
25
|
+
return this.nativeHandle.resume();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
withProfile(profile: LocationProfile): this {
|
|
29
|
+
this.nativeHandle.withProfile(profile);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
withInterval(intervalSeconds: number): this {
|
|
34
|
+
this.nativeHandle.withInterval(intervalSeconds);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
restart(): boolean {
|
|
39
|
+
return this.nativeHandle.restart();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
status(): PositionWatchStatus {
|
|
43
|
+
return this.nativeHandle.status();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
dispose(): void {
|
|
47
|
+
this.nativeHandle.removeAllListeners('positionChanged');
|
|
48
|
+
this.nativeHandle.release();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
addListener(
|
|
52
|
+
onPosition: (position: Position) => void,
|
|
53
|
+
onError?: (error: PositionWatchError) => void
|
|
54
|
+
): EventSubscription {
|
|
55
|
+
return this.nativeHandle.addListener('positionChanged', ({ data, error }) => {
|
|
56
|
+
if (error != null) {
|
|
57
|
+
onError?.(error);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (data != null) {
|
|
61
|
+
onPosition(data);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function watchPosition({
|
|
68
|
+
profile = LocationProfile.DEFAULT,
|
|
69
|
+
onPosition,
|
|
70
|
+
onError,
|
|
71
|
+
}: WatchPositionParams): PositionWatchHandle {
|
|
72
|
+
const handle = new PositionWatchHandle(profile);
|
|
73
|
+
handle.addListener(onPosition, onError);
|
|
74
|
+
return handle;
|
|
75
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NativeLocationModuleNext } from '../native';
|
|
2
|
+
import type { GetPositionOptions, Position } from '../types';
|
|
3
|
+
|
|
4
|
+
export async function getPosition(options?: GetPositionOptions): Promise<Position | null> {
|
|
5
|
+
return NativeLocationModuleNext.getPosition(options);
|
|
6
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { getPosition } from './getPosition';
|
|
2
|
+
export {
|
|
3
|
+
hasLocationServicesEnabled,
|
|
4
|
+
enableLocationServices,
|
|
5
|
+
useLocationServices,
|
|
6
|
+
} from './locationServices';
|
|
7
|
+
export { PositionWatchHandle, watchPosition } from './PositionWatchHandle';
|
|
8
|
+
export {
|
|
9
|
+
LocationProvider,
|
|
10
|
+
setLocationProvider,
|
|
11
|
+
getSelectedLocationProviderName,
|
|
12
|
+
} from './LocationProvider';
|
|
13
|
+
export {
|
|
14
|
+
getForegroundPermissions,
|
|
15
|
+
requestForegroundPermissions,
|
|
16
|
+
getBackgroundPermissions,
|
|
17
|
+
requestBackgroundPermissions,
|
|
18
|
+
useForegroundLocationPermissions,
|
|
19
|
+
useBackgroundLocationPermissions,
|
|
20
|
+
} from './Permissions';
|
|
21
|
+
export { LocationUpdatesHandle, defineLocationTask } from './LocationUpdatesHandle';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Platform, UnavailabilityError } from 'expo';
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { AppState } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { NativeLocationModuleNext } from '../native';
|
|
6
|
+
|
|
7
|
+
export function hasLocationServicesEnabled(): boolean {
|
|
8
|
+
return NativeLocationModuleNext.hasLocationServicesEnabled();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function enableLocationServices(): Promise<boolean> {
|
|
12
|
+
if (Platform.OS !== 'android') {
|
|
13
|
+
throw new UnavailabilityError('expo-location', 'enableLocationServices');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return NativeLocationModuleNext.enableLocationServices();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useLocationServices(): [enabled: boolean, enable: () => Promise<boolean>] {
|
|
20
|
+
const [enabled, setEnabled] = useState(hasLocationServicesEnabled);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const subscription = AppState.addEventListener('change', (state) => {
|
|
24
|
+
if (state === 'active') {
|
|
25
|
+
setEnabled(hasLocationServicesEnabled());
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return () => subscription.remove();
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
const enable = useCallback(async () => {
|
|
32
|
+
const result = await enableLocationServices();
|
|
33
|
+
setEnabled(result);
|
|
34
|
+
return result;
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
return [enabled, enable];
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { requireNativeModule } from 'expo';
|
|
2
|
+
|
|
3
|
+
import type { NativeLocationModuleNextClass } from './types/NativeLocationModuleNextClass.types';
|
|
4
|
+
|
|
5
|
+
export const NativeLocationModuleNext =
|
|
6
|
+
requireNativeModule<NativeLocationModuleNextClass>('LocationModuleNext');
|
|
7
|
+
export const NativeLocationProvider = NativeLocationModuleNext.LocationProvider;
|
|
8
|
+
export const NativePositionWatchHandle = NativeLocationModuleNext.PositionWatchHandle;
|
|
9
|
+
export const NativeLocationUpdatesHandle = NativeLocationModuleNext.LocationUpdatesHandle;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export {
|
|
2
|
+
NativeLocationModuleNext,
|
|
3
|
+
NativeLocationProvider,
|
|
4
|
+
NativePositionWatchHandle,
|
|
5
|
+
NativeLocationUpdatesHandle,
|
|
6
|
+
} from './NativeLocationModuleNext';
|
|
7
|
+
export type { NativeLocationModuleNextClass } from './types/NativeLocationModuleNextClass.types';
|
|
8
|
+
export type { NativePositionWatchHandleClass } from './types/NativePositionWatchHandleClass.types';
|
|
9
|
+
export type { NativeLocationProviderClass } from './types/NativeLocationProviderClass.types';
|
|
10
|
+
export type { NativeLocationUpdatesHandleClass } from './types/NativeLocationUpdatesHandleClass.types';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { NativeModule } from 'expo';
|
|
2
|
+
import type { SharedRef } from 'expo';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
GetPositionOptions,
|
|
6
|
+
LocationPermissionResponse,
|
|
7
|
+
LocationProfile,
|
|
8
|
+
LocationProviderRefType,
|
|
9
|
+
Position,
|
|
10
|
+
RequestPermissionsOptions,
|
|
11
|
+
} from '../../types';
|
|
12
|
+
import type { NativeLocationProviderClass } from './NativeLocationProviderClass.types';
|
|
13
|
+
import type { NativeLocationUpdatesHandleClass } from './NativeLocationUpdatesHandleClass.types';
|
|
14
|
+
import type { NativePositionWatchHandleClass } from './NativePositionWatchHandleClass.types';
|
|
15
|
+
|
|
16
|
+
export declare class NativeLocationModuleNextClass extends NativeModule {
|
|
17
|
+
requestForegroundPermissions(
|
|
18
|
+
options?: RequestPermissionsOptions
|
|
19
|
+
): Promise<LocationPermissionResponse>;
|
|
20
|
+
getForegroundPermissions(): Promise<LocationPermissionResponse>;
|
|
21
|
+
requestBackgroundPermissions(
|
|
22
|
+
options?: RequestPermissionsOptions
|
|
23
|
+
): Promise<LocationPermissionResponse>;
|
|
24
|
+
getBackgroundPermissions(): Promise<LocationPermissionResponse>;
|
|
25
|
+
setLocationProvider(provider: SharedRef<LocationProviderRefType>): void;
|
|
26
|
+
getSelectedLocationProviderName(): string;
|
|
27
|
+
hasLocationServicesEnabled(): boolean;
|
|
28
|
+
enableLocationServices(): Promise<boolean>;
|
|
29
|
+
getPosition(options?: GetPositionOptions): Promise<Position | null>;
|
|
30
|
+
watchPosition(profile?: LocationProfile): NativePositionWatchHandleClass;
|
|
31
|
+
LocationProvider: typeof NativeLocationProviderClass;
|
|
32
|
+
PositionWatchHandle: typeof NativePositionWatchHandleClass;
|
|
33
|
+
LocationUpdatesHandle: typeof NativeLocationUpdatesHandleClass;
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SharedObject } from 'expo';
|
|
2
|
+
import type { SharedRef } from 'expo';
|
|
3
|
+
|
|
4
|
+
import type { LocationProviderRefType } from '../../types';
|
|
5
|
+
|
|
6
|
+
export declare class NativeLocationProviderClass extends SharedObject {
|
|
7
|
+
static Gms(): SharedRef<LocationProviderRefType>;
|
|
8
|
+
static Android(): SharedRef<LocationProviderRefType>;
|
|
9
|
+
static Fallback(
|
|
10
|
+
providers: SharedRef<LocationProviderRefType>[]
|
|
11
|
+
): SharedRef<LocationProviderRefType>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LocationProfile } from '../../types';
|
|
2
|
+
|
|
3
|
+
export declare class NativeLocationUpdatesHandleClass {
|
|
4
|
+
constructor(taskName: string);
|
|
5
|
+
withProfile(profile: LocationProfile): void;
|
|
6
|
+
start(): Promise<void>;
|
|
7
|
+
stop(): Promise<void>;
|
|
8
|
+
hasStarted(): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SharedObject } from 'expo';
|
|
2
|
+
|
|
3
|
+
import type { LocationProfile, PositionUpdate, PositionWatchStatus } from '../../types';
|
|
4
|
+
|
|
5
|
+
export declare class NativePositionWatchHandleClass extends SharedObject<{
|
|
6
|
+
positionChanged: (update: PositionUpdate) => void;
|
|
7
|
+
}> {
|
|
8
|
+
pause(): void;
|
|
9
|
+
resume(): boolean;
|
|
10
|
+
withProfile(profile: LocationProfile): NativePositionWatchHandleClass;
|
|
11
|
+
withInterval(intervalSeconds: number): NativePositionWatchHandleClass;
|
|
12
|
+
restart(): boolean;
|
|
13
|
+
status(): PositionWatchStatus;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type LocationProviderRefType = 'LocationProvider';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PermissionResponse } from 'expo';
|
|
2
|
+
|
|
3
|
+
export enum LocationScope {
|
|
4
|
+
ALWAYS = 'always',
|
|
5
|
+
WHEN_IN_USE = 'whenInUse',
|
|
6
|
+
NOT_GRANTED = 'notGranted',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum LocationAccuracy {
|
|
10
|
+
FULL = 'full',
|
|
11
|
+
REDUCED = 'reduced',
|
|
12
|
+
NOT_GRANTED = 'notGranted',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export enum RequestPermissionsAccuracyOption {
|
|
16
|
+
FULL = 'full',
|
|
17
|
+
REDUCED = 'reduced',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type LocationPermissionResponse = PermissionResponse & {
|
|
21
|
+
scope: LocationScope;
|
|
22
|
+
accuracy: LocationAccuracy;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type RequestPermissionsOptions = {
|
|
26
|
+
accuracy?: RequestPermissionsAccuracyOption;
|
|
27
|
+
};
|