diff --git a/docs/components/plugins/TableOfContentSection.js b/docs/components/plugins/TableOfContentSection.js index 608207b67085b..849e051aab8ca 100644 --- a/docs/components/plugins/TableOfContentSection.js +++ b/docs/components/plugins/TableOfContentSection.js @@ -104,6 +104,7 @@ export default class TableOfContentSection extends React.Component { {contents.map(data => { return ( diff --git a/docs/pages/versions/unversioned/sdk/location.md b/docs/pages/versions/unversioned/sdk/location.md index d132974a3f9df..36427a8802d7b 100644 --- a/docs/pages/versions/unversioned/sdk/location.md +++ b/docs/pages/versions/unversioned/sdk/location.md @@ -102,6 +102,7 @@ Get the current position of the device. - **options (_object_)** -- A map of options: - **accuracy : [Location.Accuracy](#locationaccuracy)** -- Location manager accuracy. Pass one of [Location.Accuracy](#locationaccuracy) enum values. For low-accuracy the implementation can avoid geolocation providers that consume a significant amount of power (such as GPS). - **maximumAge (_number_)** -- (Android only). If specified, allow returning a previously cached position that is at most this old in milliseconds. If not specified, always gets a new location. On iOS this option is ignored and a new location is always returned. + - **timeout (_number_)** -- (Android only). Specifies the duration of time in milliseconds to wait before timing out the location request. #### Returns diff --git a/docs/pages/versions/v36.0.0/sdk/location.md b/docs/pages/versions/v36.0.0/sdk/location.md index d132974a3f9df..36427a8802d7b 100644 --- a/docs/pages/versions/v36.0.0/sdk/location.md +++ b/docs/pages/versions/v36.0.0/sdk/location.md @@ -102,6 +102,7 @@ Get the current position of the device. - **options (_object_)** -- A map of options: - **accuracy : [Location.Accuracy](#locationaccuracy)** -- Location manager accuracy. Pass one of [Location.Accuracy](#locationaccuracy) enum values. For low-accuracy the implementation can avoid geolocation providers that consume a significant amount of power (such as GPS). - **maximumAge (_number_)** -- (Android only). If specified, allow returning a previously cached position that is at most this old in milliseconds. If not specified, always gets a new location. On iOS this option is ignored and a new location is always returned. + - **timeout (_number_)** -- (Android only). Specifies the duration of time in milliseconds to wait before timing out the location request. #### Returns diff --git a/packages/expo-location/build/Location.d.ts b/packages/expo-location/build/Location.d.ts index 4f6eb73cfb06c..55e24131d2837 100644 --- a/packages/expo-location/build/Location.d.ts +++ b/packages/expo-location/build/Location.d.ts @@ -10,6 +10,7 @@ export interface ProviderStatus { } export interface LocationOptions { accuracy?: LocationAccuracy; + maximumAge?: number; enableHighAccuracy?: boolean; timeInterval?: number; distanceInterval?: number; diff --git a/packages/expo-location/build/Location.js.map b/packages/expo-location/build/Location.js.map index bc389937f50f3..61a527d5d6173 100644 --- a/packages/expo-location/build/Location.js.map +++ b/packages/expo-location/build/Location.js.map @@ -1 +1 @@ -{"version":3,"file":"Location.js","sourceRoot":"","sources":["../src/Location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAEL,gBAAgB,GACjB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,oBAAoB,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;AAqD5D,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAkD5B,IAAK,gBAOJ;AAPD,WAAK,gBAAgB;IACnB,2DAAU,CAAA;IACV,qDAAO,CAAA;IACP,+DAAY,CAAA;IACZ,uDAAQ,CAAA;IACR,6DAAW,CAAA;IACX,iFAAqB,CAAA;AACvB,CAAC,EAPI,gBAAgB,KAAhB,gBAAgB,QAOpB;AAED,IAAK,oBAMJ;AAND,WAAK,oBAAoB;IACvB,iEAAS,CAAA;IACT,+FAAwB,CAAA;IACxB,qEAAW,CAAA;IACX,qFAAmB,CAAA;IACnB,uEAAY,CAAA;AACd,CAAC,EANI,oBAAoB,KAApB,oBAAoB,QAMxB;AAED,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,oBAAoB,IAAI,YAAY,EAAE,CAAC;AAE9E,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,+DAAS,CAAA;IACT,6DAAQ,CA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AM,IAAI,SAAS,CACjB,6CAA6C,MAAM,CAAC,SAAS,YAAY,CAC1E,CAAC;SACH;QACD,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;YACrC,MAAM,IAAI,SAAS,CAAC,0CAA0C,MAAM,CAAC,MAAM,YAAY,CAAC,CAAC;SAC1F;KACF;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAgB,EAChB,UAAoB,EAAE;IAEtB,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC1B,MAAM,YAAY,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,MAAM,YAAY,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,QAAgB;IAC9D,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,YAAY,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,gGAAgG;QAChG,cAAc;QACd,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,OAAO;AACL,wBAAwB;AACxB,oBAAoB,IAAI,YAAY,EACpC,kBAAkB,GACnB,CAAC","sourcesContent":["import { EventEmitter, Platform, CodedError } from '@unimodules/core';\nimport {\n PermissionResponse as UMPermissionResponse,\n PermissionStatus,\n} from 'unimodules-permissions-interface';\n\nimport invariant from 'invariant';\n\nimport ExpoLocation from './ExpoLocation';\n\nconst LocationEventEmitter = new EventEmitter(ExpoLocation);\n\nexport interface ProviderStatus {\n locationServicesEnabled: boolean;\n backgroundModeEnabled: boolean;\n gpsAvailable?: boolean;\n networkAvailable?: boolean;\n passiveAvailable?: boolean;\n}\n\nexport interface LocationOptions {\n accuracy?: LocationAccuracy;\n enableHighAccuracy?: boolean;\n timeInterval?: number;\n distanceInterval?: number;\n timeout?: number;\n mayShowUserSettingsDialog?: boolean;\n}\n\nexport interface LocationData {\n coords: {\n latitude: number;\n longitude: number;\n altitude: number;\n accuracy: number;\n heading: number;\n speed: number;\n };\n timestamp: number;\n}\n\nexport interface HeadingData {\n trueHeading: number;\n magHeading: number;\n accuracy: number;\n}\n\nexport interface GeocodedLocation {\n latitude: number;\n longitude: number;\n altitude?: number;\n accuracy?: number;\n}\n\nexport interface Address {\n city: string;\n street: string;\n region: string;\n country: string;\n postalCode: string;\n name: string;\n}\n\nexport { PermissionStatus };\n\nexport type PermissionDetailsLocationIOS = {\n scope: 'whenInUse' | 'always';\n};\n\nexport type PermissionDetailsLocationAndroid = {\n scope: 'fine' | 'coarse' | 'none';\n};\n\nexport interface PermissionResponse extends UMPermissionResponse {\n ios?: PermissionDetailsLocationIOS;\n android?: PermissionDetailsLocationAndroid;\n}\n\ninterface LocationTaskOptions {\n accuracy?: LocationAccuracy;\n timeInterval?: number; // Android only\n distanceInterval?: number;\n showsBackgroundLocationIndicator?: boolean; // iOS only\n deferredUpdatesDistance?: number;\n deferredUpdatesTimeout?: number;\n deferredUpdatesInterval?: number;\n\n // iOS only\n activityType?: LocationActivityType;\n pausesUpdatesAutomatically?: boolean;\n\n foregroundService?: {\n notificationTitle: string;\n notificationBody: string;\n notificationColor?: string;\n };\n}\n\ninterface Region {\n identifier?: string;\n latitude: number;\n longitude: number;\n radius: number;\n notifyOnEnter?: boolean;\n notifyOnExit?: boolean;\n}\n\ntype Subscription = {\n remove: () => void;\n};\ntype LocationCallback = (data: LocationData) => any;\ntype HeadingCallback = (data: HeadingData) => any;\n\nenum LocationAccuracy {\n Lowest = 1,\n Low = 2,\n Balanced = 3,\n High = 4,\n Highest = 5,\n BestForNavigation = 6,\n}\n\nenum LocationActivityType {\n Other = 1,\n AutomotiveNavigation = 2,\n Fitness = 3,\n OtherNavigation = 4,\n Airborne = 5,\n}\n\nexport { LocationAccuracy as Accuracy, LocationActivityType as ActivityType };\n\nexport enum GeofencingEventType {\n Enter = 1,\n Exit = 2,\n}\n\nexport enum GeofencingRegionState {\n Unknown = 0,\n Inside = 1,\n Outside = 2,\n}\n\nlet nextWatchId = 0;\nlet headingId;\nfunction _getNextWatchId() {\n nextWatchId++;\n return nextWatchId;\n}\nfunction _getCurrentWatchId() {\n return nextWatchId;\n}\n\nlet watchCallbacks: {\n [watchId: number]: LocationCallback | HeadingCallback;\n} = {};\n\nlet deviceEventSubscription: Subscription | null;\nlet headingEventSub: Subscription | null;\nlet googleApiKey;\nconst googleApiUrl = 'https://maps.googleapis.com/maps/api/geocode/json';\n\nexport async function getProviderStatusAsync(): Promise {\n return ExpoLocation.getProviderStatusAsync();\n}\n\nexport async function enableNetworkProviderAsync(): Promise {\n // If network provider is disabled (user's location mode is set to \"Device only\"),\n // Android's location provider may not give you any results. Use this method in order to ask the user\n // to change the location mode to \"High accuracy\" which uses Google Play services and enables network provider.\n // `getCurrentPositionAsync` and `watchPositionAsync` are doing it automatically anyway.\n\n if (Platform.OS === 'android') {\n return ExpoLocation.enableNetworkProviderAsync();\n }\n}\n\nexport async function getCurrentPositionAsync(\n options: LocationOptions = {}\n): Promise {\n return ExpoLocation.getCurrentPositionAsync(options);\n}\n\nexport async function getLastKnownPositionAsync(): Promise {\n return ExpoLocation.getLastKnownPositionAsync();\n}\n\n// Start Compass Module\n\n// To simplify, we will call watchHeadingAsync and wait for one update To ensure accuracy, we wait\n// for a couple of watch updates if the data has low accuracy\nexport async function getHeadingAsync(): Promise {\n return new Promise(async (resolve, reject) => {\n try {\n // If there is already a compass active (would be a watch)\n if (headingEventSub) {\n let tries = 0;\n const headingSub = LocationEventEmitter.addListener(\n 'Expo.headingChanged',\n ({ heading }: { heading: HeadingData }) => {\n if (heading.accuracy > 1 || tries > 5) {\n resolve(heading);\n LocationEventEmitter.removeSubscription(headingSub);\n } else {\n tries += 1;\n }\n }\n );\n } else {\n let done = false;\n let subscription;\n let tries = 0;\n subscription = await watchHeadingAsync((heading: HeadingData) => {\n if (!done) {\n if (heading.accuracy > 1 || tries > 5) {\n subscription.remove();\n resolve(heading);\n done = true;\n } else {\n tries += 1;\n }\n } else {\n subscription.remove();\n }\n });\n\n if (done) {\n subscription.remove();\n }\n }\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport async function watchHeadingAsync(\n callback: HeadingCallback\n): Promise<{ remove: () => void }> {\n // Check if there is already a compass event watch.\n if (headingEventSub) {\n _removeHeadingWatcher(headingId);\n }\n\n headingEventSub = LocationEventEmitter.addListener(\n 'Expo.headingChanged',\n ({ watchId, heading }: { watchId: string; heading: HeadingData }) => {\n const callback = watchCallbacks[watchId];\n if (callback) {\n callback(heading);\n } else {\n ExpoLocation.removeWatchAsync(watchId);\n }\n }\n );\n\n headingId = _getNextWatchId();\n watchCallbacks[headingId] = callback;\n await ExpoLocation.watchDeviceHeading(headingId);\n return {\n remove() {\n _removeHeadingWatcher(headingId);\n },\n };\n}\n\n// Removes the compass listener and sub from JS and Native\nfunction _removeHeadingWatcher(watchId) {\n if (!watchCallbacks[watchId]) {\n return;\n }\n delete watchCallbacks[watchId];\n ExpoLocation.removeWatchAsync(watchId);\n if (headingEventSub) {\n LocationEventEmitter.removeSubscription(headingEventSub);\n headingEventSub = null;\n }\n}\n// End Compass Module\n\nfunction _maybeInitializeEmitterSubscription() {\n if (!deviceEventSubscription) {\n deviceEventSubscription = LocationEventEmitter.addListener(\n 'Expo.locationChanged',\n ({ watchId, location }: { watchId: string; location: LocationData }) => {\n const callback = watchCallbacks[watchId];\n if (callback) {\n callback(location);\n } else {\n ExpoLocation.removeWatchAsync(watchId);\n }\n }\n );\n }\n}\n\nexport async function geocodeAsync(address: string): Promise {\n return ExpoLocation.geocodeAsync(address).catch(error => {\n const platformUsesGoogleMaps = Platform.OS === 'android' || Platform.OS === 'web';\n\n if (platformUsesGoogleMaps && error.code === 'E_NO_GEOCODER') {\n if (!googleApiKey) {\n throw new CodedError(\n error.code,\n `${error.message} Please set a Google API Key to use geocoding.`\n );\n }\n return _googleGeocodeAsync(address);\n }\n throw error;\n });\n}\n\nexport async function reverseGeocodeAsync(location: {\n latitude: number;\n longitude: number;\n}): Promise {\n if (typeof location.latitude !== 'number' || typeof location.longitude !== 'number') {\n throw new TypeError(\n 'Location should be an object with number properties `latitude` and `longitude`.'\n );\n }\n return ExpoLocation.reverseGeocodeAsync(location).catch(error => {\n const platformUsesGoogleMaps = Platform.OS === 'android' || Platform.OS === 'web';\n\n if (platformUsesGoogleMaps && error.code === 'E_NO_GEOCODER') {\n if (!googleApiKey) {\n throw new CodedError(\n error.code,\n `${error.message} Please set a Google API Key to use geocoding.`\n );\n }\n return _googleReverseGeocodeAsync(location);\n }\n throw error;\n });\n}\n\nexport function setApiKey(apiKey: string) {\n googleApiKey = apiKey;\n}\n\nasync function _googleGeocodeAsync(address: string): Promise {\n const result = await fetch(`${googleApiUrl}?key=${googleApiKey}&address=${encodeURI(address)}`);\n const resultObject = await result.json();\n\n if (resultObject.status === 'ZERO_RESULTS') {\n return [];\n }\n\n assertGeocodeResults(resultObject);\n\n return resultObject.results.map(result => {\n let location = result.geometry.location;\n // TODO: This is missing a lot of props\n return {\n latitude: location.lat,\n longitude: location.lng,\n };\n });\n}\n\nasync function _googleReverseGeocodeAsync(options: {\n latitude: number;\n longitude: number;\n}): Promise {\n const result = await fetch(\n `${googleApiUrl}?key=${googleApiKey}&latlng=${options.latitude},${options.longitude}`\n );\n const resultObject = await result.json();\n\n if (resultObject.status === 'ZERO_RESULTS') {\n return [];\n }\n\n assertGeocodeResults(resultObject);\n\n return resultObject.results.map(result => {\n const address: any = {};\n\n result.address_components.forEach(component => {\n if (component.types.includes('locality')) {\n address.city = component.long_name;\n } else if (component.types.includes('street_address')) {\n address.street = component.long_name;\n } else if (component.types.includes('administrative_area_level_1')) {\n address.region = component.long_name;\n } else if (component.types.includes('country')) {\n address.country = component.long_name;\n } else if (component.types.includes('postal_code')) {\n address.postalCode = component.long_name;\n } else if (component.types.includes('point_of_interest')) {\n address.name = component.long_name;\n }\n });\n return address as Address;\n });\n}\n\n// https://developers.google.com/maps/documentation/geocoding/intro\nfunction assertGeocodeResults(resultObject: any): void {\n const { status, error_message } = resultObject;\n if (status !== 'ZERO_RESULTS' && status !== 'OK') {\n if (error_message) {\n throw new CodedError(status, error_message);\n } else if (status === 'UNKNOWN_ERROR') {\n throw new CodedError(\n status,\n 'the request could not be processed due to a server error. The request may succeed if you try again.'\n );\n }\n throw new CodedError(status, `An error occurred during geocoding.`);\n }\n}\n\n// Polyfill: navigator.geolocation.watchPosition\nfunction watchPosition(\n success: GeoSuccessCallback,\n error: GeoErrorCallback,\n options: LocationOptions\n) {\n _maybeInitializeEmitterSubscription();\n\n const watchId = _getNextWatchId();\n watchCallbacks[watchId] = success;\n\n ExpoLocation.watchPositionImplAsync(watchId, options).catch(err => {\n _removeWatcher(watchId);\n error({ watchId, message: err.message, code: err.code });\n });\n\n return watchId;\n}\n\nexport async function watchPositionAsync(options: LocationOptions, callback: LocationCallback) {\n _maybeInitializeEmitterSubscription();\n\n const watchId = _getNextWatchId();\n watchCallbacks[watchId] = callback;\n await ExpoLocation.watchPositionImplAsync(watchId, options);\n\n return {\n remove() {\n _removeWatcher(watchId);\n },\n };\n}\n\n// Polyfill: navigator.geolocation.clearWatch\nfunction clearWatch(watchId: number) {\n _removeWatcher(watchId);\n}\n\nfunction _removeWatcher(watchId) {\n // Do nothing if we have already removed the subscription\n if (!watchCallbacks[watchId]) {\n return;\n }\n\n ExpoLocation.removeWatchAsync(watchId);\n delete watchCallbacks[watchId];\n if (Object.keys(watchCallbacks).length === 0 && deviceEventSubscription) {\n LocationEventEmitter.removeSubscription(deviceEventSubscription);\n deviceEventSubscription = null;\n }\n}\n\ntype GeoSuccessCallback = (data: LocationData) => void;\ntype GeoErrorCallback = (error: any) => void;\n\nfunction getCurrentPosition(\n success: GeoSuccessCallback,\n error: GeoErrorCallback = () => {},\n options: LocationOptions = {}\n): void {\n invariant(typeof success === 'function', 'Must provide a valid success callback.');\n\n invariant(typeof options === 'object', 'options must be an object.');\n\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: GeoSuccessCallback,\n error: GeoErrorCallback,\n options: LocationOptions\n): Promise {\n try {\n await ExpoLocation.requestPermissionsAsync();\n const result = await getCurrentPositionAsync(options);\n success(result);\n } catch (e) {\n error(e);\n }\n}\n\nexport async function getPermissionsAsync(): Promise {\n return await ExpoLocation.getPermissionsAsync();\n}\n\nexport async function requestPermissionsAsync(): Promise {\n return await ExpoLocation.requestPermissionsAsync();\n}\n\n// --- Location service\n\nexport async function hasServicesEnabledAsync(): Promise {\n return await ExpoLocation.hasServicesEnabledAsync();\n}\n\n// --- Background location updates\n\nfunction _validateTaskName(taskName: string) {\n invariant(taskName && typeof taskName === 'string', '`taskName` must be a non-empty string.');\n}\n\nexport async function isBackgroundLocationAvailableAsync(): Promise {\n const providerStatus = await getProviderStatusAsync();\n return providerStatus.backgroundModeEnabled;\n}\n\nexport async function startLocationUpdatesAsync(\n taskName: string,\n options: LocationTaskOptions = { accuracy: LocationAccuracy.Balanced }\n): Promise {\n _validateTaskName(taskName);\n await ExpoLocation.startLocationUpdatesAsync(taskName, options);\n}\n\nexport async function stopLocationUpdatesAsync(taskName: string): Promise {\n _validateTaskName(taskName);\n await ExpoLocation.stopLocationUpdatesAsync(taskName);\n}\n\nexport async function hasStartedLocationUpdatesAsync(taskName: string): Promise {\n _validateTaskName(taskName);\n return ExpoLocation.hasStartedLocationUpdatesAsync(taskName);\n}\n\n// --- Geofencing\n\nfunction _validateRegions(regions: Region[]) {\n if (!regions || regions.length === 0) {\n throw new Error(\n 'Regions array cannot be empty. Use `stopGeofencingAsync` if you want to stop geofencing all regions'\n );\n }\n for (const region of regions) {\n if (typeof region.latitude !== 'number') {\n throw new TypeError(`Region's latitude must be a number. Got '${region.latitude}' instead.`);\n }\n if (typeof region.longitude !== 'number') {\n throw new TypeError(\n `Region's longitude must be a number. Got '${region.longitude}' instead.`\n );\n }\n if (typeof region.radius !== 'number') {\n throw new TypeError(`Region's radius must be a number. Got '${region.radius}' instead.`);\n }\n }\n}\n\nexport async function startGeofencingAsync(\n taskName: string,\n regions: Region[] = []\n): Promise {\n _validateTaskName(taskName);\n _validateRegions(regions);\n await ExpoLocation.startGeofencingAsync(taskName, { regions });\n}\n\nexport async function stopGeofencingAsync(taskName: string): Promise {\n _validateTaskName(taskName);\n await ExpoLocation.stopGeofencingAsync(taskName);\n}\n\nexport async function hasStartedGeofencingAsync(taskName: string): Promise {\n _validateTaskName(taskName);\n return ExpoLocation.hasStartedGeofencingAsync(taskName);\n}\n\nexport function installWebGeolocationPolyfill(): void {\n if (Platform.OS !== 'web') {\n // Polyfill navigator.geolocation for interop with the core react-native and web API approach to\n // geolocation\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\nexport {\n // For internal purposes\n LocationEventEmitter as EventEmitter,\n _getCurrentWatchId,\n};\n"]} \ No newline at end of file +{"version":3,"file":"Location.js","sourceRoot":"","sources":["../src/Location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAEL,gBAAgB,G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MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,MAAM,YAAY,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,QAAgB;IAC9D,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,YAAY,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,gGAAgG;QAChG,cAAc;QACd,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,OAAO;AACL,wBAAwB;AACxB,oBAAoB,IAAI,YAAY,EACpC,kBAAkB,GACnB,CAAC","sourcesContent":["import { EventEmitter, Platform, CodedError } from '@unimodules/core';\nimport {\n PermissionResponse as UMPermissionResponse,\n PermissionStatus,\n} from 'unimodules-permissions-interface';\n\nimport invariant from 'invariant';\n\nimport ExpoLocation from './ExpoLocation';\n\nconst LocationEventEmitter = new EventEmitter(ExpoLocation);\n\nexport interface ProviderStatus {\n locationServicesEnabled: boolean;\n backgroundModeEnabled: boolean;\n gpsAvailable?: boolean;\n networkAvailable?: boolean;\n passiveAvailable?: boolean;\n}\n\nexport interface LocationOptions {\n accuracy?: LocationAccuracy;\n maximumAge?: number;\n enableHighAccuracy?: boolean;\n timeInterval?: number;\n distanceInterval?: number;\n timeout?: number;\n mayShowUserSettingsDialog?: boolean;\n}\n\nexport interface LocationData {\n coords: {\n latitude: number;\n longitude: number;\n altitude: number;\n accuracy: number;\n heading: number;\n speed: number;\n };\n timestamp: number;\n}\n\nexport interface HeadingData {\n trueHeading: number;\n magHeading: number;\n accuracy: number;\n}\n\nexport interface GeocodedLocation {\n latitude: number;\n longitude: number;\n altitude?: number;\n accuracy?: number;\n}\n\nexport interface Address {\n city: string;\n street: string;\n region: string;\n country: string;\n postalCode: string;\n name: string;\n}\n\nexport { PermissionStatus };\n\nexport type PermissionDetailsLocationIOS = {\n scope: 'whenInUse' | 'always';\n};\n\nexport type PermissionDetailsLocationAndroid = {\n scope: 'fine' | 'coarse' | 'none';\n};\n\nexport interface PermissionResponse extends UMPermissionResponse {\n ios?: PermissionDetailsLocationIOS;\n android?: PermissionDetailsLocationAndroid;\n}\n\ninterface LocationTaskOptions {\n accuracy?: LocationAccuracy;\n timeInterval?: number; // Android only\n distanceInterval?: number;\n showsBackgroundLocationIndicator?: boolean; // iOS only\n deferredUpdatesDistance?: number;\n deferredUpdatesTimeout?: number;\n deferredUpdatesInterval?: number;\n\n // iOS only\n activityType?: LocationActivityType;\n pausesUpdatesAutomatically?: boolean;\n\n foregroundService?: {\n notificationTitle: string;\n notificationBody: string;\n notificationColor?: string;\n };\n}\n\ninterface Region {\n identifier?: string;\n latitude: number;\n longitude: number;\n radius: number;\n notifyOnEnter?: boolean;\n notifyOnExit?: boolean;\n}\n\ntype Subscription = {\n remove: () => void;\n};\ntype LocationCallback = (data: LocationData) => any;\ntype HeadingCallback = (data: HeadingData) => any;\n\nenum LocationAccuracy {\n Lowest = 1,\n Low = 2,\n Balanced = 3,\n High = 4,\n Highest = 5,\n BestForNavigation = 6,\n}\n\nenum LocationActivityType {\n Other = 1,\n AutomotiveNavigation = 2,\n Fitness = 3,\n OtherNavigation = 4,\n Airborne = 5,\n}\n\nexport { LocationAccuracy as Accuracy, LocationActivityType as ActivityType };\n\nexport enum GeofencingEventType {\n Enter = 1,\n Exit = 2,\n}\n\nexport enum GeofencingRegionState {\n Unknown = 0,\n Inside = 1,\n Outside = 2,\n}\n\nlet nextWatchId = 0;\nlet headingId;\nfunction _getNextWatchId() {\n nextWatchId++;\n return nextWatchId;\n}\nfunction _getCurrentWatchId() {\n return nextWatchId;\n}\n\nlet watchCallbacks: {\n [watchId: number]: LocationCallback | HeadingCallback;\n} = {};\n\nlet deviceEventSubscription: Subscription | null;\nlet headingEventSub: Subscription | null;\nlet googleApiKey;\nconst googleApiUrl = 'https://maps.googleapis.com/maps/api/geocode/json';\n\nexport async function getProviderStatusAsync(): Promise {\n return ExpoLocation.getProviderStatusAsync();\n}\n\nexport async function enableNetworkProviderAsync(): Promise {\n // If network provider is disabled (user's location mode is set to \"Device only\"),\n // Android's location provider may not give you any results. Use this method in order to ask the user\n // to change the location mode to \"High accuracy\" which uses Google Play services and enables network provider.\n // `getCurrentPositionAsync` and `watchPositionAsync` are doing it automatically anyway.\n\n if (Platform.OS === 'android') {\n return ExpoLocation.enableNetworkProviderAsync();\n }\n}\n\nexport async function getCurrentPositionAsync(\n options: LocationOptions = {}\n): Promise {\n return ExpoLocation.getCurrentPositionAsync(options);\n}\n\nexport async function getLastKnownPositionAsync(): Promise {\n return ExpoLocation.getLastKnownPositionAsync();\n}\n\n// Start Compass Module\n\n// To simplify, we will call watchHeadingAsync and wait for one update To ensure accuracy, we wait\n// for a couple of watch updates if the data has low accuracy\nexport async function getHeadingAsync(): Promise {\n return new Promise(async (resolve, reject) => {\n try {\n // If there is already a compass active (would be a watch)\n if (headingEventSub) {\n let tries = 0;\n const headingSub = LocationEventEmitter.addListener(\n 'Expo.headingChanged',\n ({ heading }: { heading: HeadingData }) => {\n if (heading.accuracy > 1 || tries > 5) {\n resolve(heading);\n LocationEventEmitter.removeSubscription(headingSub);\n } else {\n tries += 1;\n }\n }\n );\n } else {\n let done = false;\n let subscription;\n let tries = 0;\n subscription = await watchHeadingAsync((heading: HeadingData) => {\n if (!done) {\n if (heading.accuracy > 1 || tries > 5) {\n subscription.remove();\n resolve(heading);\n done = true;\n } else {\n tries += 1;\n }\n } else {\n subscription.remove();\n }\n });\n\n if (done) {\n subscription.remove();\n }\n }\n } catch (e) {\n reject(e);\n }\n });\n}\n\nexport async function watchHeadingAsync(\n callback: HeadingCallback\n): Promise<{ remove: () => void }> {\n // Check if there is already a compass event watch.\n if (headingEventSub) {\n _removeHeadingWatcher(headingId);\n }\n\n headingEventSub = LocationEventEmitter.addListener(\n 'Expo.headingChanged',\n ({ watchId, heading }: { watchId: string; heading: HeadingData }) => {\n const callback = watchCallbacks[watchId];\n if (callback) {\n callback(heading);\n } else {\n ExpoLocation.removeWatchAsync(watchId);\n }\n }\n );\n\n headingId = _getNextWatchId();\n watchCallbacks[headingId] = callback;\n await ExpoLocation.watchDeviceHeading(headingId);\n return {\n remove() {\n _removeHeadingWatcher(headingId);\n },\n };\n}\n\n// Removes the compass listener and sub from JS and Native\nfunction _removeHeadingWatcher(watchId) {\n if (!watchCallbacks[watchId]) {\n return;\n }\n delete watchCallbacks[watchId];\n ExpoLocation.removeWatchAsync(watchId);\n if (headingEventSub) {\n LocationEventEmitter.removeSubscription(headingEventSub);\n headingEventSub = null;\n }\n}\n// End Compass Module\n\nfunction _maybeInitializeEmitterSubscription() {\n if (!deviceEventSubscription) {\n deviceEventSubscription = LocationEventEmitter.addListener(\n 'Expo.locationChanged',\n ({ watchId, location }: { watchId: string; location: LocationData }) => {\n const callback = watchCallbacks[watchId];\n if (callback) {\n callback(location);\n } else {\n ExpoLocation.removeWatchAsync(watchId);\n }\n }\n );\n }\n}\n\nexport async function geocodeAsync(address: string): Promise {\n return ExpoLocation.geocodeAsync(address).catch(error => {\n const platformUsesGoogleMaps = Platform.OS === 'android' || Platform.OS === 'web';\n\n if (platformUsesGoogleMaps && error.code === 'E_NO_GEOCODER') {\n if (!googleApiKey) {\n throw new CodedError(\n error.code,\n `${error.message} Please set a Google API Key to use geocoding.`\n );\n }\n return _googleGeocodeAsync(address);\n }\n throw error;\n });\n}\n\nexport async function reverseGeocodeAsync(location: {\n latitude: number;\n longitude: number;\n}): Promise {\n if (typeof location.latitude !== 'number' || typeof location.longitude !== 'number') {\n throw new TypeError(\n 'Location should be an object with number properties `latitude` and `longitude`.'\n );\n }\n return ExpoLocation.reverseGeocodeAsync(location).catch(error => {\n const platformUsesGoogleMaps = Platform.OS === 'android' || Platform.OS === 'web';\n\n if (platformUsesGoogleMaps && error.code === 'E_NO_GEOCODER') {\n if (!googleApiKey) {\n throw new CodedError(\n error.code,\n `${error.message} Please set a Google API Key to use geocoding.`\n );\n }\n return _googleReverseGeocodeAsync(location);\n }\n throw error;\n });\n}\n\nexport function setApiKey(apiKey: string) {\n googleApiKey = apiKey;\n}\n\nasync function _googleGeocodeAsync(address: string): Promise {\n const result = await fetch(`${googleApiUrl}?key=${googleApiKey}&address=${encodeURI(address)}`);\n const resultObject = await result.json();\n\n if (resultObject.status === 'ZERO_RESULTS') {\n return [];\n }\n\n assertGeocodeResults(resultObject);\n\n return resultObject.results.map(result => {\n let location = result.geometry.location;\n // TODO: This is missing a lot of props\n return {\n latitude: location.lat,\n longitude: location.lng,\n };\n });\n}\n\nasync function _googleReverseGeocodeAsync(options: {\n latitude: number;\n longitude: number;\n}): Promise {\n const result = await fetch(\n `${googleApiUrl}?key=${googleApiKey}&latlng=${options.latitude},${options.longitude}`\n );\n const resultObject = await result.json();\n\n if (resultObject.status === 'ZERO_RESULTS') {\n return [];\n }\n\n assertGeocodeResults(resultObject);\n\n return resultObject.results.map(result => {\n const address: any = {};\n\n result.address_components.forEach(component => {\n if (component.types.includes('locality')) {\n address.city = component.long_name;\n } else if (component.types.includes('street_address')) {\n address.street = component.long_name;\n } else if (component.types.includes('administrative_area_level_1')) {\n address.region = component.long_name;\n } else if (component.types.includes('country')) {\n address.country = component.long_name;\n } else if (component.types.includes('postal_code')) {\n address.postalCode = component.long_name;\n } else if (component.types.includes('point_of_interest')) {\n address.name = component.long_name;\n }\n });\n return address as Address;\n });\n}\n\n// https://developers.google.com/maps/documentation/geocoding/intro\nfunction assertGeocodeResults(resultObject: any): void {\n const { status, error_message } = resultObject;\n if (status !== 'ZERO_RESULTS' && status !== 'OK') {\n if (error_message) {\n throw new CodedError(status, error_message);\n } else if (status === 'UNKNOWN_ERROR') {\n throw new CodedError(\n status,\n 'the request could not be processed due to a server error. The request may succeed if you try again.'\n );\n }\n throw new CodedError(status, `An error occurred during geocoding.`);\n }\n}\n\n// Polyfill: navigator.geolocation.watchPosition\nfunction watchPosition(\n success: GeoSuccessCallback,\n error: GeoErrorCallback,\n options: LocationOptions\n) {\n _maybeInitializeEmitterSubscription();\n\n const watchId = _getNextWatchId();\n watchCallbacks[watchId] = success;\n\n ExpoLocation.watchPositionImplAsync(watchId, options).catch(err => {\n _removeWatcher(watchId);\n error({ watchId, message: err.message, code: err.code });\n });\n\n return watchId;\n}\n\nexport async function watchPositionAsync(options: LocationOptions, callback: LocationCallback) {\n _maybeInitializeEmitterSubscription();\n\n const watchId = _getNextWatchId();\n watchCallbacks[watchId] = callback;\n await ExpoLocation.watchPositionImplAsync(watchId, options);\n\n return {\n remove() {\n _removeWatcher(watchId);\n },\n };\n}\n\n// Polyfill: navigator.geolocation.clearWatch\nfunction clearWatch(watchId: number) {\n _removeWatcher(watchId);\n}\n\nfunction _removeWatcher(watchId) {\n // Do nothing if we have already removed the subscription\n if (!watchCallbacks[watchId]) {\n return;\n }\n\n ExpoLocation.removeWatchAsync(watchId);\n delete watchCallbacks[watchId];\n if (Object.keys(watchCallbacks).length === 0 && deviceEventSubscription) {\n LocationEventEmitter.removeSubscription(deviceEventSubscription);\n deviceEventSubscription = null;\n }\n}\n\ntype GeoSuccessCallback = (data: LocationData) => void;\ntype GeoErrorCallback = (error: any) => void;\n\nfunction getCurrentPosition(\n success: GeoSuccessCallback,\n error: GeoErrorCallback = () => {},\n options: LocationOptions = {}\n): void {\n invariant(typeof success === 'function', 'Must provide a valid success callback.');\n\n invariant(typeof options === 'object', 'options must be an object.');\n\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: GeoSuccessCallback,\n error: GeoErrorCallback,\n options: LocationOptions\n): Promise {\n try {\n await ExpoLocation.requestPermissionsAsync();\n const result = await getCurrentPositionAsync(options);\n success(result);\n } catch (e) {\n error(e);\n }\n}\n\nexport async function getPermissionsAsync(): Promise {\n return await ExpoLocation.getPermissionsAsync();\n}\n\nexport async function requestPermissionsAsync(): Promise {\n return await ExpoLocation.requestPermissionsAsync();\n}\n\n// --- Location service\n\nexport async function hasServicesEnabledAsync(): Promise {\n return await ExpoLocation.hasServicesEnabledAsync();\n}\n\n// --- Background location updates\n\nfunction _validateTaskName(taskName: string) {\n invariant(taskName && typeof taskName === 'string', '`taskName` must be a non-empty string.');\n}\n\nexport async function isBackgroundLocationAvailableAsync(): Promise {\n const providerStatus = await getProviderStatusAsync();\n return providerStatus.backgroundModeEnabled;\n}\n\nexport async function startLocationUpdatesAsync(\n taskName: string,\n options: LocationTaskOptions = { accuracy: LocationAccuracy.Balanced }\n): Promise {\n _validateTaskName(taskName);\n await ExpoLocation.startLocationUpdatesAsync(taskName, options);\n}\n\nexport async function stopLocationUpdatesAsync(taskName: string): Promise {\n _validateTaskName(taskName);\n await ExpoLocation.stopLocationUpdatesAsync(taskName);\n}\n\nexport async function hasStartedLocationUpdatesAsync(taskName: string): Promise {\n _validateTaskName(taskName);\n return ExpoLocation.hasStartedLocationUpdatesAsync(taskName);\n}\n\n// --- Geofencing\n\nfunction _validateRegions(regions: Region[]) {\n if (!regions || regions.length === 0) {\n throw new Error(\n 'Regions array cannot be empty. Use `stopGeofencingAsync` if you want to stop geofencing all regions'\n );\n }\n for (const region of regions) {\n if (typeof region.latitude !== 'number') {\n throw new TypeError(`Region's latitude must be a number. Got '${region.latitude}' instead.`);\n }\n if (typeof region.longitude !== 'number') {\n throw new TypeError(\n `Region's longitude must be a number. Got '${region.longitude}' instead.`\n );\n }\n if (typeof region.radius !== 'number') {\n throw new TypeError(`Region's radius must be a number. Got '${region.radius}' instead.`);\n }\n }\n}\n\nexport async function startGeofencingAsync(\n taskName: string,\n regions: Region[] = []\n): Promise {\n _validateTaskName(taskName);\n _validateRegions(regions);\n await ExpoLocation.startGeofencingAsync(taskName, { regions });\n}\n\nexport async function stopGeofencingAsync(taskName: string): Promise {\n _validateTaskName(taskName);\n await ExpoLocation.stopGeofencingAsync(taskName);\n}\n\nexport async function hasStartedGeofencingAsync(taskName: string): Promise {\n _validateTaskName(taskName);\n return ExpoLocation.hasStartedGeofencingAsync(taskName);\n}\n\nexport function installWebGeolocationPolyfill(): void {\n if (Platform.OS !== 'web') {\n // Polyfill navigator.geolocation for interop with the core react-native and web API approach to\n // geolocation\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\nexport {\n // For internal purposes\n LocationEventEmitter as EventEmitter,\n _getCurrentWatchId,\n};\n"]} \ No newline at end of file diff --git a/packages/expo-location/src/Location.ts b/packages/expo-location/src/Location.ts index 6af5ca7925502..e307c37c2f6f8 100644 --- a/packages/expo-location/src/Location.ts +++ b/packages/expo-location/src/Location.ts @@ -20,6 +20,7 @@ export interface ProviderStatus { export interface LocationOptions { accuracy?: LocationAccuracy; + maximumAge?: number; enableHighAccuracy?: boolean; timeInterval?: number; distanceInterval?: number;