diff --git a/.vscode/settings.json b/.vscode/settings.json index 7709bc6..c56a2f6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "jira-plugin.workingProject": "" -} \ No newline at end of file + "jira-plugin.workingProject": "" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa8f8f..b136080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,10 +60,9 @@ - Updated to latest native Roam SDK versions. Android v0.0.11 and iOS v0.0.13 - ## 0.0.15 -- Updated to latest iOS native SDK version v0.0.14 which improves `the Roam.getCurrentLocation()` to return location faster. +- Updated to latest iOS native SDK version v0.0.14 which improves `the Roam.getCurrentLocation()` to return location faster. ## 0.0.16 @@ -71,7 +70,7 @@ ## 0.0.17 -- Fixed `Roam.setForegroundNotification()` to accept the custom icons. +- Fixed `Roam.setForegroundNotification()` to accept the custom icons. ## 0.0.18 @@ -91,21 +90,21 @@ ## 0.0.21 -- Added new method for `Roam.updateLocationWhenStationary(interval)` which updates location on given interval value in seconds. +- Added new method for `Roam.updateLocationWhenStationary(interval)` which updates location on given interval value in seconds. ## 0.0.22 -- Updated to latest native Roam SDK versions. Android v0.0.17 and iOS v0.0.17. +- Updated to latest native Roam SDK versions. Android v0.0.17 and iOS v0.0.17. - Fixed crashes for `endTrip`, `pauseTrip`, `resumeTrip` and `forceEndTrip` in iOS bridge. ## 0.0.23 -- Updated to latest native Roam SDK version. iOS v0.0.18. +- Updated to latest native Roam SDK version. iOS v0.0.18. - Fixed the coordinates arrangement for `Roam.getTripSummary()` on local trips. ## 0.0.24 -- Updated to latest native Roam SDK versions. Android v0.0.19 and iOS v0.0.19. +- Updated to latest native Roam SDK versions. Android v0.0.19 and iOS v0.0.19. - Modified updateCurrentLocation method to support metadata as null. - Updated location noise filter to remove inaccurate locations. - Added individual distance, duration, and elevation gain for location data inside trip routes for local trips. @@ -114,47 +113,54 @@ ## 0.0.25 -- Updated to latest native Roam SDK versions - iOS v0.0.20. +- Updated to latest native Roam SDK versions - iOS v0.0.20. - Fixed calculation for distance and duration for individual location data in trip summary route. ## 0.0.26 Added: + - Added new methods for batch configurations in location receiver. Modified: + - Location data in location receiver is changed from single location object to list of location updates. Fixed: + - Trip error changed for few error scenarios to success callbacks. - - Trip Already Started - - Trip Already Ended + - Trip Already Started + - Trip Already Ended ## 0.0.27 Modified: + - Added callbacks to `Roam.resetBatchReceiverConfig()` method to return default config values. -Fixed: + Fixed: - Fixed callback response for `Roam.getBatchReceiverConfig()` and `Roam.setBatchReceiverConfig()` methods. ## 0.0.28 Fixed: + - Fixed the method `Roam.resetBatchReceiverConfig()`. - Autolinking for iOS. ## 0.0.29 Added: + - New listener for connectity change event with `Roam.startListener('connectivityChangeEvent', connectivityChangeEvent)` -- Updated to latest native Roam SDK versions - Android v0.0.22. +- Updated to latest native Roam SDK versions - Android v0.0.22. ## 0.0.30 Added: + - Fixed location receiver when device restarted (Android). - Added option to restart Roam Service with `Roam.setForegroundNotification()` method. -- Updated to latest native Roam SDK version - Android v0.0.23. +- Updated to latest native Roam SDK version - Android v0.0.23. ## 0.0.31 @@ -163,12 +169,14 @@ Added: ## 0.0.32 Fixed: + - `Roam.enableAccuracyEngine(int)` method to accept integer value. - Autolinking for iOS. ## 0.0.33 Added: + - Added batch config for "trip_status" listener ## 0.0.34 diff --git a/MIGRATION.md b/MIGRATION.md index 0dc3b66..b298ea5 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -7,4 +7,4 @@ ## Roam 0.0.29 to Roam 0.0.30 - Trip data in trip receiver is changed from single trip object to list of trip updates for Android only. -- New parameter added to `Roam.setForegroundNotification()` method. \ No newline at end of file +- New parameter added to `Roam.setForegroundNotification()` method. diff --git a/README.md b/README.md index 44b7d96..899a9a9 100755 --- a/README.md +++ b/README.md @@ -9,21 +9,22 @@ [![Npm Publish](https://github.com/geosparks/roam-reactnative/actions/workflows/main.yml/badge.svg?branch=0.0.1)](https://github.com/geosparks/roam-reactnative/actions/workflows/main.yml) # Official Roam React Native SDK -This is the official [Roam](https://roam.ai) iOS SDK developed and maintained by Roam B.V -Note: Before you get started [signup to our dashboard](https://roam.ai/dashboard/signup) to get your API Keys. +This is the official [Roam](https://roam.ai) iOS SDK developed and maintained by Roam B.V +Note: Before you get started [signup to our dashboard](https://roam.ai/dashboard/signup) to get your API Keys. ## Featured Apps - # Quick Start + The Roam React Native SDK makes it quick and easy to build a location tracker for your React Native app. We provide powerful and customizable tracking modes and features that can be used to collect your users location updates. ### Requirements + To use the Roam SDK, the following things are required: Get yourself a free Roam Account. No credit card required. @@ -42,6 +43,7 @@ npm install --save roam-reactnative //yarn yarn add roam-reactnative ``` + If using React Native version of 0.60 or greater, autolinking is now done automatically so you can skip this step. ``` @@ -53,47 +55,51 @@ expo install roam-reactnative ``` Minimum supported versions + ``` react-native: 0.41.2 react: 15.4.2 ``` -Before making any changes to your javascript code, you would need to integrate and initialize Roam SDK in your Android and iOS applications. +Before making any changes to your javascript code, you would need to integrate and initialize Roam SDK in your Android and iOS applications. ### Android + 1. Add the following to the build script `{repositories {}}` section of the `build.gradle` (Project)file - ```java - mavenCentral() - ``` + ```java + mavenCentral() + ``` + 2. Install the SDK to your project via `Gradle` in Android Studio, add the maven below in your project `build.gradle` file. - ```java - repositories { - maven { - url 'https://com-roam-android.s3.amazonaws.com/' - } - } - ``` + ```java + repositories { + maven { + url 'https://com-roam-android.s3.amazonaws.com/' + } + } + ``` 3. Add the dependencies below in your `app build.gradle` file. Then sync Gradle. - ``` - dependencies { - implementation 'com.roam.sdk:roam-android:0.0.26' - } - ``` + ``` + dependencies { + implementation 'com.roam.sdk:roam-android:0.0.26' + } + ``` + 4. Before initializing the SDK, the below must be imported in your Main Activity. - ```java - import com.roam.sdk.Roam; - ``` + ```java + import com.roam.sdk.Roam; + ``` 5. After import, add the below code under the Application class `onCreate()` method. The SDK must be initialised before calling any of the other SDK methods. - ```java - Roam.initialize(this, "YOUR-SDK-KEY-GOES-HERE"); - ``` + ```java + Roam.initialize(this, "YOUR-SDK-KEY-GOES-HERE"); + ``` ### iOS @@ -108,28 +114,28 @@ Before making any changes to your javascript code, you would need to integrate a NSLocationAlwaysAndWhenInUseUsageDescription Add description for background location usage. iOS 11 and above ``` - + ![Screenshot 2021-06-25 at 8 40 46 PM](https://user-images.githubusercontent.com/19217956/123445597-aa8cf380-d5f5-11eb-9188-15ad742f11a8.png) 3. Next you need to enable`Background fetch` and` Location updates` under `Project Setting` > `Capabilities` > `Background Modes`. - + ![Screenshot 2021-06-25 at 8 38 24 PM](https://user-images.githubusercontent.com/19217956/123445386-74e80a80-d5f5-11eb-85d6-e06ef4300734.png) 4. Import Roam into your `AppDelegate` file. - ```objective-c - #import - ``` + ```objective-c + #import + ``` 5. Initialize the SDK in your `AppDelegate` class before calling any other Roam methods under this `application:didFinishLaunchingWithOptions:` - ```objective-c - - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - { - [Roam initialize:@"YOUR-PUBLISHABLE-KEY" :NULL :NULL]; - } - ``` - + ```objective-c + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions + { + [Roam initialize:@"YOUR-PUBLISHABLE-KEY" :NULL :NULL]; + } + ``` + ### Manual Linking 1. Open the iOS module files, located inside `node_modules/roam-reactnative/ios/`. @@ -143,22 +149,26 @@ Before making any changes to your javascript code, you would need to integrate a First, import the module. ```javascript -import Roam from 'roam-reactnative'; +import Roam from "roam-reactnative"; ``` ## Creating Users -Once the SDK is initialized, we need to *create* or *get a user* to start the tracking and use other methods. Every user created will have a unique Roam identifier which will be used later to login and access developer APIs. We can call it as Roam userId. + +Once the SDK is initialized, we need to _create_ or _get a user_ to start the tracking and use other methods. Every user created will have a unique Roam identifier which will be used later to login and access developer APIs. We can call it as Roam userId. ```javascript -Roam.createUser("SET-USER-DESCRIPTION-HERE", success => { - // do something on success -}, -error => { -// do something on error -}); +Roam.createUser( + "SET-USER-DESCRIPTION-HERE", + (success) => { + // do something on success + }, + (error) => { + // do something on error + } +); ``` -The option *user description* can be used to update your user information such as name, address or add an existing user ID. Make sure the information is encrypted if you are planning to save personal user information like email or phone number. +The option _user description_ can be used to update your user information such as name, address or add an existing user ID. Make sure the information is encrypted if you are planning to save personal user information like email or phone number. You can always set or update user descriptions later using the below code. @@ -169,17 +179,20 @@ Roam.setDescription("SET-USER-DESCRIPTION-HERE"); If you already have a Roam userID which you would like to reuse instead of creating a new user, use the below to get user session. ```javascript -Roam.getUser("ROAM-USER-ID", success => { -// do something on success -}, -error => { -// do something on error -}); +Roam.getUser( + "ROAM-USER-ID", + (success) => { + // do something on success + }, + (error) => { + // do something on error + } +); ``` ## Request Permissions -Get location permission from the App user on the device. Also check if the user has turned on location services for the device. +Get location permission from the App user on the device. Also check if the user has turned on location services for the device. ```javascript // Call this method to check Location Permission for Android & iOS @@ -206,12 +219,13 @@ In case of devices running above Anroid 10, you would need to get background loc ```javascript // Call this method to check background location permission for Android -Roam.checkBackgroundLocationPermission( status => { -// do something with status +Roam.checkBackgroundLocationPermission((status) => { + // do something with status }); // Call this method to request background location Permission for Android Roam.requestBackgroundLocationPermission(); ``` + ### SDK Configurations #### Accuracy Engine @@ -227,6 +241,7 @@ For Custom tracking mores, you can pass the desired accuracy values in integers ```javascript Roam.enableAccuracyEngine(50); ``` + To disable accuracy engine ```javascript @@ -235,7 +250,7 @@ Roam.disableAccuracyEngine(); #### Offline Location Tracking -To modify the offline location tracking configuration, which will enabled by default. +To modify the offline location tracking configuration, which will enabled by default. ```javascript Roam.offlineLocationTracking(true); @@ -243,7 +258,7 @@ Roam.offlineLocationTracking(true); #### Allow Mock Location Tracking -To allow mock location tracking during development, use the below code. This will be disabled by default. +To allow mock location tracking during development, use the below code. This will be disabled by default. ```javascript Roam.allowMockLocation(true); @@ -271,11 +286,11 @@ Roam has three default tracking modes along with a custom version. They differ b ```javascript // active tracking -Roam.startTracking('ACTIVE'); +Roam.startTracking("ACTIVE"); // balanced tracking -Roam.startTracking('BALANCED'); +Roam.startTracking("BALANCED"); // passive tracking -Roam.startTracking('PASSIVE'); +Roam.startTracking("PASSIVE"); ``` ### Custom Tracking Modes @@ -290,13 +305,17 @@ customize and build your own tracking modes. | Distance Interval | Meters | 1m ~ 2500m | | Time Interval | Seconds | 10s ~ 10800s | - **Android: Distance between location updates:** ```javascript //Update location based on distance between locations. -Roam.startTrackingDistanceInterval("DISTANCE IN METERS", "STATIONARY DURATION IN SECONDS", Roam.DesiredAccuracy.HIGH); +Roam.startTrackingDistanceInterval( + "DISTANCE IN METERS", + "STATIONARY DURATION IN SECONDS", + Roam.DesiredAccuracy.HIGH +); ``` + Here, the `DISTANCE IN METERS` refers to distance interval for location tracking and `STATIONARY DURATION IN SECONDS` refers to duration for which location update is determined as stationary. Below is the example for distance based tracking with distance interval as 10m and stationary duration as 2 minutes. @@ -310,8 +329,12 @@ Roam.startTrackingDistanceInterval(10, 120, Roam.DesiredAccuracy.HIGH); ```javascript //Update location based on time interval. -Roam.startTrackingTimeInterval("INTERVAL IN SECONDS", Roam.DesiredAccuracy.HIGH); +Roam.startTrackingTimeInterval( + "INTERVAL IN SECONDS", + Roam.DesiredAccuracy.HIGH +); ``` + Here, the `INTERVAL IN SECONDS` refers to time interval for location tracking. Below is the example for time based tracking with time interval as 10s. @@ -322,12 +345,21 @@ Roam.startTrackingTimeInterval(10, Roam.DesiredAccuracy.HIGH); ``` #### iOS + We have a single method for iOS which can perfrom both time and distance based tracking based on the input parameters. ```javascript // Update location on distance interval -Roam.startTrackingCustom(allowBackground,pauseAutomatic,activityType, - desiredAccuracy,showBackIndicator,distanceFilter,accuracyFilter, updateInterval); +Roam.startTrackingCustom( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval +); ``` **iOS: Distance between location updates:** @@ -338,53 +370,66 @@ Below is the example for distance based tracking with distance interval as 20 me ```javascript Roam.startTrackingCustom( - true, // allowBackground - false, // pauseAutomatic - Roam.ActivityType.FITNESS, // activityType - Roam.DesiredAccuracyIOS.BEST, // desiredAccuracy - true, // showBackIndicator - 20, // distanceFilter - 10, // accuracyFilter - 0, // updateInterval - ); + true, // allowBackground + false, // pauseAutomatic + Roam.ActivityType.FITNESS, // activityType + Roam.DesiredAccuracyIOS.BEST, // desiredAccuracy + true, // showBackIndicator + 20, // distanceFilter + 10, // accuracyFilter + 0 // updateInterval +); ``` **iOS: Time between location updates:** ```javascript // Update location on time interval -Roam.startTrackingCustom(allowBackground,pauseAutomatic,activityType, - desiredAccuracy,showBackIndicator,distanceFilter,accuracyFilter, updateInterval); +Roam.startTrackingCustom( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval +); ``` + Here, the `updateInterval` refers to time interval for location tracking which should be in seconds. To achieve time based tracking, the `distanceFilter` value should be 0. Below is the example for time based tracking with time interval as 120s. ```javascript Roam.startTrackingCustom( - true, // allowBackground - false, // pauseAutomatic - Roam.ActivityType.FITNESS, // activityType - Roam.DesiredAccuracyIOS.BEST, // desiredAccuracy - true, // showBackIndicator - 0, // distanceFilter - 10, // accuracyFilter - 120, // updateInterval - ); + true, // allowBackground + false, // pauseAutomatic + Roam.ActivityType.FITNESS, // activityType + Roam.DesiredAccuracyIOS.BEST, // desiredAccuracy + true, // showBackIndicator + 0, // distanceFilter + 10, // accuracyFilter + 120 // updateInterval +); ``` + ### Update Location When Stationary + By using this method updateLocationWhenStationary , location will update every x seconds when device goes to stationary state. Note: It will work on all tracking modes ie. active, passive, balance and distance based custom tracking except time based custom tracking. ```javascript -Roam.updateLocationWhenStationary(interval) +Roam.updateLocationWhenStationary(interval); ``` + For example, to update location every 60s when the user becomes stationary, use the below code. ```javascript -Roam.updateLocationWhenStationary(60) +Roam.updateLocationWhenStationary(60); ``` + ## Stop Tracking To stop the tracking use the below method. @@ -401,19 +446,23 @@ We will now have an option to send meta-data as a parameter along with location ```javascript Roam.publishAndSave(metadataJSON); ``` + Example + ```javascript //Metadata is not mandatory -let metadataJSON = {"METADATA": {"1": true, "2": true, "3":true}}; +let metadataJSON = { METADATA: { 1: true, 2: true, 3: true } }; Roam.publishAndSave(metadataJSON); -(optional) +optional; Roam.publishAndSave(null); ``` + ## Stop Publishing It will stop publishing the location data to other clients. -``` javascript + +```javascript Roam.stopPublishing(); ``` @@ -422,22 +471,25 @@ Roam.stopPublishing(); Now that you have enabled the location listener, use the below method to subscribe to your own or other user's location updates and events. ### Subscribe -``` javascript + +```javascript Roam.subscribe(TYPE, "USER-ID"); ``` -| **Type** | **Description** | -| --------------------------------| -------- | -| LOCATION | Subscribe to your own location (or) other user's location updates. | -| EVENTS | Subscribe to your own events. | -| BOTH | Subscribe to your own events and location (or) other user's location updates. | - +| **Type** | **Description** | +| -------- | ----------------------------------------------------------------------------- | +| LOCATION | Subscribe to your own location (or) other user's location updates. | +| EVENTS | Subscribe to your own events. | +| BOTH | Subscribe to your own events and location (or) other user's location updates. | ### UnSubscribe -``` javascript + +```javascript Roam.unSubscribe(TYPE, "USER-ID"); ``` + You can pass `user_id` as empty string to unsubscribe from all the users. + ## Listeners Now that the location tracking is set up, you can subscribe to locations and events and use the data locally on your device or send it directly to your own backend server. @@ -445,13 +497,18 @@ Now that the location tracking is set up, you can subscribe to locations and eve To do that, you need to set the location and event listener to `true` using the below method. By default the status will set to `false` and needs to be set to `true` in order to stream the location and events updates to the same device or other devices. ```javascript -Roam.toggleListener(true, true, success => { - // do something on success -}, -error => { -// do something on error -}); +Roam.toggleListener( + true, + true, + (success) => { + // do something on success + }, + (error) => { + // do something on error + } +); ``` + Once the listener toggles are set to true, to listen to location updates and events. Note: The location data received will be an array with either single or multiple location data. @@ -459,11 +516,12 @@ Note: The location data received will be an array with either single or multiple ```javascript Roam.startListener("location", (location) => { // do something on location received - console.log('Location', location); + console.log("Location", location); // Console Output: // [{"activity": "S", "location": {"accuracy": 22.686637856849305, "altitude": 288.10509490966797, "latitude": 10.356502722371895, "longitude": 78.00075886670541, "speed": -1}, "recordedAt": "2022-03-22T11:18:04.928Z", "timezone": "+0530", "userId": "6239b06506df1f5c1c375353"},{..}...] }); ``` + You can also configure batch setting for the location receiver. To set the batch configuration, you need to pass batch count and batch window. ```javascript @@ -479,41 +537,47 @@ error => { //error.message });); ``` -| **Type** | **Description** | -| --------------------------------| -------- | -| NETWORK_STATE | online (or) offline (or) both | -| BATCH_COUNT | Integer value from 1-1000. Default as 1 | -| BATCH_WINDOW | Integer value. Default as 0 | + +| **Type** | **Description** | +| ------------- | --------------------------------------- | +| NETWORK_STATE | online (or) offline (or) both | +| BATCH_COUNT | Integer value from 1-1000. Default as 1 | +| BATCH_WINDOW | Integer value. Default as 0 | You can get the current configured settings with the below code. ```javascript -Roam.getBatchReceiverConfig(success => { - // do something on success - //success.batchCount, - //success.batchWindow, - //success.networkState -}, -error => { -// do something on error -//error.code -//error.message -}); +Roam.getBatchReceiverConfig( + (success) => { + // do something on success + //success.batchCount, + //success.batchWindow, + //success.networkState + }, + (error) => { + // do something on error + //error.code + //error.message + } +); ``` + You can reset the batch configuration to default values with the below code. ```javascript -Roam.resetBatchReceiverConfig(success => { - // do something on success - //success.batchCount, - //success.batchWindow, - //success.networkState -}, -error => { -// do something on error -//error.code -//error.message -}); +Roam.resetBatchReceiverConfig( + (success) => { + // do something on success + //success.batchCount, + //success.batchWindow, + //success.networkState + }, + (error) => { + // do something on error + //error.code + //error.message + } +); ``` ## Documentation @@ -521,7 +585,9 @@ error => { Please visit our [Developer Center](https://github.com/geosparks/roam-reactnative/wiki) for instructions on other SDK methods. ## Contributing + - For developing the SDK, please visit our [CONTRIBUTING.md](https://github.com/geosparks/roam-reactnative/blob/master/CONTRIBUTING.md) to get started. ## 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). diff --git a/artifacts/index.js b/artifacts/index.js index 74f1bae..ce8e6ee 100644 --- a/artifacts/index.js +++ b/artifacts/index.js @@ -1,312 +1,405 @@ -import { NativeEventEmitter, NativeModules } from "react-native"; +import { NativeEventEmitter, NativeModules } 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", -}; + ACTIVE: 'ACTIVE', + BALANCED: 'BALANCED', + PASSIVE: 'PASSIVE' +} const DesiredAccuracy = { - HIGH: "HIGH", - MEDIUM: "MEDIUM", - LOW: "LOW", -}; + HIGH: 'HIGH', + MEDIUM: 'MEDIUM', + LOW: 'LOW' +} const AppState = { - ALWAYS_ON: "ALWAYS_ON", - FOREGROUND: "FOREGROUND", - BACKGROUND: "BACKGROUND", -}; + ALWAYS_ON: 'ALWAYS_ON', + FOREGROUND: 'FOREGROUND', + BACKGROUND: 'BACKGROUND' +} 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, successCallback, errorCallback); -}; + NativeModules.RNRoam.createUser(description, successCallback, errorCallback) +} const getUser = (userid, successCallback, errorCallback) => { - NativeModules.RNRoam.getUser(userid, successCallback, errorCallback); -}; + NativeModules.RNRoam.getUser(userid, successCallback, errorCallback) +} const setDescription = (description) => { - NativeModules.RNRoam.setDescription(description); -}; -const toggleEvents = (geofence, trip, location, movingGeofence, successCallback, errorCallback) => { - NativeModules.RNRoam.toggleEvents(geofence, trip, location, movingGeofence, successCallback, errorCallback); -}; + NativeModules.RNRoam.setDescription(description) +} +const toggleEvents = ( + geofence, + trip, + location, + movingGeofence, + successCallback, + errorCallback +) => { + NativeModules.RNRoam.toggleEvents( + geofence, + trip, + location, + movingGeofence, + successCallback, + errorCallback + ) +} const toggleListener = (location, event, successCallback, errorCallback) => { - NativeModules.RNRoam.toggleListener(location, event, successCallback, errorCallback); -}; + NativeModules.RNRoam.toggleListener( + location, + event, + successCallback, + 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 subscribeTripStatus = (tripId) => { - NativeModules.RNRoam.subscribeTripStatus(tripId); -}; + NativeModules.RNRoam.subscribeTripStatus(tripId) +} const unSubscribeTripStatus = (tripId) => { - NativeModules.RNRoam.unSubscribeTripStatus(tripId); -}; + NativeModules.RNRoam.unSubscribeTripStatus(tripId) +} 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 requestLocationServices = () => { - NativeModules.RNRoam.requestLocationServices(); -}; + NativeModules.RNRoam.requestLocationServices() +} const requestBackgroundLocationPermission = () => { - NativeModules.RNRoam.requestBackgroundLocationPermission(); -}; + NativeModules.RNRoam.requestBackgroundLocationPermission() +} const createTrip = (offline, successCallback, errorCallback) => { - NativeModules.RNRoam.createTrip(offline, successCallback, errorCallback); -}; + NativeModules.RNRoam.createTrip(offline, successCallback, errorCallback) +} const startTrip = (tripId, description, successCallback, errorCallback) => { - NativeModules.RNRoam.startTrip(tripId, description, successCallback, errorCallback); -}; + NativeModules.RNRoam.startTrip( + tripId, + description, + successCallback, + errorCallback + ) +} const resumeTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.resumeTrip(tripId, successCallback, errorCallback); -}; + NativeModules.RNRoam.resumeTrip(tripId, successCallback, errorCallback) +} const pauseTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.pauseTrip(tripId, successCallback, errorCallback); -}; + NativeModules.RNRoam.pauseTrip(tripId, successCallback, errorCallback) +} const getTripSummary = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback); -}; + NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback) +} const stopTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.stopTrip(tripId, successCallback, errorCallback); -}; + NativeModules.RNRoam.stopTrip(tripId, successCallback, errorCallback) +} const forceStopTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.forceStopTrip(tripId, successCallback, errorCallback); -}; + NativeModules.RNRoam.forceStopTrip(tripId, successCallback, errorCallback) +} const deleteTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.deleteTrip(tripId, successCallback, errorCallback); -}; + NativeModules.RNRoam.deleteTrip(tripId, successCallback, errorCallback) +} const syncTrip = (tripId, successCallback, errorCallback) => { - NativeModules.RNRoam.syncTrip(tripId, successCallback, errorCallback); -}; + NativeModules.RNRoam.syncTrip(tripId, successCallback, errorCallback) +} const activeTrips = (offline, successCallback, errorCallback) => { - NativeModules.RNRoam.activeTrips(offline, successCallback, errorCallback); -}; + NativeModules.RNRoam.activeTrips(offline, successCallback, errorCallback) +} 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 stopPublishing = () => { - NativeModules.RNRoam.stopPublishing(); -}; + NativeModules.RNRoam.stopPublishing() +} const startTracking = (trackingMode) => { - NativeModules.RNRoam.startTracking(trackingMode); -}; -const startTrackingCustom = (allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval) => { - NativeModules.RNRoam.startTrackingCustom(allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval); -}; -const startSelfTrackingCustom = (allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval) => { - NativeModules.RNRoam.startSelfTrackingCustom(allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval); -}; + NativeModules.RNRoam.startTracking(trackingMode) +} +const startTrackingCustom = ( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval +) => { + NativeModules.RNRoam.startTrackingCustom( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval + ) +} +const startSelfTrackingCustom = ( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval +) => { + NativeModules.RNRoam.startSelfTrackingCustom( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval + ) +} const startTrackingTimeInterval = (timeInterval, desiredAccuracy) => { - NativeModules.RNRoam.startTrackingTimeInterval(timeInterval, desiredAccuracy); -}; -const startTrackingDistanceInterval = (distance, stationary, desiredAccuracy) => { - NativeModules.RNRoam.startTrackingDistanceInterval(distance, stationary, desiredAccuracy); -}; + NativeModules.RNRoam.startTrackingTimeInterval(timeInterval, desiredAccuracy) +} +const startTrackingDistanceInterval = ( + distance, + stationary, + desiredAccuracy +) => { + NativeModules.RNRoam.startTrackingDistanceInterval( + distance, + stationary, + desiredAccuracy + ) +} const stopTracking = () => { - NativeModules.RNRoam.stopTracking(); -}; + NativeModules.RNRoam.stopTracking() +} const isLocationTracking = (callback) => { - NativeModules.RNRoam.isLocationTracking(callback); -}; + NativeModules.RNRoam.isLocationTracking(callback) +} const allowMockLocation = (enabled) => { - NativeModules.RNRoam.allowMockLocation(enabled); -}; + NativeModules.RNRoam.allowMockLocation(enabled) +} const getCurrentLocationListener = (accuracy) => { - NativeModules.RNRoam.getCurrentLocationListener(accuracy); -}; -const getCurrentLocation = (desiredAccuracy, accuracy, successCallback, errorCallback) => { - NativeModules.RNRoam.getCurrentLocation(desiredAccuracy, accuracy, successCallback, errorCallback); -}; + NativeModules.RNRoam.getCurrentLocationListener(accuracy) +} +const getCurrentLocation = ( + desiredAccuracy, + accuracy, + successCallback, + errorCallback +) => { + NativeModules.RNRoam.getCurrentLocation( + desiredAccuracy, + accuracy, + successCallback, + 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); -}; + NativeModules.RNRoam.getCurrentLocationIos( + accuracy, + successCallback, + errorCallback + ) +} const updateCurrentLocationIos = (accuracy) => { - NativeModules.RNRoam.updateCurrentLocationIos(accuracy); -}; + NativeModules.RNRoam.updateCurrentLocationIos(accuracy) +} 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); -}; -const startSelfTrackingDistanceInterval = (distance, stationary, desiredAccuracy) => { - NativeModules.RNRoam.startSelfTrackingDistanceInterval(distance, stationary, desiredAccuracy); -}; + NativeModules.RNRoam.startSelfTrackingTimeInterval( + timeInterval, + desiredAccuracy + ) +} +const startSelfTrackingDistanceInterval = ( + distance, + stationary, + desiredAccuracy +) => { + NativeModules.RNRoam.startSelfTrackingDistanceInterval( + distance, + stationary, + desiredAccuracy + ) +} const stopSelfTracking = () => { - NativeModules.RNRoam.stopSelfTracking(); -}; + NativeModules.RNRoam.stopSelfTracking() +} const enableAccuracyEngine = () => { - NativeModules.RNRoam.enableAccuracyEngine(); -}; + NativeModules.RNRoam.enableAccuracyEngine() +} const disableAccuracyEngine = () => { - NativeModules.RNRoam.disableAccuracyEngine(); -}; -const startListener = (event, callback) => (eventEmitter.addListener(event, callback)); + NativeModules.RNRoam.disableAccuracyEngine() +} +const startListener = (event, callback) => + eventEmitter.addListener(event, callback) const stopListener = (event, callback) => { - if (callback) { - eventEmitter.removeListener(event, callback); - } - else { - eventEmitter.removeAllListeners(event); - } -}; + if (callback) { + eventEmitter.removeListener(event, callback) + } else { + eventEmitter.removeAllListeners(event) + } +} const Roam = { - TrackingMode, - DesiredAccuracy, - AppState, - DesiredAccuracyIOS, - ActivityType, - SubscribeListener, - Publish, - createUser, - getUser, - setDescription, - toggleEvents, - toggleListener, - getEventsStatus, - getListenerStatus, - subscribe, - unSubscribe, - subscribeTripStatus, - unSubscribeTripStatus, - disableBatteryOptimization, - isBatteryOptimizationEnabled, - checkLocationPermission, - checkLocationServices, - checkBackgroundLocationPermission, - requestLocationPermission, - requestLocationServices, - requestBackgroundLocationPermission, - locationPermissionStatus, - createTrip, - startTrip, - resumeTrip, - pauseTrip, - stopTrip, - forceStopTrip, - deleteTrip, - syncTrip, - activeTrips, - publishOnly, - publishAndSave, - stopPublishing, - startTracking, - startTrackingCustom, - startSelfTrackingCustom, - startTrackingTimeInterval, - startTrackingDistanceInterval, - stopTracking, - isLocationTracking, - allowMockLocation, - getCurrentLocationListener, - getCurrentLocation, - updateCurrentLocation, - getCurrentLocationIos, - updateCurrentLocationIos, - logout, - setTrackingInAppState, - offlineLocationTracking, - startSelfTracking, - startSelfTrackingTimeInterval, - startSelfTrackingDistanceInterval, - stopSelfTracking, - enableAccuracyEngine, - disableAccuracyEngine, - startListener, - stopListener, - getTripSummary, -}; -export default Roam; -//# sourceMappingURL=index.js.map \ No newline at end of file + TrackingMode, + DesiredAccuracy, + AppState, + DesiredAccuracyIOS, + ActivityType, + SubscribeListener, + Publish, + createUser, + getUser, + setDescription, + toggleEvents, + toggleListener, + getEventsStatus, + getListenerStatus, + subscribe, + unSubscribe, + subscribeTripStatus, + unSubscribeTripStatus, + disableBatteryOptimization, + isBatteryOptimizationEnabled, + checkLocationPermission, + checkLocationServices, + checkBackgroundLocationPermission, + requestLocationPermission, + requestLocationServices, + requestBackgroundLocationPermission, + locationPermissionStatus, + createTrip, + startTrip, + resumeTrip, + pauseTrip, + stopTrip, + forceStopTrip, + deleteTrip, + syncTrip, + activeTrips, + publishOnly, + publishAndSave, + stopPublishing, + startTracking, + startTrackingCustom, + startSelfTrackingCustom, + startTrackingTimeInterval, + startTrackingDistanceInterval, + stopTracking, + isLocationTracking, + allowMockLocation, + getCurrentLocationListener, + getCurrentLocation, + updateCurrentLocation, + getCurrentLocationIos, + updateCurrentLocationIos, + logout, + setTrackingInAppState, + offlineLocationTracking, + startSelfTracking, + startSelfTrackingTimeInterval, + startSelfTrackingDistanceInterval, + stopSelfTracking, + enableAccuracyEngine, + disableAccuracyEngine, + startListener, + stopListener, + getTripSummary +} +export default Roam +// # sourceMappingURL=index.js.map diff --git a/js/index.js b/js/index.js index ece89e3..80a9445 100755 --- a/js/index.js +++ b/js/index.js @@ -1,35 +1,33 @@ - -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', + ACTIVE: 'ACTIVE', + BALANCED: 'BALANCED', + PASSIVE: 'PASSIVE' } const DesiredAccuracy = { - HIGH : 'HIGH', - MEDIUM : 'MEDIUM', - LOW :'LOW', + HIGH: 'HIGH', + MEDIUM: 'MEDIUM', + LOW: 'LOW' } const NetworkState = { - BOTH : 'BOTH', - ONLINE : 'ONLINE', - LOW : 'LOW' + BOTH: 'BOTH', + ONLINE: 'ONLINE', + LOW: 'LOW' } const AppState = { - ALWAYS_ON : 'ALWAYS_ON', - FOREGROUND : 'FOREGROUND', - BACKGROUND :'BACKGROUND', + ALWAYS_ON: 'ALWAYS_ON', + FOREGROUND: 'FOREGROUND', + BACKGROUND: 'BACKGROUND' } const Source = { @@ -39,306 +37,423 @@ const Source = { } 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', - } - -const createUser = (description,successCallback,errorCallback) => { - NativeModules.RNRoam.createUser(description,successCallback,errorCallback); -}; - -const getUser = (userid,successCallback,errorCallback) => { - NativeModules.RNRoam.getUser(userid,successCallback,errorCallback); -}; + 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, successCallback, errorCallback) +} + +const getUser = (userid, successCallback, errorCallback) => { + NativeModules.RNRoam.getUser(userid, successCallback, errorCallback) +} const setDescription = (description) => { - NativeModules.RNRoam.setDescription(description); -}; + NativeModules.RNRoam.setDescription(description) +} -const toggleEvents = (geofence,trip,location,movingGeofence,successCallback,errorCallback) => { - NativeModules.RNRoam.toggleEvents(geofence,trip,location,movingGeofence,successCallback,errorCallback); -}; +const toggleEvents = ( + geofence, + trip, + location, + movingGeofence, + successCallback, + errorCallback +) => { + NativeModules.RNRoam.toggleEvents( + geofence, + trip, + location, + movingGeofence, + successCallback, + errorCallback + ) +} -const toggleListener = (location,event,successCallback,errorCallback) => { - NativeModules.RNRoam.toggleListener(location,event,successCallback,errorCallback); -}; +const toggleListener = (location, event, successCallback, errorCallback) => { + NativeModules.RNRoam.toggleListener( + location, + event, + successCallback, + errorCallback + ) +} -const getEventsStatus = (successCallback,errorCallback) => { - NativeModules.RNRoam.getEventsStatus(successCallback,errorCallback); -}; +const getEventsStatus = (successCallback, errorCallback) => { + NativeModules.RNRoam.getEventsStatus(successCallback, errorCallback) +} -const getListenerStatus = (successCallback,errorCallback) => { - NativeModules.RNRoam.getListenerStatus(successCallback,errorCallback); -}; +const getListenerStatus = (successCallback, errorCallback) => { + NativeModules.RNRoam.getListenerStatus(successCallback, errorCallback) +} -const subscribe = (type,userid) => { - NativeModules.RNRoam.subscribe(type,userid); -}; +const subscribe = (type, userid) => { + NativeModules.RNRoam.subscribe(type, userid) +} -const unSubscribe = (type,userid) => { - NativeModules.RNRoam.unSubscribe(type,userid); -}; +const unSubscribe = (type, userid) => { + NativeModules.RNRoam.unSubscribe(type, userid) +} const subscribeTripStatus = (tripId) => { - NativeModules.RNRoam.subscribeTripStatus(tripId); -}; + NativeModules.RNRoam.subscribeTripStatus(tripId) +} const unSubscribeTripStatus = (tripId) => { - if(tripId === undefined || tripId === null){ - NativeModules.RNRoam.unSubscribeTripStatus(null); + if (tripId === undefined || tripId === null) { + NativeModules.RNRoam.unSubscribeTripStatus(null) } else { - NativeModules.RNRoam.unSubscribeTripStatus(tripId); + NativeModules.RNRoam.unSubscribeTripStatus(tripId) } -}; +} 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 requestLocationServices = () => { - NativeModules.RNRoam.requestLocationServices(); -}; + NativeModules.RNRoam.requestLocationServices() +} const requestBackgroundLocationPermission = () => { - NativeModules.RNRoam.requestBackgroundLocationPermission(); -}; + NativeModules.RNRoam.requestBackgroundLocationPermission() +} -const createTrip = (offline,successCallback,errorCallback) => { - NativeModules.RNRoam.createTrip(offline,successCallback,errorCallback); -}; +const createTrip = (offline, successCallback, errorCallback) => { + NativeModules.RNRoam.createTrip(offline, successCallback, errorCallback) +} -const startTrip = (tripId,description,successCallback,errorCallback) => { - NativeModules.RNRoam.startTrip(tripId,description,successCallback,errorCallback); -}; +const startTrip = (tripId, description, successCallback, errorCallback) => { + NativeModules.RNRoam.startTrip( + tripId, + description, + successCallback, + errorCallback + ) +} -const resumeTrip = (tripId,successCallback,errorCallback) => { - NativeModules.RNRoam.resumeTrip(tripId,successCallback,errorCallback); -}; +const resumeTrip = (tripId, successCallback, errorCallback) => { + NativeModules.RNRoam.resumeTrip(tripId, successCallback, errorCallback) +} -const pauseTrip = (tripId,successCallback,errorCallback) => { - NativeModules.RNRoam.pauseTrip(tripId,successCallback,errorCallback); -}; +const pauseTrip = (tripId, successCallback, errorCallback) => { + NativeModules.RNRoam.pauseTrip(tripId, successCallback, errorCallback) +} -const getTripSummary = (tripId,successCallback,errorCallback) => { - NativeModules.RNRoam.getTripSummary(tripId,successCallback,errorCallback); -}; +const getTripSummary = (tripId, successCallback, errorCallback) => { + NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback) +} -const stopTrip = (tripId,successCallback,errorCallback) => { - NativeModules.RNRoam.stopTrip(tripId,successCallback,errorCallback); -}; +const stopTrip = (tripId, successCallback, errorCallback) => { + NativeModules.RNRoam.stopTrip(tripId, successCallback, errorCallback) +} -const forceStopTrip = (tripId,successCallback,errorCallback) => { - NativeModules.RNRoam.forceStopTrip(tripId,successCallback,errorCallback); -}; +const forceStopTrip = (tripId, successCallback, errorCallback) => { + NativeModules.RNRoam.forceStopTrip(tripId, successCallback, errorCallback) +} -const deleteTrip = (tripId,successCallback,errorCallback) => { - NativeModules.RNRoam.deleteTrip(tripId,successCallback,errorCallback); -}; +const deleteTrip = (tripId, successCallback, errorCallback) => { + NativeModules.RNRoam.deleteTrip(tripId, successCallback, errorCallback) +} -const syncTrip = (tripId,successCallback,errorCallback) => { - NativeModules.RNRoam.syncTrip(tripId,successCallback,errorCallback); -}; +const syncTrip = (tripId, successCallback, errorCallback) => { + NativeModules.RNRoam.syncTrip(tripId, successCallback, errorCallback) +} -const activeTrips = (offline,successCallback,errorCallback) => { - NativeModules.RNRoam.activeTrips(offline,successCallback,errorCallback); -}; +const activeTrips = (offline, successCallback, errorCallback) => { + NativeModules.RNRoam.activeTrips(offline, successCallback, errorCallback) +} -const publishOnly = (array,jsonMetadata) => { - NativeModules.RNRoam.publishOnly(array,jsonMetadata); -}; +const publishOnly = (array, jsonMetadata) => { + NativeModules.RNRoam.publishOnly(array, jsonMetadata) +} const publishAndSave = (jsonMetadata) => { - NativeModules.RNRoam.publishAndSave(jsonMetadata); -}; + NativeModules.RNRoam.publishAndSave(jsonMetadata) +} const stopPublishing = () => { - NativeModules.RNRoam.stopPublishing(); -}; + NativeModules.RNRoam.stopPublishing() +} const startTracking = (trackingMode) => { - NativeModules.RNRoam.startTracking(trackingMode); -}; + NativeModules.RNRoam.startTracking(trackingMode) +} -const startTrackingCustom = (allowBackground,pauseAutomatic,activityType,desiredAccuracy,showBackIndicator,distanceFilter,accuracyFilter,updateInterval) => { - NativeModules.RNRoam.startTrackingCustom(allowBackground,pauseAutomatic,activityType,desiredAccuracy,showBackIndicator,distanceFilter,accuracyFilter,updateInterval); -}; +const startTrackingCustom = ( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval +) => { + NativeModules.RNRoam.startTrackingCustom( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval + ) +} -const startSelfTrackingCustom = (allowBackground,pauseAutomatic,activityType,desiredAccuracy,showBackIndicator,distanceFilter,accuracyFilter,updateInterval) => { - NativeModules.RNRoam.startSelfTrackingCustom(allowBackground,pauseAutomatic,activityType,desiredAccuracy,showBackIndicator,distanceFilter,accuracyFilter,updateInterval); -}; +const startSelfTrackingCustom = ( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval +) => { + NativeModules.RNRoam.startSelfTrackingCustom( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval + ) +} -const startTrackingTimeInterval = (timeInterval,desiredAccuracy) => { - NativeModules.RNRoam.startTrackingTimeInterval(timeInterval,desiredAccuracy); -}; +const startTrackingTimeInterval = (timeInterval, desiredAccuracy) => { + NativeModules.RNRoam.startTrackingTimeInterval(timeInterval, desiredAccuracy) +} -const startTrackingDistanceInterval = (distance,stationary,desiredAccuracy) => { - NativeModules.RNRoam.startTrackingDistanceInterval(distance,stationary,desiredAccuracy); -}; +const startTrackingDistanceInterval = ( + distance, + stationary, + desiredAccuracy +) => { + NativeModules.RNRoam.startTrackingDistanceInterval( + distance, + stationary, + desiredAccuracy + ) +} const stopTracking = () => { - NativeModules.RNRoam.stopTracking(); -}; + NativeModules.RNRoam.stopTracking() +} const isLocationTracking = (callback) => { - NativeModules.RNRoam.isLocationTracking(callback); -}; + NativeModules.RNRoam.isLocationTracking(callback) +} -const setForegroundNotification = (enabled, title, description, image, activity, roamService) => { - NativeModules.RNRoam.setForegroundNotification(enabled, title, description, image, activity, roamService); -}; +const setForegroundNotification = ( + enabled, + title, + description, + image, + activity, + roamService +) => { + NativeModules.RNRoam.setForegroundNotification( + enabled, + title, + description, + image, + activity, + 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) => { - NativeModules.RNRoam.getCurrentLocation(desiredAccuracy,accuracy,successCallback,errorCallback); -}; +const getCurrentLocation = ( + desiredAccuracy, + accuracy, + successCallback, + errorCallback +) => { + NativeModules.RNRoam.getCurrentLocation( + desiredAccuracy, + accuracy, + successCallback, + errorCallback + ) +} -const updateCurrentLocation = (desiredAccuracy,accuracy) => { - NativeModules.RNRoam.updateCurrentLocation(desiredAccuracy,accuracy); -}; +const updateCurrentLocation = (desiredAccuracy, accuracy) => { + NativeModules.RNRoam.updateCurrentLocation(desiredAccuracy, accuracy) +} -const getCurrentLocationIos = (accuracy,successCallback,errorCallback) => { - NativeModules.RNRoam.getCurrentLocationIos(accuracy,successCallback,errorCallback); -}; +const getCurrentLocationIos = (accuracy, successCallback, errorCallback) => { + NativeModules.RNRoam.getCurrentLocationIos( + accuracy, + successCallback, + 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); -}; +const logout = (successCallback, errorCallback) => { + NativeModules.RNRoam.logout(successCallback, errorCallback) +} -const setTrackingInAppState = (appState) =>{ - NativeModules.RNRoam.setTrackingInAppState(appState); +const 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); -}; +const startSelfTrackingTimeInterval = (timeInterval, desiredAccuracy) => { + NativeModules.RNRoam.startSelfTrackingTimeInterval( + timeInterval, + desiredAccuracy + ) +} -const startSelfTrackingDistanceInterval = (distance,stationary,desiredAccuracy) => { - NativeModules.RNRoam.startSelfTrackingDistanceInterval(distance,stationary,desiredAccuracy); -}; +const startSelfTrackingDistanceInterval = ( + distance, + stationary, + desiredAccuracy +) => { + NativeModules.RNRoam.startSelfTrackingDistanceInterval( + distance, + stationary, + desiredAccuracy + ) +} const stopSelfTracking = () => { - NativeModules.RNRoam.stopSelfTracking(); -}; + NativeModules.RNRoam.stopSelfTracking() +} const enableAccuracyEngine = (accuracy) => { - if(accuracy === null || accuracy === undefined){ - NativeModules.RNRoam.enableAccuracyEngine(50); + if (accuracy === null || accuracy === undefined) { + 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) => ( +const startListener = (event, callback) => eventEmitter.addListener(event, callback) -); const stopListener = (event) => { - eventEmitter.removeAllListeners(event); -}; + eventEmitter.removeAllListeners(event) +} -const setBatchReceiverConfig = (networkState, batchCount, batchWindow, successCallback, errorCallback) => { - NativeModules.RNRoam.setBatchReceiverConfig(networkState, batchCount, batchWindow, successCallback, errorCallback) +const setBatchReceiverConfig = ( + networkState, + batchCount, + batchWindow, + successCallback, + errorCallback +) => { + NativeModules.RNRoam.setBatchReceiverConfig( + networkState, + batchCount, + batchWindow, + successCallback, + errorCallback + ) } const getBatchReceiverConfig = (successCallback, errorCallback) => { @@ -349,13 +464,32 @@ const resetBatchReceiverConfig = (successCallback, errorCallback) => { NativeModules.RNRoam.resetBatchReceiverConfig(successCallback, errorCallback) } -const setTrackingConfig = (accuracy, timeout, source, discardLocation, successCallback, errorCallback) => { - if(Platform.OS === 'android'){ - NativeModules.RNRoam.setTrackingConfig(accuracy, timeout, source, discardLocation, successCallback, errorCallback) +const setTrackingConfig = ( + accuracy, + timeout, + source, + discardLocation, + successCallback, + errorCallback +) => { + if (Platform.OS === 'android') { + NativeModules.RNRoam.setTrackingConfig( + accuracy, + timeout, + source, + discardLocation, + successCallback, + errorCallback + ) } else { - NativeModules.RNRoam.setTrackingConfig(accuracy, timeout, discardLocation, successCallback, errorCallback) + NativeModules.RNRoam.setTrackingConfig( + accuracy, + timeout, + discardLocation, + successCallback, + errorCallback + ) } - } const getTrackingConfig = (successCallback, errorCallback) => { @@ -367,80 +501,80 @@ const resetTrackingConfig = (successCallback, errorCallback) => { } const Roam = { -TrackingMode, -DesiredAccuracy, -AppState, -NetworkState, -DesiredAccuracyIOS, -ActivityType, -SubscribeListener, -Publish, -Source, -createUser, -getUser, -setDescription, -toggleEvents, -toggleListener, -getEventsStatus, -getListenerStatus, -subscribe, -unSubscribe, -subscribeTripStatus, -unSubscribeTripStatus, -disableBatteryOptimization, -isBatteryOptimizationEnabled, -checkLocationPermission, -checkLocationServices, -checkBackgroundLocationPermission, -requestLocationPermission, -requestLocationServices, -requestBackgroundLocationPermission, -locationPermissionStatus, -createTrip, -startTrip, -resumeTrip, -pauseTrip, -stopTrip, -forceStopTrip, -deleteTrip, -syncTrip, -activeTrips, -getTripSummary, -publishOnly, -publishAndSave, -stopPublishing, -startTracking, -startTrackingCustom, -startSelfTrackingCustom, -startTrackingTimeInterval, -startTrackingDistanceInterval, -stopTracking, -isLocationTracking, -setForegroundNotification, -allowMockLocation, -getCurrentLocationListener, -getCurrentLocation, -updateCurrentLocation, -getCurrentLocationIos, -updateCurrentLocationIos, -logout, -setTrackingInAppState, -offlineLocationTracking, -startSelfTracking, -startSelfTrackingTimeInterval, -startSelfTrackingDistanceInterval, -stopSelfTracking, -enableAccuracyEngine, -disableAccuracyEngine, -startListener, -stopListener, -updateLocationWhenStationary, -setBatchReceiverConfig, -getBatchReceiverConfig, -resetBatchReceiverConfig, -setTrackingConfig, -getTrackingConfig, -resetTrackingConfig -}; - -export default Roam; \ No newline at end of file + TrackingMode, + DesiredAccuracy, + AppState, + NetworkState, + DesiredAccuracyIOS, + ActivityType, + SubscribeListener, + Publish, + Source, + createUser, + getUser, + setDescription, + toggleEvents, + toggleListener, + getEventsStatus, + getListenerStatus, + subscribe, + unSubscribe, + subscribeTripStatus, + unSubscribeTripStatus, + disableBatteryOptimization, + isBatteryOptimizationEnabled, + checkLocationPermission, + checkLocationServices, + checkBackgroundLocationPermission, + requestLocationPermission, + requestLocationServices, + requestBackgroundLocationPermission, + locationPermissionStatus, + createTrip, + startTrip, + resumeTrip, + pauseTrip, + stopTrip, + forceStopTrip, + deleteTrip, + syncTrip, + activeTrips, + getTripSummary, + publishOnly, + publishAndSave, + stopPublishing, + startTracking, + startTrackingCustom, + startSelfTrackingCustom, + startTrackingTimeInterval, + startTrackingDistanceInterval, + stopTracking, + isLocationTracking, + setForegroundNotification, + allowMockLocation, + getCurrentLocationListener, + getCurrentLocation, + updateCurrentLocation, + getCurrentLocationIos, + updateCurrentLocationIos, + logout, + setTrackingInAppState, + offlineLocationTracking, + startSelfTracking, + startSelfTrackingTimeInterval, + startSelfTrackingDistanceInterval, + stopSelfTracking, + enableAccuracyEngine, + disableAccuracyEngine, + startListener, + stopListener, + updateLocationWhenStationary, + setBatchReceiverConfig, + getBatchReceiverConfig, + resetBatchReceiverConfig, + setTrackingConfig, + getTrackingConfig, + resetTrackingConfig +} + +export default Roam diff --git a/js/index.ts b/js/index.ts index 579315b..63ac3c7 100755 --- a/js/index.ts +++ b/js/index.ts @@ -1,13 +1,11 @@ import { NativeEventEmitter, NativeModules } from "react-native"; - if (!NativeModules.RNRoam) { throw new Error("NativeModules.RNRoam is undefined"); } const eventEmitter = new NativeEventEmitter(NativeModules.RNRoam); - const TrackingMode = { ACTIVE: "ACTIVE", BALANCED: "BALANCED", @@ -15,16 +13,16 @@ const TrackingMode = { }; const NetworkState = { - BOTH : 'BOTH', - ONLINE : 'ONLINE', - LOW : 'LOW' -} + BOTH: "BOTH", + ONLINE: "ONLINE", + LOW: "LOW", +}; const Source = { - ALL: 'ALL', - LAST_KNOWN: 'LAST_KNOWN', - GPS: 'GPS' -} + ALL: "ALL", + LAST_KNOWN: "LAST_KNOWN", + GPS: "GPS", +}; const DesiredAccuracy = { HIGH: "HIGH", @@ -92,7 +90,11 @@ const Publish = { TZ_OFFSET: "TZ_OFFSET", }; -const createUser = (description: any, successCallback: any, errorCallback: any) => { +const createUser = ( + description: any, + successCallback: any, + errorCallback: any +) => { NativeModules.RNRoam.createUser(description, successCallback, errorCallback); }; @@ -104,12 +106,36 @@ const setDescription = (description: any) => { NativeModules.RNRoam.setDescription(description); }; -const toggleEvents = (geofence: any, trip: any, location: any, movingGeofence: any, successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.toggleEvents(geofence, trip, location, movingGeofence, successCallback, errorCallback); -}; - -const toggleListener = (location: any, event: any, successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.toggleListener(location, event, successCallback, errorCallback); +const toggleEvents = ( + geofence: any, + trip: any, + location: any, + movingGeofence: any, + successCallback: any, + errorCallback: any +) => { + NativeModules.RNRoam.toggleEvents( + geofence, + trip, + location, + movingGeofence, + successCallback, + errorCallback + ); +}; + +const toggleListener = ( + location: any, + event: any, + successCallback: any, + errorCallback: any +) => { + NativeModules.RNRoam.toggleListener( + location, + event, + successCallback, + errorCallback + ); }; const getEventsStatus = (successCallback: any, errorCallback: any) => { @@ -133,7 +159,7 @@ const subscribeTripStatus = (tripId: any) => { }; const unSubscribeTripStatus = (tripId?: any) => { - if(tripId === undefined || tripId === null){ + if (tripId === undefined || tripId === null) { NativeModules.RNRoam.unSubscribeTripStatus(null); } else { NativeModules.RNRoam.unSubscribeTripStatus(tripId); @@ -180,8 +206,18 @@ const createTrip = (offline: any, successCallback: any, errorCallback: any) => { NativeModules.RNRoam.createTrip(offline, successCallback, errorCallback); }; -const startTrip = (tripId: any, description: any, successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.startTrip(tripId, description, successCallback, errorCallback); +const startTrip = ( + tripId: any, + description: any, + successCallback: any, + errorCallback: any +) => { + NativeModules.RNRoam.startTrip( + tripId, + description, + successCallback, + errorCallback + ); }; const resumeTrip = (tripId: any, successCallback: any, errorCallback: any) => { @@ -192,7 +228,11 @@ const pauseTrip = (tripId: any, successCallback: any, errorCallback: any) => { NativeModules.RNRoam.pauseTrip(tripId, successCallback, errorCallback); }; -const getTripSummary = (tripId: any, successCallback: any, errorCallback: any) => { +const getTripSummary = ( + tripId: any, + successCallback: any, + errorCallback: any +) => { NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback); }; @@ -200,7 +240,11 @@ const stopTrip = (tripId: any, successCallback: any, errorCallback: any) => { NativeModules.RNRoam.stopTrip(tripId, successCallback, errorCallback); }; -const forceStopTrip = (tripId: any, successCallback: any, errorCallback: any) => { +const forceStopTrip = ( + tripId: any, + successCallback: any, + errorCallback: any +) => { NativeModules.RNRoam.forceStopTrip(tripId, successCallback, errorCallback); }; @@ -212,7 +256,11 @@ const syncTrip = (tripId: any, successCallback: any, errorCallback: any) => { NativeModules.RNRoam.syncTrip(tripId, successCallback, errorCallback); }; -const activeTrips = (offline: any, successCallback: any, errorCallback: any) => { +const activeTrips = ( + offline: any, + successCallback: any, + errorCallback: any +) => { NativeModules.RNRoam.activeTrips(offline, successCallback, errorCallback); }; @@ -232,20 +280,64 @@ const startTracking = (trackingMode: any) => { NativeModules.RNRoam.startTracking(trackingMode); }; -const startTrackingCustom = (allowBackground: any, pauseAutomatic: any, activityType: any, desiredAccuracy: any, showBackIndicator: any, distanceFilter: any, accuracyFilter: any, updateInterval: any) => { - NativeModules.RNRoam.startTrackingCustom(allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval); -}; - -const startSelfTrackingCustom = (allowBackground: any, pauseAutomatic: any, activityType: any, desiredAccuracy: any, showBackIndicator: any, distanceFilter: any, accuracyFilter: any, updateInterval: any) => { - NativeModules.RNRoam.startSelfTrackingCustom(allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval); +const startTrackingCustom = ( + allowBackground: any, + pauseAutomatic: any, + activityType: any, + desiredAccuracy: any, + showBackIndicator: any, + distanceFilter: any, + accuracyFilter: any, + updateInterval: any +) => { + NativeModules.RNRoam.startTrackingCustom( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval + ); +}; + +const startSelfTrackingCustom = ( + allowBackground: any, + pauseAutomatic: any, + activityType: any, + desiredAccuracy: any, + showBackIndicator: any, + distanceFilter: any, + accuracyFilter: any, + updateInterval: any +) => { + NativeModules.RNRoam.startSelfTrackingCustom( + allowBackground, + pauseAutomatic, + activityType, + desiredAccuracy, + showBackIndicator, + distanceFilter, + accuracyFilter, + updateInterval + ); }; const startTrackingTimeInterval = (timeInterval: any, desiredAccuracy: any) => { NativeModules.RNRoam.startTrackingTimeInterval(timeInterval, desiredAccuracy); }; -const startTrackingDistanceInterval = (distance: any, stationary: any, desiredAccuracy: any) => { - NativeModules.RNRoam.startTrackingDistanceInterval(distance, stationary, desiredAccuracy); +const startTrackingDistanceInterval = ( + distance: any, + stationary: any, + desiredAccuracy: any +) => { + NativeModules.RNRoam.startTrackingDistanceInterval( + distance, + stationary, + desiredAccuracy + ); }; const stopTracking = () => { @@ -256,8 +348,22 @@ const isLocationTracking = (callback: any) => { NativeModules.RNRoam.isLocationTracking(callback); }; -const setForegroundNotification = (enabled: any, title: any, description: any, image: any, activity: any, roamService:any) => { - NativeModules.RNRoam.setForegroundNotification(enabled, title, description, image, activity, roamService); +const setForegroundNotification = ( + enabled: any, + title: any, + description: any, + image: any, + activity: any, + roamService: any +) => { + NativeModules.RNRoam.setForegroundNotification( + enabled, + title, + description, + image, + activity, + roamService + ); }; const allowMockLocation = (enabled: any) => { @@ -268,16 +374,34 @@ const getCurrentLocationListener = (accuracy: any) => { NativeModules.RNRoam.getCurrentLocationListener(accuracy); }; -const getCurrentLocation = (desiredAccuracy: any, accuracy: any, successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.getCurrentLocation(desiredAccuracy, accuracy, successCallback, errorCallback); +const getCurrentLocation = ( + desiredAccuracy: any, + accuracy: any, + successCallback: any, + errorCallback: any +) => { + NativeModules.RNRoam.getCurrentLocation( + desiredAccuracy, + accuracy, + successCallback, + errorCallback + ); }; const updateCurrentLocation = (desiredAccuracy: any, accuracy: any) => { NativeModules.RNRoam.updateCurrentLocation(desiredAccuracy, accuracy); }; -const getCurrentLocationIos = (accuracy: any, successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.getCurrentLocationIos(accuracy, successCallback, errorCallback); +const getCurrentLocationIos = ( + accuracy: any, + successCallback: any, + errorCallback: any +) => { + NativeModules.RNRoam.getCurrentLocationIos( + accuracy, + successCallback, + errorCallback + ); }; const updateCurrentLocationIos = (accuracy: any) => { @@ -304,12 +428,26 @@ const startSelfTracking = (trackingMode: any) => { NativeModules.RNRoam.startSelfTracking(trackingMode); }; -const startSelfTrackingTimeInterval = (timeInterval: any, desiredAccuracy: any) => { - NativeModules.RNRoam.startSelfTrackingTimeInterval(timeInterval, desiredAccuracy); +const startSelfTrackingTimeInterval = ( + timeInterval: any, + desiredAccuracy: any +) => { + NativeModules.RNRoam.startSelfTrackingTimeInterval( + timeInterval, + desiredAccuracy + ); }; -const startSelfTrackingDistanceInterval = (distance: any, stationary: any, desiredAccuracy: any) => { - NativeModules.RNRoam.startSelfTrackingDistanceInterval(distance, stationary, desiredAccuracy); +const startSelfTrackingDistanceInterval = ( + distance: any, + stationary: any, + desiredAccuracy: any +) => { + NativeModules.RNRoam.startSelfTrackingDistanceInterval( + distance, + stationary, + desiredAccuracy + ); }; const stopSelfTracking = () => { @@ -317,7 +455,7 @@ const stopSelfTracking = () => { }; const enableAccuracyEngine = (accuracy?: any) => { - if(accuracy === null || accuracy === undefined){ + if (accuracy === null || accuracy === undefined) { NativeModules.RNRoam.enableAccuracyEngine(50); } else { NativeModules.RNRoam.enableAccuracyEngine(accuracy); @@ -328,114 +466,138 @@ const disableAccuracyEngine = () => { NativeModules.RNRoam.disableAccuracyEngine(); }; -const startListener = (event: string, callback: (...args: any[]) => any) => ( - eventEmitter.addListener(event, callback) -); +const startListener = (event: string, callback: (...args: any[]) => any) => + eventEmitter.addListener(event, callback); const stopListener = (event: string) => { eventEmitter.removeAllListeners(event); }; -const setBatchReceiverConfig = (networkState: any, batchCount: any, batchWindow: any, successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.setBatchReceiverConfig(networkState, batchCount, batchWindow, successCallback, errorCallback) -} +const setBatchReceiverConfig = ( + networkState: any, + batchCount: any, + batchWindow: any, + successCallback: any, + errorCallback: any +) => { + NativeModules.RNRoam.setBatchReceiverConfig( + networkState, + batchCount, + batchWindow, + successCallback, + errorCallback + ); +}; const getBatchReceiverConfig = (successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.getBatchReceiverConfig(successCallback, errorCallback) -} + NativeModules.RNRoam.getBatchReceiverConfig(successCallback, errorCallback); +}; const resetBatchReceiverConfig = (successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.resetBatchReceiverConfig(successCallback, errorCallback) -} - -const setTrackingConfig = (accuracy: any, timeout: any, source: any, discardLocation: any, successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.setTrackingConfig(accuracy, timeout, source, discardLocation, successCallback, errorCallback) -} + NativeModules.RNRoam.resetBatchReceiverConfig(successCallback, errorCallback); +}; + +const setTrackingConfig = ( + accuracy: any, + timeout: any, + source: any, + discardLocation: any, + successCallback: any, + errorCallback: any +) => { + NativeModules.RNRoam.setTrackingConfig( + accuracy, + timeout, + source, + discardLocation, + successCallback, + errorCallback + ); +}; const getTrackingConfig = (successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.getTrackingConfig(successCallback, errorCallback) -} + NativeModules.RNRoam.getTrackingConfig(successCallback, errorCallback); +}; const resetTrackingConfig = (successCallback: any, errorCallback: any) => { - NativeModules.RNRoam.resetTrackingConfig(successCallback, errorCallback) -} - + NativeModules.RNRoam.resetTrackingConfig(successCallback, errorCallback); +}; const Roam = { -TrackingMode, -DesiredAccuracy, -AppState, -NetworkState, -DesiredAccuracyIOS, -ActivityType, -SubscribeListener, -Publish, -Source, -createUser, -getUser, -setDescription, -toggleEvents, -toggleListener, -getEventsStatus, -getListenerStatus, -subscribe, -unSubscribe, -subscribeTripStatus, -unSubscribeTripStatus, -disableBatteryOptimization, -isBatteryOptimizationEnabled, -checkLocationPermission, -checkLocationServices, -checkBackgroundLocationPermission, -requestLocationPermission, -requestLocationServices, -requestBackgroundLocationPermission, -locationPermissionStatus, -createTrip, -startTrip, -resumeTrip, -pauseTrip, -stopTrip, -forceStopTrip, -deleteTrip, -syncTrip, -activeTrips, -publishOnly, -publishAndSave, -stopPublishing, -startTracking, -startTrackingCustom, -startSelfTrackingCustom, -startTrackingTimeInterval, -startTrackingDistanceInterval, -stopTracking, -isLocationTracking, -setForegroundNotification, -allowMockLocation, -getCurrentLocationListener, -getCurrentLocation, -updateCurrentLocation, -getCurrentLocationIos, -updateCurrentLocationIos, -logout, -setTrackingInAppState, -offlineLocationTracking, -startSelfTracking, -startSelfTrackingTimeInterval, -startSelfTrackingDistanceInterval, -stopSelfTracking, -enableAccuracyEngine, -disableAccuracyEngine, -startListener, -stopListener, -getTripSummary, -updateLocationWhenStationary, -setBatchReceiverConfig, -getBatchReceiverConfig, -resetBatchReceiverConfig, -setTrackingConfig, -getTrackingConfig, -resetTrackingConfig + TrackingMode, + DesiredAccuracy, + AppState, + NetworkState, + DesiredAccuracyIOS, + ActivityType, + SubscribeListener, + Publish, + Source, + createUser, + getUser, + setDescription, + toggleEvents, + toggleListener, + getEventsStatus, + getListenerStatus, + subscribe, + unSubscribe, + subscribeTripStatus, + unSubscribeTripStatus, + disableBatteryOptimization, + isBatteryOptimizationEnabled, + checkLocationPermission, + checkLocationServices, + checkBackgroundLocationPermission, + requestLocationPermission, + requestLocationServices, + requestBackgroundLocationPermission, + locationPermissionStatus, + createTrip, + startTrip, + resumeTrip, + pauseTrip, + stopTrip, + forceStopTrip, + deleteTrip, + syncTrip, + activeTrips, + publishOnly, + publishAndSave, + stopPublishing, + startTracking, + startTrackingCustom, + startSelfTrackingCustom, + startTrackingTimeInterval, + startTrackingDistanceInterval, + stopTracking, + isLocationTracking, + setForegroundNotification, + allowMockLocation, + getCurrentLocationListener, + getCurrentLocation, + updateCurrentLocation, + getCurrentLocationIos, + updateCurrentLocationIos, + logout, + setTrackingInAppState, + offlineLocationTracking, + startSelfTracking, + startSelfTrackingTimeInterval, + startSelfTrackingDistanceInterval, + stopSelfTracking, + enableAccuracyEngine, + disableAccuracyEngine, + startListener, + stopListener, + getTripSummary, + updateLocationWhenStationary, + setBatchReceiverConfig, + getBatchReceiverConfig, + resetBatchReceiverConfig, + setTrackingConfig, + getTrackingConfig, + resetTrackingConfig, }; export default Roam; diff --git a/tsconfig.json b/tsconfig.json index 82d142f..39b1a00 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "compilerOptions": { + "compilerOptions": { "target": "es6", "allowJs": true, "jsx": "react", @@ -8,13 +8,7 @@ "sourceMap": true, "noImplicitAny": true, "moduleResolution": "node" - }, - "filesGlob": [ - "js/**/*.d.ts", - "js/**/*.ts", - "js/**/*.tsx" - ], - "exclude": [ - "node_modules" - ] -} \ No newline at end of file + }, + "filesGlob": ["js/**/*.d.ts", "js/**/*.ts", "js/**/*.tsx"], + "exclude": ["node_modules"] +}