From 1cffa21daa07cced92b8057be03532538c102b87 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 08:12:49 +0000 Subject: [PATCH] style: format code with Prettier and StandardJS This commit fixes the style issues introduced in 4c3fba1 according to the output from Prettier and StandardJS. Details: None --- CHANGELOG.md | 2 +- README.md | 2 +- js/index.js | 598 +++++++++++++++++++++++++-------------------------- js/index.ts | 100 ++++----- 4 files changed, 344 insertions(+), 358 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efb17de..dd9119d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -346,4 +346,4 @@ Added: ## 0.1.22-beta.2 - Updated the Roam SDK to the latest version. -- Fixed the offline trips issue. \ No newline at end of file +- Fixed the offline trips issue. diff --git a/README.md b/README.md index 959f77f..428ee48 100755 --- a/README.md +++ b/README.md @@ -590,4 +590,4 @@ Please visit our [Developer Center](https://github.com/geosparks/roam-reactnativ ## Need Help? -If you have any problems or issues over our SDK, feel free to create a github issue or submit a request on [Roam Help](https://geosparkai.atlassian.net/servicedesk/customer/portal/2). \ No newline at end of file +If you have any problems or issues over our SDK, feel free to create a github issue or submit a request on [Roam Help](https://geosparkai.atlassian.net/servicedesk/customer/portal/2). diff --git a/js/index.js b/js/index.js index a4882b5..c2f29fd 100755 --- a/js/index.js +++ b/js/index.js @@ -1,116 +1,116 @@ -import { NativeEventEmitter, NativeModules, Platform } from 'react-native' +import { NativeEventEmitter, NativeModules, Platform } from "react-native"; if (!NativeModules.RNRoam) { - throw new Error('NativeModules.RNRoam is undefined') + throw new Error("NativeModules.RNRoam is undefined"); } -const eventEmitter = new NativeEventEmitter(NativeModules.RNRoam) +const eventEmitter = new NativeEventEmitter(NativeModules.RNRoam); const TrackingMode = { - ACTIVE: 'ACTIVE', - BALANCED: 'BALANCED', - PASSIVE: 'PASSIVE', - CUSTOM: 'CUSTOM' -} + ACTIVE: "ACTIVE", + BALANCED: "BALANCED", + PASSIVE: "PASSIVE", + CUSTOM: "CUSTOM", +}; const DesiredAccuracy = { - HIGH: 'HIGH', - MEDIUM: 'MEDIUM', - LOW: 'LOW' -} + HIGH: "HIGH", + MEDIUM: "MEDIUM", + LOW: "LOW", +}; const NetworkState = { - BOTH: 'BOTH', - ONLINE: 'ONLINE', - OFFLINE: 'OFFLINE' -} + BOTH: "BOTH", + ONLINE: "ONLINE", + OFFLINE: "OFFLINE", +}; const AppState = { - ALWAYS_ON: 'ALWAYS_ON', - FOREGROUND: 'FOREGROUND', - BACKGROUND: 'BACKGROUND' -} + ALWAYS_ON: "ALWAYS_ON", + FOREGROUND: "FOREGROUND", + BACKGROUND: "BACKGROUND", +}; const Source = { - ALL: 'ALL', - LAST_KNOWN: 'LAST_KNOWN', - GPS: 'GPS' -} + ALL: "ALL", + LAST_KNOWN: "LAST_KNOWN", + GPS: "GPS", +}; const DesiredAccuracyIOS = { - BESTFORNAVIGATION: 'BESTFORNAVIGATION', - BEST: 'BEST', - NEAREST_TEN_METERS: 'NEAREST_TEN_METERS', - HUNDRED_METERS: 'HUNDRED_METERS', - KILO_METERS: 'KILO_METERS', - THREE_KILOMETERS: 'THREE_KILOMETERS' -} + BESTFORNAVIGATION: "BESTFORNAVIGATION", + BEST: "BEST", + NEAREST_TEN_METERS: "NEAREST_TEN_METERS", + HUNDRED_METERS: "HUNDRED_METERS", + KILO_METERS: "KILO_METERS", + THREE_KILOMETERS: "THREE_KILOMETERS", +}; const ActivityType = { - OTHER: 'OTHER', - AUTO_NAVIGATION: 'AUTO_NAVIGATION', - OTHER_NAVIGATION: 'OTHER_NAVIGATION', - FITNESS: 'FITNESS' -} + OTHER: "OTHER", + AUTO_NAVIGATION: "AUTO_NAVIGATION", + OTHER_NAVIGATION: "OTHER_NAVIGATION", + FITNESS: "FITNESS", +}; const SubscribeListener = { - EVENTS: 'EVENTS', - LOCATION: 'LOCATION', - BOTH: 'BOTH' -} + EVENTS: "EVENTS", + LOCATION: "LOCATION", + BOTH: "BOTH", +}; const Publish = { - APP_ID: 'APP_ID', - USER_ID: 'USER_ID', - GEOFENCE_EVENTS: 'GEOFENCE_EVENTS', - LOCATION_EVENTS: 'LOCATION_EVENTS', - NEARBY_EVENTS: 'NEARBY_EVENTS', - TRIPS_EVENTS: 'TRIPS_EVENTS', - LOCATION_LISTENER: 'LOCATION_LISTENER', - EVENT_LISTENER: 'EVENT_LISTENER', - ALTITUDE: 'ALTITUDE', - COURSE: 'COURSE', - SPEED: 'SPEED', - VERTICAL_ACCURACY: 'VERTICAL_ACCURACY', - HORIZONTAL_ACCURACY: 'HORIZONTAL_ACCURACY', - APP_CONTEXT: 'APP_CONTEXT', - ALLOW_MOCKED: 'ALLOW_MOCKED', - BATTERY_REMAINING: 'BATTERY_REMAINING', - BATTERY_SAVER: 'BATTERY_SAVER', - BATTERY_STATUS: 'BATTERY_STATUS', - ACTIVITY: 'ACTIVITY', - AIRPLANE_MODE: 'AIRPLANE_MODE', - DEVICE_MANUFACTURE: 'DEVICE_MANUFACTURE', - DEVICE_MODEL: 'DEVICE_MODEL', - TRACKING_MODE: 'TRACKING_MODE', - LOCATIONPERMISSION: 'LOCATIONPERMISSION', - NETWORK_STATUS: 'NETWORK_STATUS', - GPS_STATUS: 'GPS_STATUS', - OS_VERSION: 'OS_VERSION', - RECORDERD_AT: 'RECORDERD_AT', - TZ_OFFSET: 'TZ_OFFSET' -} + APP_ID: "APP_ID", + USER_ID: "USER_ID", + GEOFENCE_EVENTS: "GEOFENCE_EVENTS", + LOCATION_EVENTS: "LOCATION_EVENTS", + NEARBY_EVENTS: "NEARBY_EVENTS", + TRIPS_EVENTS: "TRIPS_EVENTS", + LOCATION_LISTENER: "LOCATION_LISTENER", + EVENT_LISTENER: "EVENT_LISTENER", + ALTITUDE: "ALTITUDE", + COURSE: "COURSE", + SPEED: "SPEED", + VERTICAL_ACCURACY: "VERTICAL_ACCURACY", + HORIZONTAL_ACCURACY: "HORIZONTAL_ACCURACY", + APP_CONTEXT: "APP_CONTEXT", + ALLOW_MOCKED: "ALLOW_MOCKED", + BATTERY_REMAINING: "BATTERY_REMAINING", + BATTERY_SAVER: "BATTERY_SAVER", + BATTERY_STATUS: "BATTERY_STATUS", + ACTIVITY: "ACTIVITY", + AIRPLANE_MODE: "AIRPLANE_MODE", + DEVICE_MANUFACTURE: "DEVICE_MANUFACTURE", + DEVICE_MODEL: "DEVICE_MODEL", + TRACKING_MODE: "TRACKING_MODE", + LOCATIONPERMISSION: "LOCATIONPERMISSION", + NETWORK_STATUS: "NETWORK_STATUS", + GPS_STATUS: "GPS_STATUS", + OS_VERSION: "OS_VERSION", + RECORDERD_AT: "RECORDERD_AT", + TZ_OFFSET: "TZ_OFFSET", +}; const createUser = (description, successCallback, errorCallback) => { NativeModules.RNRoam.createUser( description, null, successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const getUser = (userid, successCallback, errorCallback) => { - NativeModules.RNRoam.getUser(userid, successCallback, errorCallback) -} + NativeModules.RNRoam.getUser(userid, successCallback, errorCallback); +}; const setDescription = (description) => { - if (Platform.OS === 'android') { - NativeModules.RNRoam.setDescription(description) + if (Platform.OS === "android") { + NativeModules.RNRoam.setDescription(description); } else { - NativeModules.RNRoam.setDescription(description, null) + NativeModules.RNRoam.setDescription(description, null); } -} +}; const toggleEvents = ( geofence, @@ -118,7 +118,7 @@ const toggleEvents = ( location, movingGeofence, successCallback, - errorCallback + errorCallback, ) => { NativeModules.RNRoam.toggleEvents( geofence, @@ -126,113 +126,111 @@ const toggleEvents = ( location, movingGeofence, successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const toggleListener = (location, event, successCallback, errorCallback) => { NativeModules.RNRoam.toggleListener( location, event, successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const getEventsStatus = (successCallback, errorCallback) => { - NativeModules.RNRoam.getEventsStatus(successCallback, errorCallback) -} + NativeModules.RNRoam.getEventsStatus(successCallback, errorCallback); +}; const getListenerStatus = (successCallback, errorCallback) => { - NativeModules.RNRoam.getListenerStatus(successCallback, errorCallback) -} + NativeModules.RNRoam.getListenerStatus(successCallback, errorCallback); +}; const subscribe = (type, userid) => { - NativeModules.RNRoam.subscribe(type, userid) -} + NativeModules.RNRoam.subscribe(type, userid); +}; const unSubscribe = (type, userid) => { - NativeModules.RNRoam.unSubscribe(type, userid) -} + NativeModules.RNRoam.unSubscribe(type, userid); +}; const disableBatteryOptimization = () => { - NativeModules.RNRoam.disableBatteryOptimization() -} + NativeModules.RNRoam.disableBatteryOptimization(); +}; const isBatteryOptimizationEnabled = (callback) => { - NativeModules.RNRoam.isBatteryOptimizationEnabled(callback) -} + NativeModules.RNRoam.isBatteryOptimizationEnabled(callback); +}; const checkLocationPermission = (callback) => { - NativeModules.RNRoam.checkLocationPermission(callback) -} + NativeModules.RNRoam.checkLocationPermission(callback); +}; const checkLocationServices = (callback) => { - NativeModules.RNRoam.checkLocationServices(callback) -} + NativeModules.RNRoam.checkLocationServices(callback); +}; const checkBackgroundLocationPermission = (callback) => { - NativeModules.RNRoam.checkBackgroundLocationPermission(callback) -} + NativeModules.RNRoam.checkBackgroundLocationPermission(callback); +}; const locationPermissionStatus = (callback) => { - NativeModules.RNRoam.locationPermissionStatus(callback) -} + NativeModules.RNRoam.locationPermissionStatus(callback); +}; const requestLocationPermission = () => { - NativeModules.RNRoam.requestLocationPermission() -} - - + NativeModules.RNRoam.requestLocationPermission(); +}; const requestPhoneStatePermission = () => { - NativeModules.RNRoam.requestPhoneStatePermission() -} + NativeModules.RNRoam.requestPhoneStatePermission(); +}; const requestLocationServices = () => { - NativeModules.RNRoam.requestLocationServices() -} + NativeModules.RNRoam.requestLocationServices(); +}; const requestBackgroundLocationPermission = () => { - NativeModules.RNRoam.requestBackgroundLocationPermission() -} + NativeModules.RNRoam.requestBackgroundLocationPermission(); +}; // -------- Trips V2 ---------- class RoamTrip { - constructor (metadata, description, name, stops, isLocal, tripId, userId) { - this.metadata = metadata - this.description = description - this.name = name - this.stops = stops - this.isLocal = isLocal - this.tripId = tripId - this.userId = userId + constructor(metadata, description, name, stops, isLocal, tripId, userId) { + this.metadata = metadata; + this.description = description; + this.name = name; + this.stops = stops; + this.isLocal = isLocal; + this.tripId = tripId; + this.userId = userId; } } class RoamTripStop { - constructor ( + constructor( id, metadata, description, name, address, geometryRadius, - geometry + geometry, ) { - this.id = id - this.metadata = metadata - this.description = description - this.name = name - this.address = address - this.geometryRadius = geometryRadius - this.geometry = geometry + this.id = id; + this.metadata = metadata; + this.description = description; + this.name = name; + this.address = address; + this.geometryRadius = geometryRadius; + this.geometry = geometry; } } class RoamCustomTrackingOptions { - constructor ( + constructor( desiredAccuracy, updateInterval, distanceFilter, @@ -242,25 +240,25 @@ class RoamCustomTrackingOptions { allowBackgroundLocationUpdates, pausesLocationUpdatesAutomatically, showsBackgroundLocationIndicator, - accuracyFilter + accuracyFilter, ) { - this.desiredAccuracy = desiredAccuracy - this.updateInterval = updateInterval - this.distanceFilter = distanceFilter - this.stopDuration = stopDuration - this.activityType = activityType - this.desiredAccuracyIOS = desiredAccuracyIOS - this.allowBackgroundLocationUpdates = allowBackgroundLocationUpdates + this.desiredAccuracy = desiredAccuracy; + this.updateInterval = updateInterval; + this.distanceFilter = distanceFilter; + this.stopDuration = stopDuration; + this.activityType = activityType; + this.desiredAccuracyIOS = desiredAccuracyIOS; + this.allowBackgroundLocationUpdates = allowBackgroundLocationUpdates; this.pausesLocationUpdatesAutomatically = - pausesLocationUpdatesAutomatically - this.showsBackgroundLocationIndicator = showsBackgroundLocationIndicator - this.accuracyFilter = accuracyFilter + pausesLocationUpdatesAutomatically; + this.showsBackgroundLocationIndicator = showsBackgroundLocationIndicator; + this.accuracyFilter = accuracyFilter; } } -function roamCustomTrackingOptionsToMap (customOptions) { +function roamCustomTrackingOptionsToMap(customOptions) { if (customOptions === null) { - return null + return null; } const customMap = { desiredAccuracy: customOptions.desiredAccuracy, @@ -275,16 +273,16 @@ function roamCustomTrackingOptionsToMap (customOptions) { customOptions.pausesLocationUpdatesAutomatically, showsBackgroundLocationIndicator: customOptions.showsBackgroundLocationIndicator, - accuracyFilter: customOptions.accuracyFilter - } - return customMap + accuracyFilter: customOptions.accuracyFilter, + }; + return customMap; } -function roamTripStopsToMap (stop) { +function roamTripStopsToMap(stop) { if (stop === null) { - return null + return null; } - const stopsList = [] + const stopsList = []; for (let i = 0; i < stop.length; i++) { const stopMap = { RoamTripStop: stop[i].id, @@ -293,17 +291,17 @@ function roamTripStopsToMap (stop) { address: stop[i].address, geometryRadius: stop[i].geometryRadius, geometryCoordinates: stop[i].geometry, - metadata: stop[i].metadata - } - stopsList.push(stopMap) + metadata: stop[i].metadata, + }; + stopsList.push(stopMap); } - return stopsList + return stopsList; } -function roamTripToMap (roamTrip) { +function roamTripToMap(roamTrip) { if (roamTrip === null) { - return null + return null; } const roamTripMap = { @@ -313,101 +311,101 @@ function roamTripToMap (roamTrip) { metadata: roamTrip.metadata, isLocal: roamTrip.isLocal, stops: roamTripStopsToMap(roamTrip.stops), - userId: roamTrip.userId - } - return roamTripMap + userId: roamTrip.userId, + }; + return roamTripMap; } const createTrip = (roamTrip, successCallback, errorCallback) => { NativeModules.RNRoam.createTrip( roamTripToMap(roamTrip), successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const startQuickTrip = ( roamTrip, trackingMode, customTrackingOption, successCallback, - errorCallback + errorCallback, ) => { NativeModules.RNRoam.startQuickTrip( roamTripToMap(roamTrip), trackingMode, roamCustomTrackingOptionsToMap(customTrackingOption), successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const startTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.startTrip(tripId, successCallback, errorCallback) -} + NativeModules.RNRoam.startTrip(tripId, successCallback, errorCallback); +}; const updateTrip = (roamTrip, successCallback, errorCallback) => { NativeModules.RNRoam.updateTrip( roamTripToMap(roamTrip), successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const endTrip = (tripId, forceStopTracking, successCallback, errorCallback) => { NativeModules.RNRoam.endTrip( tripId, forceStopTracking, successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const pauseTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.pauseTrip(tripId, successCallback, errorCallback) -} + NativeModules.RNRoam.pauseTrip(tripId, successCallback, errorCallback); +}; const resumeTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.resumeTrip(tripId, successCallback, errorCallback) -} + NativeModules.RNRoam.resumeTrip(tripId, successCallback, errorCallback); +}; const syncTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.syncTrip(tripId, successCallback, errorCallback) -} + NativeModules.RNRoam.syncTrip(tripId, successCallback, errorCallback); +}; const getTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.getTrip(tripId, successCallback, errorCallback) -} + NativeModules.RNRoam.getTrip(tripId, successCallback, errorCallback); +}; const getActiveTrips = (isLocal, successCallback, errorCallback) => { - NativeModules.RNRoam.getActiveTrips(isLocal, successCallback, errorCallback) -} + NativeModules.RNRoam.getActiveTrips(isLocal, successCallback, errorCallback); +}; const getTripSummary = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback) -} + NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback); +}; const subscribeTrip = (tripId) => { - NativeModules.RNRoam.subscribeTripStatus(tripId) -} + NativeModules.RNRoam.subscribeTripStatus(tripId); +}; const unSubscribeTrip = (tripId) => { - NativeModules.RNRoam.unSubscribeTripStatus(tripId) -} + NativeModules.RNRoam.unSubscribeTripStatus(tripId); +}; const deleteTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.deleteTrip(tripId, successCallback, errorCallback) -} + NativeModules.RNRoam.deleteTrip(tripId, successCallback, errorCallback); +}; // -------- END ------------ const publishOnly = (array, jsonMetadata) => { - NativeModules.RNRoam.publishOnly(array, jsonMetadata) -} + NativeModules.RNRoam.publishOnly(array, jsonMetadata); +}; const publishAndSave = (jsonMetadata) => { - NativeModules.RNRoam.publishAndSave(jsonMetadata) -} + NativeModules.RNRoam.publishAndSave(jsonMetadata); +}; const batchProcess = (enable, syncHour) => { // console.log('batchProcess called with: --> 1', { enable, syncHour }); @@ -415,19 +413,16 @@ const batchProcess = (enable, syncHour) => { NativeModules.RNRoam.batchProcess(enable, syncHour); }; - const stopPublishing = () => { - NativeModules.RNRoam.stopPublishing() -} + NativeModules.RNRoam.stopPublishing(); +}; // IOS const createGeofence = (geofence) => { - NativeModules.RNRoam.createGeofence(geofence); }; - // Android // const createGeofence = (geofence) => { @@ -436,17 +431,15 @@ const createGeofence = (geofence) => { // NativeModules.RNRoam.createGeofence(); // } - - // const getAllGeofences = (geofences) => { // NativeModules.RNRoam.getAllGeofences((error, geofences) => { // if (error) { // console.error("Error fetching geofences:", error); // return; // } - + // console.log(`Geofences count: ${geofences.length}`); - + // geofences.forEach((geofence) => { // if (geofence.type === "Circular") { // console.log(`Circular Geofence - Radius: ${geofence.radius}`); @@ -457,10 +450,9 @@ const createGeofence = (geofence) => { // }); // })} - const startTracking = (trackingMode) => { - NativeModules.RNRoam.startTracking(trackingMode) -} + NativeModules.RNRoam.startTracking(trackingMode); +}; const startTrackingCustom = ( allowBackground, @@ -470,7 +462,7 @@ const startTrackingCustom = ( showBackIndicator, distanceFilter, accuracyFilter, - updateInterval + updateInterval, ) => { NativeModules.RNRoam.startTrackingCustom( allowBackground, @@ -480,9 +472,9 @@ const startTrackingCustom = ( showBackIndicator, distanceFilter, accuracyFilter, - updateInterval - ) -} + updateInterval, + ); +}; const startSelfTrackingCustom = ( allowBackground, @@ -492,7 +484,7 @@ const startSelfTrackingCustom = ( showBackIndicator, distanceFilter, accuracyFilter, - updateInterval + updateInterval, ) => { NativeModules.RNRoam.startSelfTrackingCustom( allowBackground, @@ -502,33 +494,33 @@ const startSelfTrackingCustom = ( showBackIndicator, distanceFilter, accuracyFilter, - updateInterval - ) -} + updateInterval, + ); +}; const startTrackingTimeInterval = (timeInterval, desiredAccuracy) => { - NativeModules.RNRoam.startTrackingTimeInterval(timeInterval, desiredAccuracy) -} + NativeModules.RNRoam.startTrackingTimeInterval(timeInterval, desiredAccuracy); +}; const startTrackingDistanceInterval = ( distance, stationary, - desiredAccuracy + desiredAccuracy, ) => { NativeModules.RNRoam.startTrackingDistanceInterval( distance, stationary, - desiredAccuracy - ) -} + desiredAccuracy, + ); +}; const stopTracking = () => { - NativeModules.RNRoam.stopTracking() -} + NativeModules.RNRoam.stopTracking(); +}; const isLocationTracking = (callback) => { - NativeModules.RNRoam.isLocationTracking(callback) -} + NativeModules.RNRoam.isLocationTracking(callback); +}; const setForegroundNotification = ( enabled, @@ -536,7 +528,7 @@ const setForegroundNotification = ( description, image, activity, - roamService + roamService, ) => { NativeModules.RNRoam.setForegroundNotification( enabled, @@ -544,137 +536,137 @@ const setForegroundNotification = ( description, image, activity, - roamService - ) -} + roamService, + ); +}; const allowMockLocation = (enabled) => { - NativeModules.RNRoam.allowMockLocation(enabled) -} + NativeModules.RNRoam.allowMockLocation(enabled); +}; const getCurrentLocationListener = (accuracy) => { - NativeModules.RNRoam.getCurrentLocationListener(accuracy) -} + NativeModules.RNRoam.getCurrentLocationListener(accuracy); +}; const getCurrentLocation = ( desiredAccuracy, accuracy, successCallback, - errorCallback + errorCallback, ) => { NativeModules.RNRoam.getCurrentLocation( desiredAccuracy, accuracy, successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const updateCurrentLocation = (desiredAccuracy, accuracy) => { - NativeModules.RNRoam.updateCurrentLocation(desiredAccuracy, accuracy) -} + NativeModules.RNRoam.updateCurrentLocation(desiredAccuracy, accuracy); +}; const getCurrentLocationIos = (accuracy, successCallback, errorCallback) => { NativeModules.RNRoam.getCurrentLocationIos( accuracy, successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const updateCurrentLocationIos = (accuracy) => { - NativeModules.RNRoam.updateCurrentLocationIos(accuracy) -} + NativeModules.RNRoam.updateCurrentLocationIos(accuracy); +}; const updateLocationWhenStationary = (interval) => { - NativeModules.RNRoam.updateLocationWhenStationary(interval) -} + NativeModules.RNRoam.updateLocationWhenStationary(interval); +}; const logout = (successCallback, errorCallback) => { - NativeModules.RNRoam.logout(successCallback, errorCallback) -} + NativeModules.RNRoam.logout(successCallback, errorCallback); +}; const setTrackingInAppState = (appState) => { - NativeModules.RNRoam.setTrackingInAppState(appState) -} + NativeModules.RNRoam.setTrackingInAppState(appState); +}; const offlineLocationTracking = (enabled) => { - NativeModules.RNRoam.offlineLocationTracking(enabled) -} + NativeModules.RNRoam.offlineLocationTracking(enabled); +}; const startSelfTracking = (trackingMode) => { - NativeModules.RNRoam.startSelfTracking(trackingMode) -} + NativeModules.RNRoam.startSelfTracking(trackingMode); +}; const startSelfTrackingTimeInterval = (timeInterval, desiredAccuracy) => { NativeModules.RNRoam.startSelfTrackingTimeInterval( timeInterval, - desiredAccuracy - ) -} + desiredAccuracy, + ); +}; const startSelfTrackingDistanceInterval = ( distance, stationary, - desiredAccuracy + desiredAccuracy, ) => { NativeModules.RNRoam.startSelfTrackingDistanceInterval( distance, stationary, - desiredAccuracy - ) -} + desiredAccuracy, + ); +}; const stopSelfTracking = () => { - NativeModules.RNRoam.stopSelfTracking() -} + NativeModules.RNRoam.stopSelfTracking(); +}; const enableAccuracyEngine = (accuracy) => { - if (Platform.OS === 'ios') { - NativeModules.RNRoam.enableAccuracyEngine() + if (Platform.OS === "ios") { + NativeModules.RNRoam.enableAccuracyEngine(); } else { if (accuracy === null || accuracy === undefined) { - NativeModules.RNRoam.enableAccuracyEngine(50) + NativeModules.RNRoam.enableAccuracyEngine(50); } else { - NativeModules.RNRoam.enableAccuracyEngine(accuracy) + NativeModules.RNRoam.enableAccuracyEngine(accuracy); } } -} +}; const disableAccuracyEngine = () => { - NativeModules.RNRoam.disableAccuracyEngine() -} + NativeModules.RNRoam.disableAccuracyEngine(); +}; const startListener = (event, callback) => - eventEmitter.addListener(event, callback) + eventEmitter.addListener(event, callback); const stopListener = (event) => { - eventEmitter.removeAllListeners(event) -} + eventEmitter.removeAllListeners(event); +}; const setBatchReceiverConfig = ( networkState, batchCount, batchWindow, successCallback, - errorCallback + errorCallback, ) => { NativeModules.RNRoam.setBatchReceiverConfig( networkState, batchCount, batchWindow, successCallback, - errorCallback - ) -} + errorCallback, + ); +}; const getBatchReceiverConfig = (successCallback, errorCallback) => { - NativeModules.RNRoam.getBatchReceiverConfig(successCallback, errorCallback) -} + NativeModules.RNRoam.getBatchReceiverConfig(successCallback, errorCallback); +}; const resetBatchReceiverConfig = (successCallback, errorCallback) => { - NativeModules.RNRoam.resetBatchReceiverConfig(successCallback, errorCallback) -} + NativeModules.RNRoam.resetBatchReceiverConfig(successCallback, errorCallback); +}; const setTrackingConfig = ( accuracy, @@ -682,43 +674,43 @@ const setTrackingConfig = ( source, discardLocation, successCallback, - errorCallback + errorCallback, ) => { - if (Platform.OS === 'android') { + if (Platform.OS === "android") { NativeModules.RNRoam.setTrackingConfig( accuracy, timeout, source, discardLocation, successCallback, - errorCallback - ) + errorCallback, + ); } else { NativeModules.RNRoam.setTrackingConfig( accuracy, timeout, discardLocation, successCallback, - errorCallback - ) + errorCallback, + ); } -} +}; const getTrackingConfig = (successCallback, errorCallback) => { - NativeModules.RNRoam.getTrackingConfig(successCallback, errorCallback) -} + NativeModules.RNRoam.getTrackingConfig(successCallback, errorCallback); +}; const resetTrackingConfig = (successCallback, errorCallback) => { - NativeModules.RNRoam.resetTrackingConfig(successCallback, errorCallback) -} + NativeModules.RNRoam.resetTrackingConfig(successCallback, errorCallback); +}; const checkActivityPermission = (callback) => { - NativeModules.RNRoam.checkActivityPermission(callback) -} + NativeModules.RNRoam.checkActivityPermission(callback); +}; const requestActivityPermission = () => { - NativeModules.RNRoam.requestActivityPermission() -} + NativeModules.RNRoam.requestActivityPermission(); +}; const Roam = { TrackingMode, @@ -805,7 +797,7 @@ const Roam = { RoamTripStop, RoamCustomTrackingOptions, checkActivityPermission, - requestActivityPermission -} + requestActivityPermission, +}; -export default Roam +export default Roam; diff --git a/js/index.ts b/js/index.ts index d50c123..bc6f8f1 100755 --- a/js/index.ts +++ b/js/index.ts @@ -94,13 +94,13 @@ const Publish = { const createUser = ( description: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.createUser( description, null, successCallback, - errorCallback + errorCallback, ); }; @@ -122,7 +122,7 @@ const toggleEvents = ( location: any, movingGeofence: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.toggleEvents( geofence, @@ -130,7 +130,7 @@ const toggleEvents = ( location, movingGeofence, successCallback, - errorCallback + errorCallback, ); }; @@ -138,13 +138,13 @@ const toggleListener = ( location: any, event: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.toggleListener( location, event, successCallback, - errorCallback + errorCallback, ); }; @@ -192,7 +192,6 @@ const requestLocationPermission = () => { NativeModules.RNRoam.requestLocationPermission(); }; - const requestPhoneStatePermission = () => { NativeModules.RNRoam.requestPhoneStatePermission(); }; @@ -222,7 +221,7 @@ class RoamTrip { stops: any, isLocal: any, tripId: any, - userId: any + userId: any, ) { this.metadata = metadata; this.description = description; @@ -249,7 +248,7 @@ class RoamTripStop { name: any, address: any, geometryRadius: any, - geometry: any + geometry: any, ) { this.id = id; this.metadata = metadata; @@ -282,7 +281,7 @@ class RoamCustomTrackingOptions { allowBackgroundLocationUpdates: any, pausesLocationUpdatesAutomatically: any, showsBackgroundLocationIndicator: any, - accuracyFilter: any + accuracyFilter: any, ) { this.desiredAccuracy = desiredAccuracy; this.updateInterval = updateInterval; @@ -361,12 +360,12 @@ function roamTripToMap(roamTrip: any) { const createTrip = ( roamTrip: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.createTrip( roamTripToMap(roamTrip), successCallback, - errorCallback + errorCallback, ); }; @@ -375,14 +374,14 @@ const startQuickTrip = ( trackingMode: any, customTrackingOption: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.startQuickTrip( roamTripToMap(roamTrip), trackingMode, roamCustomTrackingOptionsToMap(customTrackingOption), successCallback, - errorCallback + errorCallback, ); }; @@ -393,12 +392,12 @@ const startTrip = (tripId: any, successCallback: any, errorCallback: any) => { const updateTrip = ( roamTrip: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.updateTrip( roamTripToMap(roamTrip), successCallback, - errorCallback + errorCallback, ); }; @@ -406,13 +405,13 @@ const endTrip = ( tripId: any, forceStopTracking: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.endTrip( tripId, forceStopTracking, successCallback, - errorCallback + errorCallback, ); }; @@ -435,7 +434,7 @@ const getTrip = (tripId: any, successCallback: any, errorCallback: any) => { const getActiveTrips = ( isLocal: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.getActiveTrips(isLocal, successCallback, errorCallback); }; @@ -443,7 +442,7 @@ const getActiveTrips = ( const getTripSummary = ( tripId: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback); }; @@ -466,9 +465,6 @@ const publishOnly = (array: any, jsonMetadata: any) => { NativeModules.RNRoam.publishOnly(array, jsonMetadata); }; - - - const publishAndSave = (jsonMetadata: any) => { NativeModules.RNRoam.publishAndSave(jsonMetadata); }; @@ -484,45 +480,43 @@ type RNRoamType = { const { RNRoam } = NativeModules as { RNRoam?: RNRoamType }; const batchProcess = (enable: boolean, syncHour: number): void => { - console.log('batchProcess called with:', { enable, syncHour }); + console.log("batchProcess called with:", { enable, syncHour }); if (RNRoam?.batchProcess) { try { RNRoam.batchProcess(enable, syncHour); - console.log('batchProcess executed successfully.'); + console.log("batchProcess executed successfully."); } catch (error) { - console.error('Error executing batchProcess:', error); + console.error("Error executing batchProcess:", error); } } else { - console.warn('RNRoam module is not linked properly.'); + console.warn("RNRoam module is not linked properly."); } }; export const createGeofence = (geofence: { [key: string]: any }) => { if (NativeModules.RNRoam && NativeModules.RNRoam.createGeofence) { NativeModules.RNRoam.createGeofence(geofence) .then((response: any) => { - console.log('Geofence created:', response); + console.log("Geofence created:", response); }) .catch((error: any) => { - console.error('Error creating geofence:', error); + console.error("Error creating geofence:", error); }); } else { - console.error('createGeofence method is not available'); + console.error("createGeofence method is not available"); } }; // export const getAllGeofences = (geofences: "") => { // // Logic for fetching geofences // console.log('Fetching all geofences'); - + // // Ensure the correct argument is passed - a callback function // NativeModules.RNRoam.getAllGeofences((geofences: "") => { // console.log('Received geofences:', geofences); // }); // }; - - const startTracking = (trackingMode: any) => { NativeModules.RNRoam.startTracking(trackingMode); }; @@ -535,7 +529,7 @@ const startTrackingCustom = ( showBackIndicator: any, distanceFilter: any, accuracyFilter: any, - updateInterval: any + updateInterval: any, ) => { NativeModules.RNRoam.startTrackingCustom( allowBackground, @@ -545,7 +539,7 @@ const startTrackingCustom = ( showBackIndicator, distanceFilter, accuracyFilter, - updateInterval + updateInterval, ); }; @@ -557,7 +551,7 @@ const startSelfTrackingCustom = ( showBackIndicator: any, distanceFilter: any, accuracyFilter: any, - updateInterval: any + updateInterval: any, ) => { NativeModules.RNRoam.startSelfTrackingCustom( allowBackground, @@ -567,7 +561,7 @@ const startSelfTrackingCustom = ( showBackIndicator, distanceFilter, accuracyFilter, - updateInterval + updateInterval, ); }; @@ -578,12 +572,12 @@ const startTrackingTimeInterval = (timeInterval: any, desiredAccuracy: any) => { const startTrackingDistanceInterval = ( distance: any, stationary: any, - desiredAccuracy: any + desiredAccuracy: any, ) => { NativeModules.RNRoam.startTrackingDistanceInterval( distance, stationary, - desiredAccuracy + desiredAccuracy, ); }; @@ -601,7 +595,7 @@ const setForegroundNotification = ( description: any, image: any, activity: any, - roamService: any + roamService: any, ) => { NativeModules.RNRoam.setForegroundNotification( enabled, @@ -609,7 +603,7 @@ const setForegroundNotification = ( description, image, activity, - roamService + roamService, ); }; @@ -625,13 +619,13 @@ const getCurrentLocation = ( desiredAccuracy: any, accuracy: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.getCurrentLocation( desiredAccuracy, accuracy, successCallback, - errorCallback + errorCallback, ); }; @@ -642,12 +636,12 @@ const updateCurrentLocation = (desiredAccuracy: any, accuracy: any) => { const getCurrentLocationIos = ( accuracy: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.getCurrentLocationIos( accuracy, successCallback, - errorCallback + errorCallback, ); }; @@ -677,23 +671,23 @@ const startSelfTracking = (trackingMode: any) => { const startSelfTrackingTimeInterval = ( timeInterval: any, - desiredAccuracy: any + desiredAccuracy: any, ) => { NativeModules.RNRoam.startSelfTrackingTimeInterval( timeInterval, - desiredAccuracy + desiredAccuracy, ); }; const startSelfTrackingDistanceInterval = ( distance: any, stationary: any, - desiredAccuracy: any + desiredAccuracy: any, ) => { NativeModules.RNRoam.startSelfTrackingDistanceInterval( distance, stationary, - desiredAccuracy + desiredAccuracy, ); }; @@ -729,14 +723,14 @@ const setBatchReceiverConfig = ( batchCount: any, batchWindow: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.setBatchReceiverConfig( networkState, batchCount, batchWindow, successCallback, - errorCallback + errorCallback, ); }; @@ -754,7 +748,7 @@ const setTrackingConfig = ( source: any, discardLocation: any, successCallback: any, - errorCallback: any + errorCallback: any, ) => { NativeModules.RNRoam.setTrackingConfig( accuracy, @@ -762,7 +756,7 @@ const setTrackingConfig = ( source, discardLocation, successCallback, - errorCallback + errorCallback, ); };