diff --git a/README.md b/README.md index 20542cc7..4fa5079d 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html
- - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index 51beccb4..6f53cde5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.5.7", + "version": "4.5.8-beta.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index fedb3cad..5f98f997 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.5.7", + "version": "4.5.8-beta.0", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/api/track.ts b/src/api/track.ts index edf47233..12a97aa9 100644 --- a/src/api/track.ts +++ b/src/api/track.ts @@ -25,7 +25,7 @@ class TrackAPI { // if latitude & longitude are not provided, // try and retrieve device location (will prompt for location permissions) if (!latitude || !longitude) { - const deviceLocation = await Navigator.getCurrentPosition({ desiredAccuracy }); + const deviceLocation = await Navigator.getCurrentPosition({ desiredAccuracy }, fraud); latitude = deviceLocation.latitude; longitude = deviceLocation.longitude; accuracy = deviceLocation.accuracy; diff --git a/src/navigator.ts b/src/navigator.ts index 71cc07ad..b7d8754e 100644 --- a/src/navigator.ts +++ b/src/navigator.ts @@ -5,6 +5,26 @@ import { RadarLocationError, RadarPermissionsError } from './errors'; import type { LocationAuthorization, NavigatorPosition } from './types'; +const radarGeolocation = (() => { + if (!navigator) { + return null; + } + + const g = navigator.geolocation; + + if (!g) { + return null; + } + + const emptyFn = () => {}; + + return Object.freeze({ + getCurrentPosition: g.getCurrentPosition ? g.getCurrentPosition.bind(g) : emptyFn, + watchPosition: g.watchPosition ? g.watchPosition.bind(g) : emptyFn, + clearWatch: g.clearWatch ? g.clearWatch.bind(g) : emptyFn, + }); +})(); + interface PositionOptionOverrides { desiredAccuracy?: string; } @@ -21,11 +41,13 @@ const useHighAccuracy = (desiredAccuracy?: string) => ( ); class Navigator { - public static async getCurrentPosition(overrides: PositionOptionOverrides = {}): Promise