├── .vscode
└── settings.json
├── logo.png
├── android
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── roam
│ │ │ └── reactnative
│ │ │ ├── RNRoamHeadlessService.java
│ │ │ ├── RNRoamPackage.java
│ │ │ ├── RNRoamReceiver.java
│ │ │ ├── RNRoamUtils.java
│ │ │ └── RNRoamModule.java
│ │ └── AndroidManifest.xml
├── build.gradle
├── gradlew.bat
└── gradlew
├── ios
├── RNRoam.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── project.pbxproj
└── RNRoam.h
├── .deepsource.toml
├── tsconfig.json
├── .github
└── workflows
│ └── main.yml
├── CONTRIBUTING.md
├── RNRoam.podspec
├── package.json
├── LICENSE
├── MIGRATION.md
├── .gitignore
├── artifacts
├── index.js.map
└── index.js
├── CHANGELOG.md
├── README.md
└── js
├── index.js
└── index.ts
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "jira-plugin.workingProject": ""
3 | }
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roam-ai/roam-reactnative/HEAD/logo.png
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roam-ai/roam-reactnative/HEAD/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/ios/RNRoam.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/.deepsource.toml:
--------------------------------------------------------------------------------
1 | version = 1
2 |
3 | [[analyzers]]
4 | name = "javascript"
5 | enabled = true
6 |
7 | [analyzers.meta]
8 | plugins = ["react"]
9 |
10 | [[transformers]]
11 | name = "prettier"
12 | enabled = true
13 |
14 | [[transformers]]
15 | name = "standardjs"
16 | enabled = true
--------------------------------------------------------------------------------
/ios/RNRoam.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/RNRoam.h:
--------------------------------------------------------------------------------
1 | //
2 | // RNRoam.h
3 | // RoamApp
4 | //
5 | // Created by GeoSpark on 11/11/22.
6 | //
7 |
8 | #import
9 |
10 | #if __has_include("RCTBridgeModule.h")
11 | #import "RCTBridgeModule.h"
12 | #else
13 | #import
14 | #endif
15 | #import
16 |
17 | @interface RNRoam : RCTEventEmitter
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "allowJs": true,
5 | "jsx": "react",
6 | "outDir": "artifacts",
7 | "rootDir": "js",
8 | "sourceMap": true,
9 | "noImplicitAny": true,
10 | "moduleResolution": "node"
11 | },
12 | "filesGlob": [
13 | "js/**/*.d.ts",
14 | "js/**/*.ts",
15 | "js/**/*.tsx"
16 | ],
17 | "exclude": [
18 | "node_modules"
19 | ]
20 | }
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: Npm Publish
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - uses: actions/setup-node@v1
13 | with:
14 | node-version: 14
15 | registry-url: https://registry.npmjs.org/
16 | - run: yarn install
17 | - run: npm publish --access public
18 | env:
19 | NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
20 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to the Roam SDK for React Native
2 |
3 | 🎉 Thanks for your interest in contributing! 🎉
4 |
5 | ## Ramping Up
6 |
7 | ### Prerequisites
8 |
9 | Make sure you have React Native itself installed and the tools necessary for your desired platforms.
10 |
11 | You can checkout the the official React Native documentation on [getting started](https://reactnative.dev/docs/getting-started) for help.
12 |
13 | ## Setting Up
14 |
15 | ### Clone the repo
16 |
17 | `git clone https://github.com/geosparks/roam-reactnative`
18 |
--------------------------------------------------------------------------------
/RNRoam.podspec:
--------------------------------------------------------------------------------
1 |
2 | require 'json'
3 |
4 | package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
5 |
6 | Pod::Spec.new do |s|
7 | s.name = 'RNRoam'
8 | s.version = package['version']
9 | s.summary = package['description']
10 | s.description = package['description']
11 | s.license = package['license']
12 | s.author = package['author']
13 | s.homepage = package['homepage']
14 | s.source = { :git => "#{package["repository"]["url"]}.git", :tag => "#{s.version}" }
15 |
16 | s.requires_arc = true
17 | s.platform = :ios, '10.0'
18 |
19 | s.preserve_paths = 'LICENSE', 'README.md', 'package.json', 'index.js'
20 | s.source_files = './*.{h,m}'
21 |
22 | s.dependency 'React'
23 | s.dependency 'roam-ios/Roam', '0.1.35-beta.3'
24 | end
25 |
--------------------------------------------------------------------------------
/android/src/main/java/com/roam/reactnative/RNRoamHeadlessService.java:
--------------------------------------------------------------------------------
1 | package com.roam.reactnative;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | import com.facebook.react.HeadlessJsTaskService;
10 | import com.facebook.react.bridge.Arguments;
11 | import com.facebook.react.jstasks.HeadlessJsTaskConfig;
12 |
13 | public class RNRoamHeadlessService extends HeadlessJsTaskService {
14 |
15 | @Nullable
16 | @Override
17 | protected HeadlessJsTaskConfig getTaskConfig(Intent intent) {
18 | Bundle extra = intent.getExtras();
19 | return new HeadlessJsTaskConfig(
20 | "RoamHeadlessService",
21 | extra != null ? Arguments.fromBundle(extra) : Arguments.createMap(),
22 | 0,
23 | true
24 | );
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "roam-reactnative",
3 | "description": "This plugin allows to use the Roam.ai SDK in your React Native mobile application on iOS and Android.",
4 | "homepage": "https://roam.ai",
5 | "license": "MIT",
6 | "version": "0.1.25",
7 | "author": "Roam B.V",
8 | "main": "js/index.js",
9 | "dependencies": {
10 | "typescript": "^4.2.4"
11 | },
12 | "bugs": {
13 | "url": "https://github.com/geosparks/roam-reactnative/issues"
14 | },
15 | "repository": {
16 | "type": "git",
17 | "url": "https://github.com/geosparks/roam-reactnative"
18 | },
19 | "keywords": [
20 | "location",
21 | "android",
22 | "roam",
23 | "sdk",
24 | "ios",
25 | "gps",
26 | "tracking",
27 | "react",
28 | "react-native"
29 | ],
30 | "devDependencies": {
31 | "@types/react-native": "^0.64.5",
32 | "react": ">= 15.4.2",
33 | "react-native": "^0.41.2"
34 | },
35 | "scripts": {
36 | "test": "echo \"Error: no test specified\" && exit 1"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Roam B.V
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/android/src/main/java/com/roam/reactnative/RNRoamPackage.java:
--------------------------------------------------------------------------------
1 | package com.roam.reactnative;
2 |
3 | import com.facebook.react.ReactPackage;
4 | import com.facebook.react.bridge.JavaScriptModule;
5 | import com.facebook.react.bridge.NativeModule;
6 | import com.facebook.react.bridge.ReactApplicationContext;
7 | import com.facebook.react.uimanager.ViewManager;
8 |
9 | import java.util.ArrayList;
10 | import java.util.Collections;
11 | import java.util.List;
12 |
13 | public class RNRoamPackage implements ReactPackage {
14 |
15 |
16 | public RNRoamPackage() {
17 | }
18 |
19 | @Override
20 | public List createNativeModules(ReactApplicationContext reactContext) {
21 | List nativeModules = new ArrayList<>();
22 | nativeModules.add(new RNRoamModule(reactContext));
23 | return nativeModules;
24 | }
25 |
26 | public List> createJSModules() {
27 | return Collections.emptyList();
28 | }
29 |
30 | @Override
31 | public List createViewManagers(ReactApplicationContext reactContext) {
32 | return Collections.emptyList();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/MIGRATION.md:
--------------------------------------------------------------------------------
1 | # Migration Guide
2 |
3 | ## Roam 0.0.25 to Roam 0.0.26
4 |
5 | - Location data in location receiver is changed from single location object to list of location updates.
6 |
7 | ## Roam 0.0.29 to Roam 0.0.30
8 |
9 | - Trip data in trip receiver is changed from single trip object to list of trip updates for Android only.
10 | - New parameter added to `Roam.setForegroundNotification()` method.
11 |
12 | ## Roam 0.0.37 to Roam 0.0.38
13 |
14 | - The parameter for distance covered in trip summary method is changed from `distance` to `distanceCovered` for Android. This is to match the iOS trip response.
15 |
16 | ## Roam 0.0.X to 0.1.0
17 |
18 | - The Roam.subscribeTripStatus() method has been renamed to Roam.subscribeTrip()
19 | - The Roam.updateTrip() method is newly added
20 | - The Roam.stopTrip() method has been renamed to Roam.endTrip()
21 | - All the below trips method will use the new trips v2 logic where origins and destinations are called as stops.
22 | - Roam.createTrip()
23 | - Roam.startQuickTrip()
24 | - Roam.startTrip()
25 | - Roam.updateTrip()
26 | - Roam.endTrip()
27 | - Roam.pauseTrip()
28 | - Roam.resumeTrip()
29 | - Roam.syncTrip()
30 | - Roam.getTrip()
31 | - Roam.getActiveTrips()
32 | - Roam.getTripSummary()
33 | - Roam.subscribeTrip()
34 | - Roam.unSubscribeTrip()
35 | - Roam.deleteTrip()
36 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | def safeExtGet(prop, fallback) {
4 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5 | }
6 |
7 | buildscript {
8 | repositories {
9 | google()
10 | jcenter()
11 | }
12 | dependencies {
13 | classpath 'com.android.tools.build:gradle:7.0.0'
14 | }
15 | }
16 |
17 | android {
18 | compileSdkVersion safeExtGet('compileSdkVersion', 34)
19 | buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
20 |
21 | defaultConfig {
22 | minSdkVersion safeExtGet('minSdkVersion', 23)
23 | }
24 | buildTypes {
25 | release {
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 |
30 | compileOptions {
31 | sourceCompatibility JavaVersion.VERSION_1_8
32 | targetCompatibility JavaVersion.VERSION_1_8
33 | }
34 | }
35 |
36 | repositories {
37 | google()
38 | jcenter()
39 | mavenCentral()
40 | maven {
41 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
42 | url "$rootDir/../node_modules/react-native/android"
43 | }
44 | maven {
45 | url 'https://com-roam-android.s3.amazonaws.com/'
46 | }
47 | }
48 |
49 | dependencies {
50 | implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
51 | implementation 'com.roam.sdk:roam-android:0.1.42-beta.2'
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.aar
4 | *.ap_
5 | *.aab
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 | android/.DS_Store
10 | android/app/.DS_Store
11 |
12 | # Java class files
13 | *.class
14 |
15 | # Generated files
16 | bin/
17 | gen/
18 | out/
19 | # Uncomment the following line in case you need and you don't have the release build type files in your app
20 | # release/
21 |
22 | # Gradle files
23 | .gradle/
24 | build/
25 |
26 | # Local configuration file (sdk path, etc)
27 | local.properties
28 |
29 | # Proguard folder generated by Eclipse
30 | proguard/
31 |
32 | # Log Files
33 | *.log
34 |
35 | # Android Studio Navigation editor temp files
36 | .navigation/
37 |
38 | # Android Studio captures folder
39 | captures/
40 |
41 | # IntelliJ
42 | *.iml
43 | .idea/
44 | .idea/workspace.xml
45 | .idea/tasks.xml
46 | .idea/gradle.xml
47 | .idea/assetWizardSettings.xml
48 | .idea/dictionaries
49 | .idea/libraries
50 | # Android Studio 3 in .gitignore file.
51 | .idea/caches
52 | .idea/modules.xml
53 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you
54 | .idea/navEditor.xml
55 |
56 | # Keystore files
57 | # Uncomment the following lines if you do not want to check your keystore files in.
58 | #*.jks
59 | #*.keystore
60 |
61 | # External native build folder generated in Android Studio 2.2 and later
62 | .externalNativeBuild
63 | .cxx/
64 |
65 | # Google Services (e.g. APIs or Firebase)
66 | # google-services.json
67 |
68 | # Freeline
69 | freeline.py
70 | freeline/
71 | freeline_project_description.json
72 |
73 | # fastlane
74 | fastlane/report.xml
75 | fastlane/Preview.html
76 | fastlane/screenshots
77 | fastlane/test_output
78 | fastlane/readme.md
79 |
80 | # Version control
81 | vcs.xml
82 |
83 | # lint
84 | lint/intermediates/
85 | lint/generated/
86 | lint/outputs/
87 | lint/tmp/
88 | # lint/reports/
89 | .DS_Store
90 |
91 | node_modules/
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/android/src/main/java/com/roam/reactnative/RNRoamReceiver.java:
--------------------------------------------------------------------------------
1 | package com.roam.reactnative;
2 |
3 |
4 | import android.content.Context;
5 | import android.content.Intent;
6 |
7 | import com.facebook.react.HeadlessJsTaskService;
8 | import com.facebook.react.ReactApplication;
9 | import com.facebook.react.ReactInstanceManager;
10 | import com.facebook.react.ReactNativeHost;
11 | import com.facebook.react.bridge.Arguments;
12 | import com.facebook.react.bridge.ReactContext;
13 | import com.facebook.react.bridge.WritableArray;
14 | import com.facebook.react.bridge.WritableMap;
15 | import com.facebook.react.modules.core.DeviceEventManagerModule;
16 | import com.roam.sdk.models.NetworkListener;
17 | import com.roam.sdk.models.RoamError;
18 | import com.roam.sdk.models.RoamLocation;
19 | import com.roam.sdk.models.RoamLocationReceived;
20 | import com.roam.sdk.models.RoamTripStatus;
21 | import com.roam.sdk.models.events.RoamEvent;
22 | import com.roam.sdk.service.RoamReceiver;
23 |
24 | import java.util.List;
25 |
26 |
27 | public class RNRoamReceiver extends RoamReceiver {
28 | private ReactNativeHost mReactNativeHost;
29 |
30 | private void invokeSendEvent(ReactContext reactContext, String eventName, Object data) {
31 | reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
32 | }
33 |
34 | private void sendEvent(final String eventName, final Object data) {
35 | final ReactInstanceManager reactInstanceManager = mReactNativeHost.getReactInstanceManager();
36 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
37 | if (reactContext == null) {
38 | reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
39 | @Override
40 | public void onReactContextInitialized(ReactContext reactContext) {
41 | invokeSendEvent(reactContext, eventName, data);
42 | reactInstanceManager.removeReactInstanceEventListener(this);
43 | }
44 | });
45 | if (!reactInstanceManager.hasStartedCreatingInitialContext()) {
46 | reactInstanceManager.createReactContextInBackground();
47 | }
48 | } else {
49 | invokeSendEvent(reactContext, eventName, data);
50 | }
51 | }
52 |
53 | @Override
54 | public void onLocationUpdated(Context context, List locationList) {
55 | super.onLocationUpdated(context, locationList);
56 | ReactApplication reactApplication = (ReactApplication) context.getApplicationContext();
57 | mReactNativeHost = reactApplication.getReactNativeHost();
58 | WritableArray array = RNRoamUtils.mapForLocationList(locationList);
59 | sendEvent("location", array);
60 | }
61 |
62 | @Override
63 | public void onEventReceived(Context context, RoamEvent roamEvent) {
64 | super.onEventReceived(context, roamEvent);
65 | ReactApplication reactApplication = (ReactApplication) context.getApplicationContext();
66 | mReactNativeHost = reactApplication.getReactNativeHost();
67 | WritableMap map = RNRoamUtils.mapForRoamEvent(roamEvent);
68 | sendEvent("events", map);
69 | }
70 |
71 | @Override
72 | public void onLocationReceived(Context context, RoamLocationReceived roamLocationReceived) {
73 | super.onLocationReceived(context, roamLocationReceived);
74 | ReactApplication reactApplication = (ReactApplication) context.getApplicationContext();
75 | mReactNativeHost = reactApplication.getReactNativeHost();
76 | WritableMap map = Arguments.createMap();
77 | if (roamLocationReceived.getUser_id() != null) {
78 | map.putString("userId", roamLocationReceived.getUser_id());
79 | }
80 | if (roamLocationReceived.getLocation_id() != null) {
81 | map.putString("locationId", roamLocationReceived.getLocation_id());
82 | }
83 | if (roamLocationReceived.getActivity() != null) {
84 | map.putString("activity", roamLocationReceived.getActivity());
85 | }
86 | if (roamLocationReceived.getEvent_source() != null) {
87 | map.putString("eventSource", roamLocationReceived.getEvent_source());
88 | }
89 | map.putInt("speed", roamLocationReceived.getSpeed());
90 | map.putDouble("altitude", roamLocationReceived.getAltitude());
91 | map.putDouble("horizontalAccuracy", roamLocationReceived.getHorizontal_accuracy());
92 | map.putDouble("verticalAccuracy", roamLocationReceived.getVertical_accuracy());
93 | map.putDouble("course", roamLocationReceived.getCourse());
94 | map.putDouble("latitude", roamLocationReceived.getLatitude());
95 | map.putDouble("longitude", roamLocationReceived.getLongitude());
96 | if (roamLocationReceived.getEvent_version() != null) {
97 | map.putString("eventVersion", roamLocationReceived.getEvent_version());
98 | }
99 | if (roamLocationReceived.getRecorded_at() != null) {
100 | map.putString("recordedAt", roamLocationReceived.getRecorded_at());
101 | }
102 | if (roamLocationReceived.getEvent_type() != null) {
103 | map.putString("eventType", roamLocationReceived.getEvent_type());
104 | }
105 | sendEvent("location_received", map);
106 | }
107 |
108 | @Override
109 | public void onReceiveTrip(Context context, List list) {
110 | super.onReceiveTrip(context, list);
111 | ReactApplication reactApplication = (ReactApplication) context.getApplicationContext();
112 | mReactNativeHost = reactApplication.getReactNativeHost();
113 | sendEvent("trip_status", RNRoamUtils.mapForTripStatusListener(list));
114 | }
115 |
116 | @Override
117 | public void onError(Context context, RoamError roamError) {
118 | super.onError(context, roamError);
119 | ReactApplication reactApplication = (ReactApplication) context.getApplicationContext();
120 | mReactNativeHost = reactApplication.getReactNativeHost();
121 | WritableMap map = Arguments.createMap();
122 | map.putString("code", roamError.getCode());
123 | map.putString("message", roamError.getMessage());
124 | if(roamError.getMessage().equalsIgnoreCase("The GPS is enabled.") || roamError.getMessage().equalsIgnoreCase("The location permission is enabled"))
125 | {
126 | map.putBoolean("locationServicesEnabled", true);
127 | sendEvent("locationAuthorizationChange", map);
128 | }
129 | else if (roamError.getMessage().equalsIgnoreCase("The GPS is disabled.") || roamError.getMessage().equalsIgnoreCase("The location permission is disabled"))
130 | {
131 | map.putBoolean("locationServicesEnabled", false);
132 | sendEvent("locationAuthorizationChange", map);
133 | }
134 | sendEvent("error", map);
135 | }
136 |
137 | @Override
138 | public void onConnectivityChange(Context context, NetworkListener networkListener) {
139 | super.onConnectivityChange(context, networkListener);
140 | ReactApplication reactApplication = (ReactApplication) context.getApplicationContext();
141 | mReactNativeHost = reactApplication.getReactNativeHost();
142 | WritableMap map = Arguments.createMap();
143 | map.putString("type", networkListener.getType());
144 | map.putBoolean("isConnected", networkListener.getIsConnected());
145 | sendEvent("connectivityChangeEvent", map);
146 | }
147 |
148 | @Override
149 | public void onReceive(Context context, Intent intent) {
150 | super.onReceive(context, intent);
151 | if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
152 | try{
153 | Intent headlessServiceIntent = new Intent(context, RNRoamHeadlessService.class);
154 | context.startService(headlessServiceIntent);
155 | HeadlessJsTaskService.acquireWakeLockNow(context);
156 | }catch(Exception e){
157 | e.printStackTrace();
158 | }
159 | }
160 | }
161 | }
162 |
163 |
--------------------------------------------------------------------------------
/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/ios/RNRoam.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | B3E7B58A1CC2AC0600A0062D /* RNRoam.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNRoam.m */; };
11 | /* End PBXBuildFile section */
12 |
13 | /* Begin PBXCopyFilesBuildPhase section */
14 | 58B511D91A9E6C8500147676 /* CopyFiles */ = {
15 | isa = PBXCopyFilesBuildPhase;
16 | buildActionMask = 2147483647;
17 | dstPath = "include/$(PRODUCT_NAME)";
18 | dstSubfolderSpec = 16;
19 | files = (
20 | );
21 | runOnlyForDeploymentPostprocessing = 0;
22 | };
23 | /* End PBXCopyFilesBuildPhase section */
24 |
25 | /* Begin PBXFileReference section */
26 | 134814201AA4EA6300B7C361 /* libRNRoam.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNRoam.a; sourceTree = BUILT_PRODUCTS_DIR; };
27 | B3E7B5881CC2AC0600A0062D /* RNRoam.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNRoam.h; sourceTree = ""; };
28 | B3E7B5891CC2AC0600A0062D /* RNRoam.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNRoam.m; sourceTree = ""; };
29 | /* End PBXFileReference section */
30 |
31 | /* Begin PBXFrameworksBuildPhase section */
32 | 58B511D81A9E6C8500147676 /* Frameworks */ = {
33 | isa = PBXFrameworksBuildPhase;
34 | buildActionMask = 2147483647;
35 | files = (
36 | );
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXFrameworksBuildPhase section */
40 |
41 | /* Begin PBXGroup section */
42 | 134814211AA4EA7D00B7C361 /* Products */ = {
43 | isa = PBXGroup;
44 | children = (
45 | 134814201AA4EA6300B7C361 /* libRNRoam.a */,
46 | );
47 | name = Products;
48 | sourceTree = "";
49 | };
50 | 58B511D21A9E6C8500147676 = {
51 | isa = PBXGroup;
52 | children = (
53 | B3E7B5881CC2AC0600A0062D /* RNRoam.h */,
54 | B3E7B5891CC2AC0600A0062D /* RNRoam.m */,
55 | 134814211AA4EA7D00B7C361 /* Products */,
56 | );
57 | sourceTree = "";
58 | };
59 | /* End PBXGroup section */
60 |
61 | /* Begin PBXNativeTarget section */
62 | 58B511DA1A9E6C8500147676 /* RNRoam */ = {
63 | isa = PBXNativeTarget;
64 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNRoam" */;
65 | buildPhases = (
66 | 58B511D71A9E6C8500147676 /* Sources */,
67 | 58B511D81A9E6C8500147676 /* Frameworks */,
68 | 58B511D91A9E6C8500147676 /* CopyFiles */,
69 | );
70 | buildRules = (
71 | );
72 | dependencies = (
73 | );
74 | name = RNRoam;
75 | productName = RCTDataManager;
76 | productReference = 134814201AA4EA6300B7C361 /* libRNRoam.a */;
77 | productType = "com.apple.product-type.library.static";
78 | };
79 | /* End PBXNativeTarget section */
80 |
81 | /* Begin PBXProject section */
82 | 58B511D31A9E6C8500147676 /* Project object */ = {
83 | isa = PBXProject;
84 | attributes = {
85 | LastUpgradeCheck = 0830;
86 | ORGANIZATIONNAME = Facebook;
87 | TargetAttributes = {
88 | 58B511DA1A9E6C8500147676 = {
89 | CreatedOnToolsVersion = 6.1.1;
90 | };
91 | };
92 | };
93 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNRoam" */;
94 | compatibilityVersion = "Xcode 3.2";
95 | developmentRegion = English;
96 | hasScannedForEncodings = 0;
97 | knownRegions = (
98 | en,
99 | );
100 | mainGroup = 58B511D21A9E6C8500147676;
101 | productRefGroup = 58B511D21A9E6C8500147676;
102 | projectDirPath = "";
103 | projectRoot = "";
104 | targets = (
105 | 58B511DA1A9E6C8500147676 /* RNRoam */,
106 | );
107 | };
108 | /* End PBXProject section */
109 |
110 | /* Begin PBXSourcesBuildPhase section */
111 | 58B511D71A9E6C8500147676 /* Sources */ = {
112 | isa = PBXSourcesBuildPhase;
113 | buildActionMask = 2147483647;
114 | files = (
115 | B3E7B58A1CC2AC0600A0062D /* RNRoam.m in Sources */,
116 | );
117 | runOnlyForDeploymentPostprocessing = 0;
118 | };
119 | /* End PBXSourcesBuildPhase section */
120 |
121 | /* Begin XCBuildConfiguration section */
122 | 58B511ED1A9E6C8500147676 /* Debug */ = {
123 | isa = XCBuildConfiguration;
124 | buildSettings = {
125 | ALWAYS_SEARCH_USER_PATHS = NO;
126 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
127 | CLANG_CXX_LIBRARY = "libc++";
128 | CLANG_ENABLE_MODULES = YES;
129 | CLANG_ENABLE_OBJC_ARC = YES;
130 | CLANG_WARN_BOOL_CONVERSION = YES;
131 | CLANG_WARN_CONSTANT_CONVERSION = YES;
132 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
133 | CLANG_WARN_EMPTY_BODY = YES;
134 | CLANG_WARN_ENUM_CONVERSION = YES;
135 | CLANG_WARN_INFINITE_RECURSION = YES;
136 | CLANG_WARN_INT_CONVERSION = YES;
137 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
138 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
139 | CLANG_WARN_UNREACHABLE_CODE = YES;
140 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
141 | COPY_PHASE_STRIP = NO;
142 | ENABLE_STRICT_OBJC_MSGSEND = YES;
143 | ENABLE_TESTABILITY = YES;
144 | GCC_C_LANGUAGE_STANDARD = gnu99;
145 | GCC_DYNAMIC_NO_PIC = NO;
146 | GCC_NO_COMMON_BLOCKS = YES;
147 | GCC_OPTIMIZATION_LEVEL = 0;
148 | GCC_PREPROCESSOR_DEFINITIONS = (
149 | "DEBUG=1",
150 | "$(inherited)",
151 | );
152 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
153 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
154 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
155 | GCC_WARN_UNDECLARED_SELECTOR = YES;
156 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
157 | GCC_WARN_UNUSED_FUNCTION = YES;
158 | GCC_WARN_UNUSED_VARIABLE = YES;
159 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
160 | MTL_ENABLE_DEBUG_INFO = YES;
161 | ONLY_ACTIVE_ARCH = YES;
162 | SDKROOT = iphoneos;
163 | };
164 | name = Debug;
165 | };
166 | 58B511EE1A9E6C8500147676 /* Release */ = {
167 | isa = XCBuildConfiguration;
168 | buildSettings = {
169 | ALWAYS_SEARCH_USER_PATHS = NO;
170 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
171 | CLANG_CXX_LIBRARY = "libc++";
172 | CLANG_ENABLE_MODULES = YES;
173 | CLANG_ENABLE_OBJC_ARC = YES;
174 | CLANG_WARN_BOOL_CONVERSION = YES;
175 | CLANG_WARN_CONSTANT_CONVERSION = YES;
176 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
177 | CLANG_WARN_EMPTY_BODY = YES;
178 | CLANG_WARN_ENUM_CONVERSION = YES;
179 | CLANG_WARN_INFINITE_RECURSION = YES;
180 | CLANG_WARN_INT_CONVERSION = YES;
181 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
182 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
183 | CLANG_WARN_UNREACHABLE_CODE = YES;
184 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
185 | COPY_PHASE_STRIP = YES;
186 | ENABLE_NS_ASSERTIONS = NO;
187 | ENABLE_STRICT_OBJC_MSGSEND = YES;
188 | GCC_C_LANGUAGE_STANDARD = gnu99;
189 | GCC_NO_COMMON_BLOCKS = YES;
190 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
191 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
192 | GCC_WARN_UNDECLARED_SELECTOR = YES;
193 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
194 | GCC_WARN_UNUSED_FUNCTION = YES;
195 | GCC_WARN_UNUSED_VARIABLE = YES;
196 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
197 | MTL_ENABLE_DEBUG_INFO = NO;
198 | SDKROOT = iphoneos;
199 | VALIDATE_PRODUCT = YES;
200 | };
201 | name = Release;
202 | };
203 | 58B511F01A9E6C8500147676 /* Debug */ = {
204 | isa = XCBuildConfiguration;
205 | buildSettings = {
206 | HEADER_SEARCH_PATHS = (
207 | "$(inherited)",
208 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
209 | "$(SRCROOT)/../../../React/**",
210 | "$(SRCROOT)/../../react-native/React/**",
211 | );
212 | LIBRARY_SEARCH_PATHS = "$(inherited)";
213 | OTHER_LDFLAGS = "-ObjC";
214 | PRODUCT_NAME = RNRoam;
215 | SKIP_INSTALL = YES;
216 | };
217 | name = Debug;
218 | };
219 | 58B511F11A9E6C8500147676 /* Release */ = {
220 | isa = XCBuildConfiguration;
221 | buildSettings = {
222 | HEADER_SEARCH_PATHS = (
223 | "$(inherited)",
224 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
225 | "$(SRCROOT)/../../../React/**",
226 | "$(SRCROOT)/../../react-native/React/**",
227 | );
228 | LIBRARY_SEARCH_PATHS = "$(inherited)";
229 | OTHER_LDFLAGS = "-ObjC";
230 | PRODUCT_NAME = RNRoam;
231 | SKIP_INSTALL = YES;
232 | };
233 | name = Release;
234 | };
235 | /* End XCBuildConfiguration section */
236 |
237 | /* Begin XCConfigurationList section */
238 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNRoam" */ = {
239 | isa = XCConfigurationList;
240 | buildConfigurations = (
241 | 58B511ED1A9E6C8500147676 /* Debug */,
242 | 58B511EE1A9E6C8500147676 /* Release */,
243 | );
244 | defaultConfigurationIsVisible = 0;
245 | defaultConfigurationName = Release;
246 | };
247 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNRoam" */ = {
248 | isa = XCConfigurationList;
249 | buildConfigurations = (
250 | 58B511F01A9E6C8500147676 /* Debug */,
251 | 58B511F11A9E6C8500147676 /* Release */,
252 | );
253 | defaultConfigurationIsVisible = 0;
254 | defaultConfigurationName = Release;
255 | };
256 | /* End XCConfigurationList section */
257 | };
258 | rootObject = 58B511D31A9E6C8500147676 /* Project object */;
259 | }
260 |
--------------------------------------------------------------------------------
/artifacts/index.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../js/index.ts"],"names":[],"mappings":"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"}
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.0.1
2 |
3 | - A whole new React Native SDK which is based on much more stable GeoSpark native iOS and Android SDKs.
4 |
5 | ## 0.0.2
6 |
7 | - Added support for Typescript
8 |
9 | ## 0.0.3
10 |
11 | - Added support for Get Trip Summary (Android)
12 |
13 | ## 0.0.4
14 |
15 | - Added support for total elevation gain to trip summary along with elevation gain, distance and duration for location date in trip summary. (Android)
16 |
17 | ## 0.0.5
18 |
19 | - Refactored iOS SDK modules to support new Xcode v12.5.1
20 |
21 | ## 0.0.6
22 |
23 | - Updated to latest native Roam SDK versions. Android v0.0.3 and iOS v0.0.7
24 | - Fixed the auto linking for both iOS and Android.
25 | - Updated the Readme.md docs with latest quickstart guides.
26 |
27 | ## 0.0.7
28 |
29 | - Added support in android native SDK(0.0.7) to listen to location updates of user from different projects which are within same account.
30 |
31 | ## 0.0.8
32 |
33 | - Code cleanup in RNRoamReceiver.java file
34 |
35 | ## 0.0.9
36 |
37 | - Added support in android native SDK(0.0.8) to listen to location permission changes
38 |
39 | ## 0.0.10
40 |
41 | - Added support in android native SDK(0.0.9)
42 | - Ability to listen to trip status with distance, duration, elevation gain and total elevation gain
43 | - Ability to create offline trips without user session
44 |
45 | ## 0.0.11
46 |
47 | - Updated android native SDK(0.0.9)
48 |
49 | ## 0.0.12
50 |
51 | - Refactored android native SDK (0.0.9) linking
52 |
53 | ## 0.0.13
54 |
55 | - Added support in android native SDK(0.0.10)
56 | - Fixed create trip when creating offline trip without user session.
57 | - Added support to location permission events in `locationAuthorizationChange`
58 |
59 | ## 0.0.14
60 |
61 | - Updated to latest native Roam SDK versions. Android v0.0.11 and iOS v0.0.13
62 |
63 | ## 0.0.15
64 |
65 | - Updated to latest iOS native SDK version v0.0.14 which improves `the Roam.getCurrentLocation()` to return location faster.
66 |
67 | ## 0.0.16
68 |
69 | - Updated to latest Android native SDK version v0.0.12 with support for controlling the foreground service notification.
70 |
71 | ## 0.0.17
72 |
73 | - Fixed `Roam.setForegroundNotification()` to accept the custom icons.
74 |
75 | ## 0.0.18
76 |
77 | - Updated to latest native Roam SDK versions. Android v0.0.13 and iOS v0.0.15
78 | - Added iOS native bridge for `getTripSummary()` method.
79 |
80 | ## 0.0.19
81 |
82 | - Updated to latest native Roam SDK versions. Android v0.0.15 and iOS v0.0.16
83 | - Added option in `Roam.unSubscribe()` which will now unsubscribe all users if `user_id` is passed as null or empty.
84 | - Added battery and network details as part of location in location receiver.
85 | - Fixed logical error in calculation of elevation gain in trip summary.
86 |
87 | ## 0.0.20
88 |
89 | - Removed the blue bar in iOS which was being displayed during active tracking mode.
90 |
91 | ## 0.0.21
92 |
93 | - Added new method for `Roam.updateLocationWhenStationary(interval)` which updates location on given interval value in seconds.
94 |
95 | ## 0.0.22
96 |
97 | - Updated to latest native Roam SDK versions. Android v0.0.17 and iOS v0.0.17.
98 | - Fixed crashes for `endTrip`, `pauseTrip`, `resumeTrip` and `forceEndTrip` in iOS bridge.
99 |
100 | ## 0.0.23
101 |
102 | - Updated to latest native Roam SDK version. iOS v0.0.18.
103 | - Fixed the coordinates arrangement for `Roam.getTripSummary()` on local trips.
104 |
105 | ## 0.0.24
106 |
107 | - Updated to latest native Roam SDK versions. Android v0.0.19 and iOS v0.0.19.
108 | - Modified updateCurrentLocation method to support metadata as null.
109 | - Updated location noise filter to remove inaccurate locations.
110 | - Added individual distance, duration, and elevation gain for location data inside trip routes for local trips.
111 | - Trip summary response for the local trip will have the route sorted by recorded timestamp.
112 | - Fixed background location tracking for time-based tracking mode when location permission is given as 'Allow while using'
113 |
114 | ## 0.0.25
115 |
116 | - Updated to latest native Roam SDK versions - iOS v0.0.20.
117 | - Fixed calculation for distance and duration for individual location data in trip summary route.
118 |
119 | ## 0.0.26
120 |
121 | Added:
122 |
123 | - Added new methods for batch configurations in location receiver.
124 |
125 | Modified:
126 |
127 | - Location data in location receiver is changed from single location object to list of location updates.
128 |
129 | Fixed:
130 |
131 | - Trip error changed for few error scenarios to success callbacks.
132 | - Trip Already Started
133 | - Trip Already Ended
134 |
135 | ## 0.0.27
136 |
137 | Modified:
138 |
139 | - Added callbacks to `Roam.resetBatchReceiverConfig()` method to return default config values.
140 | Fixed:
141 | - Fixed callback response for `Roam.getBatchReceiverConfig()` and `Roam.setBatchReceiverConfig()` methods.
142 |
143 | ## 0.0.28
144 |
145 | Fixed:
146 |
147 | - Fixed the method `Roam.resetBatchReceiverConfig()`.
148 | - Autolinking for iOS.
149 |
150 | ## 0.0.29
151 |
152 | Added:
153 |
154 | - New listener for connectity change event with `Roam.startListener('connectivityChangeEvent', connectivityChangeEvent)`
155 | - Updated to latest native Roam SDK versions - Android v0.0.22.
156 |
157 | ## 0.0.30
158 |
159 | Added:
160 |
161 | - Fixed location receiver when device restarted (Android).
162 | - Added option to restart Roam Service with `Roam.setForegroundNotification()` method.
163 | - Updated to latest native Roam SDK version - Android v0.0.23.
164 |
165 | ## 0.0.31
166 |
167 | - Configured the SDK to support location receiver after device reboot.
168 |
169 | ## 0.0.32
170 |
171 | Fixed:
172 |
173 | - `Roam.enableAccuracyEngine(int)` method to accept integer value.
174 | - Autolinking for iOS.
175 |
176 | ## 0.0.33
177 |
178 | Added:
179 |
180 | - Added batch config for "trip_status" listener
181 |
182 | ## 0.0.34
183 |
184 | - Updated to latest native Roam SDK versions. Android v0.0.25 and iOS v0.0.25.
185 | - Added `recorderAt` parameter for trip status listener.
186 | - Added option to unsubscribe from all the trips in the method `Roam.unsubscribeTripStatus()`
187 | - Fixed trip listener that works independently of the location listener in iOS.
188 |
189 | ## 0.0.35
190 |
191 | - Fixed enableAccuracyEngine() for null accuracy value.
192 |
193 | ## 0.0.36
194 |
195 | - Updated native Roam SDK versions. Android v0.0.26 and iOS v0.0.27
196 | - Added tracking config methods `Roam.setTrackingConfig()`, `Roam.getTrackingConfig()` and `Roam.resetTrackingConfig()`
197 | - Fixed blue bar for custom tracking in iOS.
198 |
199 | ## 0.0.37
200 |
201 | - Updated native Roam SDK versions. Android v0.0.28 and iOS v0.0.28
202 | - Added `discardLocation` parameter for `Roam.setTrackingConfig()`, `Roam.getTrackingConfig()` and `Roam.resetTrackingConfig()` methods.
203 |
204 | ## 0.0.38
205 |
206 | - Added extra `distanceCovered` property in android for trip summary.
207 |
208 | ## 0.0.39
209 |
210 | - Updated native Roam SDK versions. Android v0.0.30 and iOS v0.0.31
211 | - Fixed `OFFLINE` input for Tracking config NetworkState
212 |
213 | ## 0.0.40
214 |
215 | - Updated native Roam SDK iOS version v0.0.36
216 | - Added `altitude`, `elevationGain`, and `totalElevationGain` in `trip_status` listener
217 |
218 | ## 0.0.41
219 |
220 | - Fixed `location` parameter of location listener for Batch Locations (Android).
221 |
222 | ## 0.0.42
223 |
224 | - Updated Android SDK v0.0.35 and iOS SDK v0.0.37
225 | - Fixed location drift issue in iOS
226 |
227 | ## 0.1.0
228 |
229 | - Migration to trips v2 methods.
230 | - Updated native Roam SDK versions. Android v0.1.7 and iOS v0.1.4
231 |
232 | ## 0.1.1
233 |
234 | - Updated native Roam SDK android v0.1.9 and iOS v0.1.5
235 |
236 | ## 0.1.2
237 |
238 | - Updated native Roam SDK for iOS v0.1.6
239 |
240 | ## 0.1.3
241 |
242 | - Updated native Roam SDK for iOS v0.1.7 and android v0.1.10
243 | - Fixed `Roam.unSubscribe()` crash
244 | - Added `Roam.checkActivityPermission` and `Roam.requestActivityPermission()` methods
245 |
246 | ## 0.1.4
247 |
248 | - Update native Roam SDK for android v0.1.11 and iOS v0.1.8
249 |
250 | ## 0.1.5
251 |
252 | - Added support for receiving events
253 |
254 | ## 0.1.6
255 |
256 | - Update native Roam SDK for android v0.1.13
257 |
258 | ## 0.1.7
259 |
260 | - Update native Roam SDK for android v0.1.14
261 |
262 | ## 0.1.8
263 |
264 | - Update native Roam SDK for android v0.1.19 and iOS v0.1.14
265 |
266 | ## 0.1.9
267 |
268 | - Update native Roam SDK for android v0.1.21 and iOS v0.1.17
269 |
270 | ## 0.1.10
271 |
272 | - Update native Roam SDK for android v0.1.23 and iOS v0.1.19
273 |
274 | ## 0.1.11
275 |
276 | - Update native Roam SDK for iOS v0.1.25
277 | - Trip summary response fix for iOS
278 |
279 | ## 0.1.12
280 |
281 | - Update native Roam SDK for iOS v0.1.26 and Android v0.1.28
282 | - Trip summary response fix for Android
283 |
284 | ## 0.1.13
285 |
286 | - Update native Roam SDK for iOS v0.1.26 to use only Roam core module.
287 | - Trip summary response fix for Android
288 |
289 | ## 0.1.14
290 |
291 | - Update native Roam SDK for iOS v0.1.27 to use only Roam core module.
292 |
293 | ## 0.1.15
294 |
295 | - Update native Roam SDK for iOS v0.1.28 to use only Roam core module.
296 |
297 | ## 0.1.16
298 |
299 | - Update native Roam SDK for iOS v0.1.29 to use only Roam core module.
300 |
301 | ## 0.1.18
302 |
303 | - Update native Roam SDK for Android v0.1.32
304 |
305 | ## 0.1.19
306 |
307 | - Update native Roam SDK for Android v0.1.34
308 |
309 | ## 0.1.20
310 |
311 | - Updated the Roam SDK to latest versions.
312 |
313 | ## 0.1.21
314 |
315 | - Updated the Roam SDK to latest versions.
316 | - Added geofencing methods
317 | - Added additional data points to location listener
318 |
319 | ## 0.1.22
320 |
321 | - Updated the Roam SDK to latest versions.
322 | - Added additional data points to location listener
323 |
324 | ## 0.2.0-beta.1
325 |
326 | - Updated the Roam SDK to the latest version.
327 | - Integrated GCP support.
328 |
329 | ## 0.2.0-beta.2
330 |
331 | - Updated the Roam SDK to the latest version.
332 | - Added support for the New Architecture.
333 |
334 | ## 0.2.0
335 |
336 | - Updated the Roam SDK to the latest version.
337 | - Added support for the New Architecture.
338 | - Integrated GCP support.
339 |
340 | ## 0.1.22-beta.1
341 |
342 | - Updated the Roam SDK to the latest version.
343 | - Added support for the New Architecture.
344 | - Offline trips.
345 |
346 | ## 0.1.22-beta.2
347 |
348 | - Updated the Roam SDK to the latest version.
349 | - Fixed the offline trips issue.
350 |
351 | ## 0.1.23
352 |
353 | - Updated the Roam SDK to the latest version.
354 | - Fixed the offline trips issue.
355 | - Updated GCP initialization process.
356 |
357 | ## 0.1.24
358 |
359 | - Updated the Roam SDK to the latest version.
360 | - Fixed the AWS framework issue.
361 |
362 | ## 0.1.25
363 |
364 | - Updated the Roam SDK to the latest version.
365 | - Fixed the distance tracking issue
366 |
--------------------------------------------------------------------------------
/artifacts/index.js:
--------------------------------------------------------------------------------
1 | import { NativeEventEmitter, NativeModules } from "react-native";
2 | if (!NativeModules.RNRoam) {
3 | throw new Error("NativeModules.RNRoam is undefined");
4 | }
5 | const eventEmitter = new NativeEventEmitter(NativeModules.RNRoam);
6 | const TrackingMode = {
7 | ACTIVE: "ACTIVE",
8 | BALANCED: "BALANCED",
9 | PASSIVE: "PASSIVE",
10 | };
11 | const DesiredAccuracy = {
12 | HIGH: "HIGH",
13 | MEDIUM: "MEDIUM",
14 | LOW: "LOW",
15 | };
16 | const AppState = {
17 | ALWAYS_ON: "ALWAYS_ON",
18 | FOREGROUND: "FOREGROUND",
19 | BACKGROUND: "BACKGROUND",
20 | };
21 | const DesiredAccuracyIOS = {
22 | BESTFORNAVIGATION: "BESTFORNAVIGATION",
23 | BEST: "BEST",
24 | NEAREST_TEN_METERS: "NEAREST_TEN_METERS",
25 | HUNDRED_METERS: "HUNDRED_METERS",
26 | KILO_METERS: "KILO_METERS",
27 | THREE_KILOMETERS: "THREE_KILOMETERS",
28 | };
29 | const ActivityType = {
30 | OTHER: "OTHER",
31 | AUTO_NAVIGATION: "AUTO_NAVIGATION",
32 | OTHER_NAVIGATION: "OTHER_NAVIGATION",
33 | FITNESS: "FITNESS",
34 | };
35 | const SubscribeListener = {
36 | EVENTS: "EVENTS",
37 | LOCATION: "LOCATION",
38 | BOTH: "BOTH",
39 | };
40 | const Publish = {
41 | APP_ID: "APP_ID",
42 | USER_ID: "USER_ID",
43 | GEOFENCE_EVENTS: "GEOFENCE_EVENTS",
44 | LOCATION_EVENTS: "LOCATION_EVENTS",
45 | NEARBY_EVENTS: "NEARBY_EVENTS",
46 | TRIPS_EVENTS: "TRIPS_EVENTS",
47 | LOCATION_LISTENER: "LOCATION_LISTENER",
48 | EVENT_LISTENER: "EVENT_LISTENER",
49 | ALTITUDE: "ALTITUDE",
50 | COURSE: "COURSE",
51 | SPEED: "SPEED",
52 | VERTICAL_ACCURACY: "VERTICAL_ACCURACY",
53 | HORIZONTAL_ACCURACY: "HORIZONTAL_ACCURACY",
54 | APP_CONTEXT: "APP_CONTEXT",
55 | ALLOW_MOCKED: "ALLOW_MOCKED",
56 | BATTERY_REMAINING: "BATTERY_REMAINING",
57 | BATTERY_SAVER: "BATTERY_SAVER",
58 | BATTERY_STATUS: "BATTERY_STATUS",
59 | ACTIVITY: "ACTIVITY",
60 | AIRPLANE_MODE: "AIRPLANE_MODE",
61 | DEVICE_MANUFACTURE: "DEVICE_MANUFACTURE",
62 | DEVICE_MODEL: "DEVICE_MODEL",
63 | TRACKING_MODE: "TRACKING_MODE",
64 | LOCATIONPERMISSION: "LOCATIONPERMISSION",
65 | NETWORK_STATUS: "NETWORK_STATUS",
66 | GPS_STATUS: "GPS_STATUS",
67 | OS_VERSION: "OS_VERSION",
68 | RECORDERD_AT: "RECORDERD_AT",
69 | TZ_OFFSET: "TZ_OFFSET",
70 | };
71 | const createUser = (description, successCallback, errorCallback) => {
72 | NativeModules.RNRoam.createUser(description, successCallback, errorCallback);
73 | };
74 | const getUser = (userid, successCallback, errorCallback) => {
75 | NativeModules.RNRoam.getUser(userid, successCallback, errorCallback);
76 | };
77 | const setDescription = (description) => {
78 | NativeModules.RNRoam.setDescription(description);
79 | };
80 | const toggleEvents = (geofence, trip, location, movingGeofence, successCallback, errorCallback) => {
81 | NativeModules.RNRoam.toggleEvents(geofence, trip, location, movingGeofence, successCallback, errorCallback);
82 | };
83 | const toggleListener = (location, event, successCallback, errorCallback) => {
84 | NativeModules.RNRoam.toggleListener(location, event, successCallback, errorCallback);
85 | };
86 | const getEventsStatus = (successCallback, errorCallback) => {
87 | NativeModules.RNRoam.getEventsStatus(successCallback, errorCallback);
88 | };
89 | const getListenerStatus = (successCallback, errorCallback) => {
90 | NativeModules.RNRoam.getListenerStatus(successCallback, errorCallback);
91 | };
92 | const subscribe = (type, userid) => {
93 | NativeModules.RNRoam.subscribe(type, userid);
94 | };
95 | const unSubscribe = (type, userid) => {
96 | NativeModules.RNRoam.unSubscribe(type, userid);
97 | };
98 | const subscribeTripStatus = (tripId) => {
99 | NativeModules.RNRoam.subscribeTripStatus(tripId);
100 | };
101 | const unSubscribeTripStatus = (tripId) => {
102 | NativeModules.RNRoam.unSubscribeTripStatus(tripId);
103 | };
104 | const disableBatteryOptimization = () => {
105 | NativeModules.RNRoam.disableBatteryOptimization();
106 | };
107 | const isBatteryOptimizationEnabled = (callback) => {
108 | NativeModules.RNRoam.isBatteryOptimizationEnabled(callback);
109 | };
110 | const checkLocationPermission = (callback) => {
111 | NativeModules.RNRoam.checkLocationPermission(callback);
112 | };
113 | const checkLocationServices = (callback) => {
114 | NativeModules.RNRoam.checkLocationServices(callback);
115 | };
116 | const checkBackgroundLocationPermission = (callback) => {
117 | NativeModules.RNRoam.checkBackgroundLocationPermission(callback);
118 | };
119 | const locationPermissionStatus = (callback) => {
120 | NativeModules.RNRoam.locationPermissionStatus(callback);
121 | };
122 | const requestLocationPermission = () => {
123 | NativeModules.RNRoam.requestLocationPermission();
124 | };
125 | const requestLocationServices = () => {
126 | NativeModules.RNRoam.requestLocationServices();
127 | };
128 | const requestBackgroundLocationPermission = () => {
129 | NativeModules.RNRoam.requestBackgroundLocationPermission();
130 | };
131 | const createTrip = (offline, successCallback, errorCallback) => {
132 | NativeModules.RNRoam.createTrip(offline, successCallback, errorCallback);
133 | };
134 | const startTrip = (tripId, description, successCallback, errorCallback) => {
135 | NativeModules.RNRoam.startTrip(tripId, description, successCallback, errorCallback);
136 | };
137 | const resumeTrip = (tripId, successCallback, errorCallback) => {
138 | NativeModules.RNRoam.resumeTrip(tripId, successCallback, errorCallback);
139 | };
140 | const pauseTrip = (tripId, successCallback, errorCallback) => {
141 | NativeModules.RNRoam.pauseTrip(tripId, successCallback, errorCallback);
142 | };
143 | const getTripSummary = (tripId, successCallback, errorCallback) => {
144 | NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback);
145 | };
146 | const stopTrip = (tripId, successCallback, errorCallback) => {
147 | NativeModules.RNRoam.stopTrip(tripId, successCallback, errorCallback);
148 | };
149 | const forceStopTrip = (tripId, successCallback, errorCallback) => {
150 | NativeModules.RNRoam.forceStopTrip(tripId, successCallback, errorCallback);
151 | };
152 | const deleteTrip = (tripId, successCallback, errorCallback) => {
153 | NativeModules.RNRoam.deleteTrip(tripId, successCallback, errorCallback);
154 | };
155 | const syncTrip = (tripId, successCallback, errorCallback) => {
156 | NativeModules.RNRoam.syncTrip(tripId, successCallback, errorCallback);
157 | };
158 | const activeTrips = (offline, successCallback, errorCallback) => {
159 | NativeModules.RNRoam.activeTrips(offline, successCallback, errorCallback);
160 | };
161 | const publishOnly = (array, jsonMetadata) => {
162 | NativeModules.RNRoam.publishOnly(array, jsonMetadata);
163 | };
164 | const publishAndSave = (jsonMetadata) => {
165 | NativeModules.RNRoam.publishAndSave(jsonMetadata);
166 | };
167 | const stopPublishing = () => {
168 | NativeModules.RNRoam.stopPublishing();
169 | };
170 | const startTracking = (trackingMode) => {
171 | NativeModules.RNRoam.startTracking(trackingMode);
172 | };
173 | const startTrackingCustom = (allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval) => {
174 | NativeModules.RNRoam.startTrackingCustom(allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval);
175 | };
176 | const startSelfTrackingCustom = (allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval) => {
177 | NativeModules.RNRoam.startSelfTrackingCustom(allowBackground, pauseAutomatic, activityType, desiredAccuracy, showBackIndicator, distanceFilter, accuracyFilter, updateInterval);
178 | };
179 | const startTrackingTimeInterval = (timeInterval, desiredAccuracy) => {
180 | NativeModules.RNRoam.startTrackingTimeInterval(timeInterval, desiredAccuracy);
181 | };
182 | const startTrackingDistanceInterval = (distance, stationary, desiredAccuracy) => {
183 | NativeModules.RNRoam.startTrackingDistanceInterval(distance, stationary, desiredAccuracy);
184 | };
185 | const stopTracking = () => {
186 | NativeModules.RNRoam.stopTracking();
187 | };
188 | const isLocationTracking = (callback) => {
189 | NativeModules.RNRoam.isLocationTracking(callback);
190 | };
191 | const allowMockLocation = (enabled) => {
192 | NativeModules.RNRoam.allowMockLocation(enabled);
193 | };
194 | const getCurrentLocationListener = (accuracy) => {
195 | NativeModules.RNRoam.getCurrentLocationListener(accuracy);
196 | };
197 | const getCurrentLocation = (desiredAccuracy, accuracy, successCallback, errorCallback) => {
198 | NativeModules.RNRoam.getCurrentLocation(desiredAccuracy, accuracy, successCallback, errorCallback);
199 | };
200 | const updateCurrentLocation = (desiredAccuracy, accuracy) => {
201 | NativeModules.RNRoam.updateCurrentLocation(desiredAccuracy, accuracy);
202 | };
203 | const getCurrentLocationIos = (accuracy, successCallback, errorCallback) => {
204 | NativeModules.RNRoam.getCurrentLocationIos(accuracy, successCallback, errorCallback);
205 | };
206 | const updateCurrentLocationIos = (accuracy) => {
207 | NativeModules.RNRoam.updateCurrentLocationIos(accuracy);
208 | };
209 | const logout = (successCallback, errorCallback) => {
210 | NativeModules.RNRoam.logout(successCallback, errorCallback);
211 | };
212 | const setTrackingInAppState = (appState) => {
213 | NativeModules.RNRoam.setTrackingInAppState(appState);
214 | };
215 | const offlineLocationTracking = (enabled) => {
216 | NativeModules.RNRoam.offlineLocationTracking(enabled);
217 | };
218 | const startSelfTracking = (trackingMode) => {
219 | NativeModules.RNRoam.startSelfTracking(trackingMode);
220 | };
221 | const startSelfTrackingTimeInterval = (timeInterval, desiredAccuracy) => {
222 | NativeModules.RNRoam.startSelfTrackingTimeInterval(timeInterval, desiredAccuracy);
223 | };
224 | const startSelfTrackingDistanceInterval = (distance, stationary, desiredAccuracy) => {
225 | NativeModules.RNRoam.startSelfTrackingDistanceInterval(distance, stationary, desiredAccuracy);
226 | };
227 | const stopSelfTracking = () => {
228 | NativeModules.RNRoam.stopSelfTracking();
229 | };
230 | const enableAccuracyEngine = () => {
231 | NativeModules.RNRoam.enableAccuracyEngine();
232 | };
233 | const disableAccuracyEngine = () => {
234 | NativeModules.RNRoam.disableAccuracyEngine();
235 | };
236 | const startListener = (event, callback) => (eventEmitter.addListener(event, callback));
237 | const stopListener = (event, callback) => {
238 | if (callback) {
239 | eventEmitter.removeListener(event, callback);
240 | }
241 | else {
242 | eventEmitter.removeAllListeners(event);
243 | }
244 | };
245 | const Roam = {
246 | TrackingMode,
247 | DesiredAccuracy,
248 | AppState,
249 | DesiredAccuracyIOS,
250 | ActivityType,
251 | SubscribeListener,
252 | Publish,
253 | createUser,
254 | getUser,
255 | setDescription,
256 | toggleEvents,
257 | toggleListener,
258 | getEventsStatus,
259 | getListenerStatus,
260 | subscribe,
261 | unSubscribe,
262 | subscribeTripStatus,
263 | unSubscribeTripStatus,
264 | disableBatteryOptimization,
265 | isBatteryOptimizationEnabled,
266 | checkLocationPermission,
267 | checkLocationServices,
268 | checkBackgroundLocationPermission,
269 | requestLocationPermission,
270 | requestLocationServices,
271 | requestBackgroundLocationPermission,
272 | locationPermissionStatus,
273 | createTrip,
274 | startTrip,
275 | resumeTrip,
276 | pauseTrip,
277 | stopTrip,
278 | forceStopTrip,
279 | deleteTrip,
280 | syncTrip,
281 | activeTrips,
282 | publishOnly,
283 | publishAndSave,
284 | stopPublishing,
285 | startTracking,
286 | startTrackingCustom,
287 | startSelfTrackingCustom,
288 | startTrackingTimeInterval,
289 | startTrackingDistanceInterval,
290 | stopTracking,
291 | isLocationTracking,
292 | allowMockLocation,
293 | getCurrentLocationListener,
294 | getCurrentLocation,
295 | updateCurrentLocation,
296 | getCurrentLocationIos,
297 | updateCurrentLocationIos,
298 | logout,
299 | setTrackingInAppState,
300 | offlineLocationTracking,
301 | startSelfTracking,
302 | startSelfTrackingTimeInterval,
303 | startSelfTrackingDistanceInterval,
304 | stopSelfTracking,
305 | enableAccuracyEngine,
306 | disableAccuracyEngine,
307 | startListener,
308 | stopListener,
309 | getTripSummary,
310 | };
311 | export default Roam;
312 | //# sourceMappingURL=index.js.map
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | [](https://badge.fury.io/js/roam-reactnative)
9 | [](https://github.com/geosparks/roam-reactnative/actions/workflows/main.yml)
10 |
11 | # Official Roam React Native SDK
12 |
13 | This is the official [Roam](https://roam.ai) iOS SDK developed and maintained by Roam B.V
14 |
15 | Note: Before you get started [signup to our dashboard](https://roam.ai/dashboard/signup) to get your API Keys.
16 |
17 | ## Featured Apps
18 |
19 |
20 |
21 |
22 | # Quick Start
23 |
24 | 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.
25 |
26 | ### Requirements
27 |
28 | To use the Roam SDK, the following things are required:
29 | Get yourself a free Roam Account. No credit card required.
30 |
31 | - [x] Create a project and add an iOS app to the project.
32 | - [x] You need the SDK_KEY in your project settings which you’ll need to initialize the SDK.
33 | - [x] Now you’re ready to integrate the SDK into your React Native application.
34 |
35 | # Add the Roam React Native SDK to your app
36 |
37 | In your project directory, install from npm or yarn, and then link it.
38 |
39 | ```bash
40 | //npm
41 | npm install --save roam-reactnative
42 |
43 | //yarn
44 | yarn add roam-reactnative
45 | ```
46 |
47 | If using React Native version of 0.60 or greater, autolinking is now done automatically so you can skip this step.
48 |
49 | ```
50 | //React Native
51 | react-native link roam-reactnative
52 |
53 | //Expo
54 | expo install roam-reactnative
55 | ```
56 |
57 | Minimum supported versions
58 |
59 | ```
60 | react-native: 0.41.2
61 | react: 15.4.2
62 | ```
63 |
64 | Before making any changes to your javascript code, you would need to integrate and initialize Roam SDK in your Android and iOS applications.
65 |
66 | ### Android
67 |
68 | 1. Add the following to the build script `{repositories {}}` section of the `build.gradle` (Project)file
69 |
70 | ```java
71 | mavenCentral()
72 | ```
73 |
74 | 2. Install the SDK to your project via `Gradle` in Android Studio, add the maven below in your project `build.gradle` file.
75 |
76 | ```java
77 | repositories {
78 | maven {
79 | url 'https://com-roam-android.s3.amazonaws.com/'
80 | }
81 | }
82 | ```
83 |
84 | 3. Add the dependencies below in your `app build.gradle` file. Then sync Gradle.
85 |
86 | ```
87 | dependencies {
88 | implementation 'com.roam.sdk:roam-android:0.1.42-beta.2'
89 | }
90 | ```
91 |
92 | 4. Before initializing the SDK, the below must be imported in your Main Activity.
93 |
94 | ```java
95 | import com.roam.sdk.Roam;
96 | ```
97 |
98 | 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.
99 |
100 | ```java
101 | Roam.initializeSimplifiedSDK(this, "YOUR-SDK-KEY-GOES-HERE");
102 | ```
103 |
104 | ### iOS
105 |
106 | 1. Run `cd ios` && `pod install`
107 | 2. Then, configure the information property list file `Info.plist` with an XML snippet that contains data about your app. You need to add strings for `NSLocationWhenInUseUsageDescription` in the `Info.plist` file to prompt the user during location permissions for foreground location tracking. For background location tracking, you also need to add a string for `NSLocationAlwaysUsageDescription` and `NSLocationAlwaysAndWhenInUseUsageDescription` in the same` Info.plist` file.
108 |
109 | ```xml
110 | NSLocationWhenInUseUsageDescription
111 | Add description for foreground only location usage.
112 | NSLocationAlwaysUsageDescription
113 | Add description for background location usage. iOS 10 and below"
114 | NSLocationAlwaysAndWhenInUseUsageDescription
115 | Add description for background location usage. iOS 11 and above
116 | ```
117 |
118 | 
119 |
120 | 3. Next you need to enable`Background fetch` and` Location updates` under `Project Setting` > `Capabilities` > `Background Modes`.
121 |
122 | 
123 |
124 | 4. Import Roam into your `AppDelegate` file.
125 |
126 | ```objective-c
127 | #import
128 | ```
129 |
130 | 5. Initialize the SDK in your `AppDelegate` class before calling any other Roam methods under this `application:didFinishLaunchingWithOptions:`
131 |
132 | ```objective-c
133 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
134 | {
135 | [Roam initialize:@"YOUR-PUBLISHABLE-KEY" :NULL :NULL];
136 | }
137 | ```
138 |
139 | ### Manual Linking
140 |
141 | 1. Open the iOS module files, located inside `node_modules/roam-reactnative/ios/`.
142 | 2. Open the app workspace file `(AppName.xcworkspace)` in Xcode.
143 | 3. Move the `RNRoam.h` and `RNRoam.m` files to your project. When shown a popup window, select `Create groups`.
144 |
145 | # Finally, lets do some javascript
146 |
147 | ## Import module
148 |
149 | First, import the module.
150 |
151 | ```javascript
152 | import Roam from "roam-reactnative";
153 | ```
154 |
155 | ## Creating Users
156 |
157 | 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.
158 |
159 | ```javascript
160 | Roam.createUser(
161 | "SET-USER-DESCRIPTION-HERE",
162 | (success) => {
163 | // do something on success
164 | },
165 | (error) => {
166 | // do something on error
167 | },
168 | );
169 | ```
170 |
171 | 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.
172 |
173 | You can always set or update user descriptions later using the below code.
174 |
175 | ```javascript
176 | Roam.setDescription("SET-USER-DESCRIPTION-HERE");
177 | ```
178 |
179 | 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.
180 |
181 | ```javascript
182 | Roam.getUser(
183 | "ROAM-USER-ID",
184 | (success) => {
185 | // do something on success
186 | },
187 | (error) => {
188 | // do something on error
189 | },
190 | );
191 | ```
192 |
193 | ## Request Permissions
194 |
195 | Get location permission from the App user on the device. Also check if the user has turned on location services for the device.
196 |
197 | ```javascript
198 | // Call this method to check Location Permission for Android & iOS
199 | Roam.checkLocationPermission( status => {
200 | // do something with status
201 | });
202 |
203 | // Call this method to request Location Permission for Android & iOS
204 | Roam.requestLocationPermission();
205 | ```
206 |
207 | ### Android
208 |
209 | ```javascript
210 | // Call this method to check Location services for Android
211 | Roam.checkLocationServices( status => {
212 | // do something with status
213 | });
214 | // Call this method to request Location services for Android
215 | Roam.requestLocationServices();
216 | ```
217 |
218 | In case of devices running above Anroid 10, you would need to get background location permissions to track locations in background.
219 |
220 | ```javascript
221 | // Call this method to check background location permission for Android
222 | Roam.checkBackgroundLocationPermission((status) => {
223 | // do something with status
224 | });
225 | // Call this method to request background location Permission for Android
226 | Roam.requestBackgroundLocationPermission();
227 | ```
228 |
229 | ### SDK Configurations
230 |
231 | #### Accuracy Engine
232 |
233 | For enabling accuracy engine for Passive, Active, and Balanced tracking.
234 |
235 | ```javascript
236 | Roam.enableAccuracyEngine();
237 | ```
238 |
239 | For Custom tracking mores, you can pass the desired accuracy values in integers ranging from 25-150m.
240 |
241 | ```javascript
242 | Roam.enableAccuracyEngine(50);
243 | ```
244 |
245 | To disable accuracy engine
246 |
247 | ```javascript
248 | Roam.disableAccuracyEngine();
249 | ```
250 |
251 | #### Offline Location Tracking
252 |
253 | To modify the offline location tracking configuration, which will enabled by default.
254 |
255 | ```javascript
256 | Roam.offlineLocationTracking(true);
257 | ```
258 |
259 | #### Allow Mock Location Tracking
260 |
261 | To allow mock location tracking during development, use the below code. This will be disabled by default.
262 |
263 | ```javascript
264 | Roam.allowMockLocation(true);
265 | ```
266 |
267 | ## Location Tracking
268 |
269 | ### Start Tracking
270 |
271 | Use the tracking modes while you use the startTracking method `Roam.startTracking`
272 |
273 | ```javascript
274 | Roam.startTracking(TrackingMode);
275 | ```
276 |
277 | ### Tracking Modes
278 |
279 | Roam has three default tracking modes along with a custom version. They differ based on the frequency of location updates and battery consumption. The higher the frequency, the higher is the battery consumption. You must use [foreground service](https://developer.android.com/about/versions/oreo/background-location-limits) for continuous tracking.
280 |
281 | | **Mode** | **Battery usage** | **Updates every** | **Optimised for/advised for** |
282 | | -------- | ----------------- | ----------------- | ----------------------------- |
283 | | ACTIVE | 6% - 12% | 25 ~ 250 meters | Ride Hailing / Sharing |
284 | | BALANCED | 3% - 6% | 50 ~ 500 meters | On Demand Services |
285 | | PASSIVE | 0% - 1% | 100 ~ 1000 meters | Social Apps |
286 |
287 | ```javascript
288 | // active tracking
289 | Roam.startTracking("ACTIVE");
290 | // balanced tracking
291 | Roam.startTracking("BALANCED");
292 | // passive tracking
293 | Roam.startTracking("PASSIVE");
294 | ```
295 |
296 | ### Custom Tracking Modes
297 |
298 | The SDK also allows you define a custom tracking mode that allows you to
299 | customize and build your own tracking modes.
300 |
301 | #### Android
302 |
303 | | **Type** | **Unit** | **Unit Range** |
304 | | ----------------- | -------- | -------------- |
305 | | Distance Interval | Meters | 1m ~ 2500m |
306 | | Time Interval | Seconds | 10s ~ 10800s |
307 |
308 | **Android: Distance between location updates:**
309 |
310 | ```javascript
311 | //Update location based on distance between locations.
312 | Roam.startTrackingDistanceInterval(
313 | "DISTANCE IN METERS",
314 | "STATIONARY DURATION IN SECONDS",
315 | Roam.DesiredAccuracy.HIGH,
316 | );
317 | ```
318 |
319 | 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.
320 |
321 | Below is the example for distance based tracking with distance interval as 10m and stationary duration as 2 minutes.
322 |
323 | ```javascript
324 | //Update location based on distance between locations.
325 | Roam.startTrackingDistanceInterval(10, 120, Roam.DesiredAccuracy.HIGH);
326 | ```
327 |
328 | **Android: Time between location updates:**
329 |
330 | ```javascript
331 | //Update location based on time interval.
332 | Roam.startTrackingTimeInterval(
333 | "INTERVAL IN SECONDS",
334 | Roam.DesiredAccuracy.HIGH,
335 | );
336 | ```
337 |
338 | Here, the `INTERVAL IN SECONDS` refers to time interval for location tracking.
339 |
340 | Below is the example for time based tracking with time interval as 10s.
341 |
342 | ```javascript
343 | //Update location based on time interval.
344 | Roam.startTrackingTimeInterval(10, Roam.DesiredAccuracy.HIGH);
345 | ```
346 |
347 | #### iOS
348 |
349 | We have a single method for iOS which can perfrom both time and distance based tracking based on the input parameters.
350 |
351 | ```javascript
352 | // Update location on distance interval
353 | Roam.startTrackingCustom(
354 | allowBackground,
355 | pauseAutomatic,
356 | activityType,
357 | desiredAccuracy,
358 | showBackIndicator,
359 | distanceFilter,
360 | accuracyFilter,
361 | updateInterval,
362 | );
363 | ```
364 |
365 | **iOS: Distance between location updates:**
366 |
367 | Here, the `distanceFilter` refers to distance interval for location tracking which should be in meters. To achieve distance based tracking, the `updateInterval` value should be 0.
368 |
369 | Below is the example for distance based tracking with distance interval as 20 meters.
370 |
371 | ```javascript
372 | Roam.startTrackingCustom(
373 | true, // allowBackground
374 | false, // pauseAutomatic
375 | Roam.ActivityType.FITNESS, // activityType
376 | Roam.DesiredAccuracyIOS.BEST, // desiredAccuracy
377 | true, // showBackIndicator
378 | 20, // distanceFilter
379 | 10, // accuracyFilter
380 | 0, // updateInterval
381 | );
382 | ```
383 |
384 | **iOS: Time between location updates:**
385 |
386 | ```javascript
387 | // Update location on time interval
388 | Roam.startTrackingCustom(
389 | allowBackground,
390 | pauseAutomatic,
391 | activityType,
392 | desiredAccuracy,
393 | showBackIndicator,
394 | distanceFilter,
395 | accuracyFilter,
396 | updateInterval,
397 | );
398 | ```
399 |
400 | 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.
401 |
402 | Below is the example for time based tracking with time interval as 120s.
403 |
404 | ```javascript
405 | Roam.startTrackingCustom(
406 | true, // allowBackground
407 | false, // pauseAutomatic
408 | Roam.ActivityType.FITNESS, // activityType
409 | Roam.DesiredAccuracyIOS.BEST, // desiredAccuracy
410 | true, // showBackIndicator
411 | 0, // distanceFilter
412 | 10, // accuracyFilter
413 | 120, // updateInterval
414 | );
415 | ```
416 |
417 | ### Update Location When Stationary
418 |
419 | By using this method updateLocationWhenStationary , location will update every x seconds when device goes to stationary state.
420 |
421 | Note: It will work on all tracking modes ie. active, passive, balance and distance based custom tracking except time based custom tracking.
422 |
423 | ```javascript
424 | Roam.updateLocationWhenStationary(interval);
425 | ```
426 |
427 | For example, to update location every 60s when the user becomes stationary, use the below code.
428 |
429 | ```javascript
430 | Roam.updateLocationWhenStationary(60);
431 | ```
432 |
433 | ## Stop Tracking
434 |
435 | To stop the tracking use the below method.
436 |
437 | ```javascript
438 | Roam.stopTracking();
439 | ```
440 |
441 | ## Publish Messages
442 |
443 | It will both publish location data and these data will be sent to Roam servers for further processing and data will be saved in our database servers.
444 | We will now have an option to send meta-data as a parameter along with location updates in the below json format.
445 |
446 | ```javascript
447 | Roam.publishAndSave(metadataJSON);
448 | ```
449 |
450 | Example
451 |
452 | ```javascript
453 | //Metadata is not mandatory
454 | let metadataJSON = { METADATA: { 1: true, 2: true, 3: true } };
455 |
456 | Roam.publishAndSave(metadataJSON);
457 | optional;
458 | Roam.publishAndSave(null);
459 | ```
460 |
461 | ## Stop Publishing
462 |
463 | It will stop publishing the location data to other clients.
464 |
465 | ```javascript
466 | Roam.stopPublishing();
467 | ```
468 |
469 | ## Subscribe Messages
470 |
471 | 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.
472 |
473 | ### Subscribe
474 |
475 | ```javascript
476 | Roam.subscribe(TYPE, "USER-ID");
477 | ```
478 |
479 | | **Type** | **Description** |
480 | | -------- | ----------------------------------------------------------------------------- |
481 | | LOCATION | Subscribe to your own location (or) other user's location updates. |
482 | | EVENTS | Subscribe to your own events. |
483 | | BOTH | Subscribe to your own events and location (or) other user's location updates. |
484 |
485 | ### UnSubscribe
486 |
487 | ```javascript
488 | Roam.unSubscribe(TYPE, "USER-ID");
489 | ```
490 |
491 | You can pass `user_id` as empty string to unsubscribe from all the users.
492 |
493 | ## Listeners
494 |
495 | 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.
496 |
497 | 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.
498 |
499 | ```javascript
500 | Roam.toggleListener(
501 | true,
502 | true,
503 | (success) => {
504 | // do something on success
505 | },
506 | (error) => {
507 | // do something on error
508 | },
509 | );
510 | ```
511 |
512 | Once the listener toggles are set to true, to listen to location updates and events.
513 |
514 | Note: The location data received will be an array with either single or multiple location data.
515 |
516 | ```javascript
517 | Roam.startListener("location", (location) => {
518 | // do something on location received
519 | console.log("Location", location);
520 | // Console Output:
521 | // [{"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"},{..}...]
522 | });
523 | ```
524 |
525 | You can also configure batch setting for the location receiver. To set the batch configuration, you need to pass batch count and batch window.
526 |
527 | ```javascript
528 | Roam.setBatchReceiverConfig(NETWORK_STATE, BATCH_COUNT, BATCH_WINDOW, success => {
529 | // do something on success
530 | //success.batchCount,
531 | //success.batchWindow,
532 | //success.networkState
533 | },
534 | error => {
535 | // do something on error
536 | //error.code
537 | //error.message
538 | }););
539 | ```
540 |
541 | | **Type** | **Description** |
542 | | ------------- | --------------------------------------- |
543 | | NETWORK_STATE | online (or) offline (or) both |
544 | | BATCH_COUNT | Integer value from 1-1000. Default as 1 |
545 | | BATCH_WINDOW | Integer value. Default as 0 |
546 |
547 | You can get the current configured settings with the below code.
548 |
549 | ```javascript
550 | Roam.getBatchReceiverConfig(
551 | (success) => {
552 | // do something on success
553 | //success.batchCount,
554 | //success.batchWindow,
555 | //success.networkState
556 | },
557 | (error) => {
558 | // do something on error
559 | //error.code
560 | //error.message
561 | },
562 | );
563 | ```
564 |
565 | You can reset the batch configuration to default values with the below code.
566 |
567 | ```javascript
568 | Roam.resetBatchReceiverConfig(
569 | (success) => {
570 | // do something on success
571 | //success.batchCount,
572 | //success.batchWindow,
573 | //success.networkState
574 | },
575 | (error) => {
576 | // do something on error
577 | //error.code
578 | //error.message
579 | },
580 | );
581 | ```
582 |
583 | ## Documentation
584 |
585 | Please visit our [Developer Center](https://github.com/geosparks/roam-reactnative/wiki) for instructions on other SDK methods.
586 |
587 | ## Contributing
588 |
589 | - For developing the SDK, please visit our [CONTRIBUTING.md](https://github.com/geosparks/roam-reactnative/blob/master/CONTRIBUTING.md) to get started.
590 |
591 | ## Need Help?
592 |
593 | 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).
--------------------------------------------------------------------------------
/js/index.js:
--------------------------------------------------------------------------------
1 | import { NativeEventEmitter, NativeModules, Platform } from 'react-native'
2 |
3 | if (!NativeModules.RNRoam) {
4 | throw new Error('NativeModules.RNRoam is undefined')
5 | }
6 |
7 | const eventEmitter = new NativeEventEmitter(NativeModules.RNRoam)
8 |
9 | const TrackingMode = {
10 | ACTIVE: 'ACTIVE',
11 | BALANCED: 'BALANCED',
12 | PASSIVE: 'PASSIVE',
13 | CUSTOM: 'CUSTOM'
14 | }
15 |
16 | const DesiredAccuracy = {
17 | HIGH: 'HIGH',
18 | MEDIUM: 'MEDIUM',
19 | LOW: 'LOW'
20 | }
21 |
22 | const NetworkState = {
23 | BOTH: 'BOTH',
24 | ONLINE: 'ONLINE',
25 | OFFLINE: 'OFFLINE'
26 | }
27 |
28 | const AppState = {
29 | ALWAYS_ON: 'ALWAYS_ON',
30 | FOREGROUND: 'FOREGROUND',
31 | BACKGROUND: 'BACKGROUND'
32 | }
33 |
34 | const Source = {
35 | ALL: 'ALL',
36 | LAST_KNOWN: 'LAST_KNOWN',
37 | GPS: 'GPS'
38 | }
39 |
40 | const DesiredAccuracyIOS = {
41 | BESTFORNAVIGATION: 'BESTFORNAVIGATION',
42 | BEST: 'BEST',
43 | NEAREST_TEN_METERS: 'NEAREST_TEN_METERS',
44 | HUNDRED_METERS: 'HUNDRED_METERS',
45 | KILO_METERS: 'KILO_METERS',
46 | THREE_KILOMETERS: 'THREE_KILOMETERS'
47 | }
48 |
49 | const ActivityType = {
50 | OTHER: 'OTHER',
51 | AUTO_NAVIGATION: 'AUTO_NAVIGATION',
52 | OTHER_NAVIGATION: 'OTHER_NAVIGATION',
53 | FITNESS: 'FITNESS'
54 | }
55 |
56 | const SubscribeListener = {
57 | EVENTS: 'EVENTS',
58 | LOCATION: 'LOCATION',
59 | BOTH: 'BOTH'
60 | }
61 |
62 | const Publish = {
63 | APP_ID: 'APP_ID',
64 | USER_ID: 'USER_ID',
65 | GEOFENCE_EVENTS: 'GEOFENCE_EVENTS',
66 | LOCATION_EVENTS: 'LOCATION_EVENTS',
67 | NEARBY_EVENTS: 'NEARBY_EVENTS',
68 | TRIPS_EVENTS: 'TRIPS_EVENTS',
69 | LOCATION_LISTENER: 'LOCATION_LISTENER',
70 | EVENT_LISTENER: 'EVENT_LISTENER',
71 | ALTITUDE: 'ALTITUDE',
72 | COURSE: 'COURSE',
73 | SPEED: 'SPEED',
74 | VERTICAL_ACCURACY: 'VERTICAL_ACCURACY',
75 | HORIZONTAL_ACCURACY: 'HORIZONTAL_ACCURACY',
76 | APP_CONTEXT: 'APP_CONTEXT',
77 | ALLOW_MOCKED: 'ALLOW_MOCKED',
78 | BATTERY_REMAINING: 'BATTERY_REMAINING',
79 | BATTERY_SAVER: 'BATTERY_SAVER',
80 | BATTERY_STATUS: 'BATTERY_STATUS',
81 | ACTIVITY: 'ACTIVITY',
82 | AIRPLANE_MODE: 'AIRPLANE_MODE',
83 | DEVICE_MANUFACTURE: 'DEVICE_MANUFACTURE',
84 | DEVICE_MODEL: 'DEVICE_MODEL',
85 | TRACKING_MODE: 'TRACKING_MODE',
86 | LOCATIONPERMISSION: 'LOCATIONPERMISSION',
87 | NETWORK_STATUS: 'NETWORK_STATUS',
88 | GPS_STATUS: 'GPS_STATUS',
89 | OS_VERSION: 'OS_VERSION',
90 | RECORDERD_AT: 'RECORDERD_AT',
91 | TZ_OFFSET: 'TZ_OFFSET'
92 | }
93 |
94 | const createUser = (description, successCallback, errorCallback) => {
95 | NativeModules.RNRoam.createUser(
96 | description,
97 | null,
98 | successCallback,
99 | errorCallback
100 | )
101 | }
102 |
103 | const getUser = (userid, successCallback, errorCallback) => {
104 | NativeModules.RNRoam.getUser(userid, successCallback, errorCallback)
105 | }
106 |
107 | const setDescription = (description) => {
108 | if (Platform.OS === 'android') {
109 | NativeModules.RNRoam.setDescription(description)
110 | } else {
111 | NativeModules.RNRoam.setDescription(description, null)
112 | }
113 | }
114 |
115 | const toggleEvents = (
116 | geofence,
117 | trip,
118 | location,
119 | movingGeofence,
120 | successCallback,
121 | errorCallback
122 | ) => {
123 | NativeModules.RNRoam.toggleEvents(
124 | geofence,
125 | trip,
126 | location,
127 | movingGeofence,
128 | successCallback,
129 | errorCallback
130 | )
131 | }
132 |
133 | const toggleListener = (location, event, successCallback, errorCallback) => {
134 | NativeModules.RNRoam.toggleListener(
135 | location,
136 | event,
137 | successCallback,
138 | errorCallback
139 | )
140 | }
141 |
142 | const getEventsStatus = (successCallback, errorCallback) => {
143 | NativeModules.RNRoam.getEventsStatus(successCallback, errorCallback)
144 | }
145 |
146 | const getListenerStatus = (successCallback, errorCallback) => {
147 | NativeModules.RNRoam.getListenerStatus(successCallback, errorCallback)
148 | }
149 |
150 | const subscribe = (type, userid) => {
151 | NativeModules.RNRoam.subscribe(type, userid)
152 | }
153 |
154 | const unSubscribe = (type, userid) => {
155 | NativeModules.RNRoam.unSubscribe(type, userid)
156 | }
157 |
158 | const disableBatteryOptimization = () => {
159 | NativeModules.RNRoam.disableBatteryOptimization()
160 | }
161 |
162 | const isBatteryOptimizationEnabled = (callback) => {
163 | NativeModules.RNRoam.isBatteryOptimizationEnabled(callback)
164 | }
165 |
166 | const checkLocationPermission = (callback) => {
167 | NativeModules.RNRoam.checkLocationPermission(callback)
168 | }
169 |
170 | const checkLocationServices = (callback) => {
171 | NativeModules.RNRoam.checkLocationServices(callback)
172 | }
173 |
174 | const checkBackgroundLocationPermission = (callback) => {
175 | NativeModules.RNRoam.checkBackgroundLocationPermission(callback)
176 | }
177 |
178 | const locationPermissionStatus = (callback) => {
179 | NativeModules.RNRoam.locationPermissionStatus(callback)
180 | }
181 |
182 | const requestLocationPermission = () => {
183 | NativeModules.RNRoam.requestLocationPermission()
184 | }
185 |
186 |
187 |
188 | const requestPhoneStatePermission = () => {
189 | NativeModules.RNRoam.requestPhoneStatePermission()
190 | }
191 |
192 | const requestLocationServices = () => {
193 | NativeModules.RNRoam.requestLocationServices()
194 | }
195 |
196 | const requestBackgroundLocationPermission = () => {
197 | NativeModules.RNRoam.requestBackgroundLocationPermission()
198 | }
199 |
200 | // -------- Trips V2 ----------
201 |
202 | class RoamTrip {
203 | constructor (metadata, description, name, stops, isLocal, tripId, userId) {
204 | this.metadata = metadata
205 | this.description = description
206 | this.name = name
207 | this.stops = stops
208 | this.isLocal = isLocal
209 | this.tripId = tripId
210 | this.userId = userId
211 | }
212 | }
213 |
214 | class RoamTripStop {
215 | constructor (
216 | id,
217 | metadata,
218 | description,
219 | name,
220 | address,
221 | geometryRadius,
222 | geometry
223 | ) {
224 | this.id = id
225 | this.metadata = metadata
226 | this.description = description
227 | this.name = name
228 | this.address = address
229 | this.geometryRadius = geometryRadius
230 | this.geometry = geometry
231 | }
232 | }
233 |
234 | class RoamCustomTrackingOptions {
235 | constructor (
236 | desiredAccuracy,
237 | updateInterval,
238 | distanceFilter,
239 | stopDuration,
240 | activityType,
241 | desiredAccuracyIOS,
242 | allowBackgroundLocationUpdates,
243 | pausesLocationUpdatesAutomatically,
244 | showsBackgroundLocationIndicator,
245 | accuracyFilter
246 | ) {
247 | this.desiredAccuracy = desiredAccuracy
248 | this.updateInterval = updateInterval
249 | this.distanceFilter = distanceFilter
250 | this.stopDuration = stopDuration
251 | this.activityType = activityType
252 | this.desiredAccuracyIOS = desiredAccuracyIOS
253 | this.allowBackgroundLocationUpdates = allowBackgroundLocationUpdates
254 | this.pausesLocationUpdatesAutomatically =
255 | pausesLocationUpdatesAutomatically
256 | this.showsBackgroundLocationIndicator = showsBackgroundLocationIndicator
257 | this.accuracyFilter = accuracyFilter
258 | }
259 | }
260 |
261 | function roamCustomTrackingOptionsToMap (customOptions) {
262 | if (customOptions === null) {
263 | return null
264 | }
265 | const customMap = {
266 | desiredAccuracy: customOptions.desiredAccuracy,
267 | updateInterval: customOptions.updateInterval,
268 | distanceFilter: customOptions.distanceFilter,
269 | stopDuration: customOptions.stopDuration,
270 | activityType: customOptions.activityType,
271 | desiredAccuracyIOS: customOptions.desiredAccuracyIOS,
272 | allowBackgroundLocationUpdates:
273 | customOptions.allowBackgroundLocationUpdates,
274 | pausesLocationUpdatesAutomatically:
275 | customOptions.pausesLocationUpdatesAutomatically,
276 | showsBackgroundLocationIndicator:
277 | customOptions.showsBackgroundLocationIndicator,
278 | accuracyFilter: customOptions.accuracyFilter
279 | }
280 | return customMap
281 | }
282 |
283 | function roamTripStopsToMap (stop) {
284 | if (stop === null) {
285 | return null
286 | }
287 | const stopsList = []
288 | for (let i = 0; i < stop.length; i++) {
289 | const stopMap = {
290 | RoamTripStop: stop[i].id,
291 | stopName: stop[i].name,
292 | stopDescription: stop[i].description,
293 | address: stop[i].address,
294 | geometryRadius: stop[i].geometryRadius,
295 | geometryCoordinates: stop[i].geometry,
296 | metadata: stop[i].metadata
297 | }
298 | stopsList.push(stopMap)
299 | }
300 |
301 | return stopsList
302 | }
303 |
304 | function roamTripToMap (roamTrip) {
305 | if (roamTrip === null) {
306 | return null
307 | }
308 |
309 | const roamTripMap = {
310 | tripId: roamTrip.tripId,
311 | tripDescription: roamTrip.description,
312 | tripName: roamTrip.name,
313 | metadata: roamTrip.metadata,
314 | isLocal: roamTrip.isLocal,
315 | stops: roamTripStopsToMap(roamTrip.stops),
316 | userId: roamTrip.userId
317 | }
318 | return roamTripMap
319 | }
320 |
321 | const createTrip = (roamTrip, successCallback, errorCallback) => {
322 | NativeModules.RNRoam.createTrip(
323 | roamTripToMap(roamTrip),
324 | successCallback,
325 | errorCallback
326 | )
327 | }
328 |
329 | const startQuickTrip = (
330 | roamTrip,
331 | trackingMode,
332 | customTrackingOption,
333 | successCallback,
334 | errorCallback
335 | ) => {
336 | NativeModules.RNRoam.startQuickTrip(
337 | roamTripToMap(roamTrip),
338 | trackingMode,
339 | roamCustomTrackingOptionsToMap(customTrackingOption),
340 | successCallback,
341 | errorCallback
342 | )
343 | }
344 |
345 | const startTrip = (tripId, successCallback, errorCallback) => {
346 | NativeModules.RNRoam.startTrip(tripId, successCallback, errorCallback)
347 | }
348 |
349 | const updateTrip = (roamTrip, successCallback, errorCallback) => {
350 | NativeModules.RNRoam.updateTrip(
351 | roamTripToMap(roamTrip),
352 | successCallback,
353 | errorCallback
354 | )
355 | }
356 |
357 | const endTrip = (tripId, forceStopTracking, successCallback, errorCallback) => {
358 | NativeModules.RNRoam.endTrip(
359 | tripId,
360 | forceStopTracking,
361 | successCallback,
362 | errorCallback
363 | )
364 | }
365 |
366 | const pauseTrip = (tripId, successCallback, errorCallback) => {
367 | NativeModules.RNRoam.pauseTrip(tripId, successCallback, errorCallback)
368 | }
369 |
370 | const resumeTrip = (tripId, successCallback, errorCallback) => {
371 | NativeModules.RNRoam.resumeTrip(tripId, successCallback, errorCallback)
372 | }
373 |
374 | const syncTrip = (tripId, successCallback, errorCallback) => {
375 | NativeModules.RNRoam.syncTrip(tripId, successCallback, errorCallback)
376 | }
377 |
378 | const getTrip = (tripId, successCallback, errorCallback) => {
379 | NativeModules.RNRoam.getTrip(tripId, successCallback, errorCallback)
380 | }
381 |
382 | const getActiveTrips = (isLocal, successCallback, errorCallback) => {
383 | NativeModules.RNRoam.getActiveTrips(isLocal, successCallback, errorCallback)
384 | }
385 |
386 | const getTripSummary = (tripId, successCallback, errorCallback) => {
387 | NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback)
388 | }
389 |
390 | const subscribeTrip = (tripId) => {
391 | NativeModules.RNRoam.subscribeTripStatus(tripId)
392 | }
393 |
394 | const unSubscribeTrip = (tripId) => {
395 | NativeModules.RNRoam.unSubscribeTripStatus(tripId)
396 | }
397 |
398 | const deleteTrip = (tripId, successCallback, errorCallback) => {
399 | NativeModules.RNRoam.deleteTrip(tripId, successCallback, errorCallback)
400 | }
401 |
402 | // -------- END ------------
403 |
404 | const publishOnly = (array, jsonMetadata) => {
405 | NativeModules.RNRoam.publishOnly(array, jsonMetadata)
406 | }
407 |
408 | const publishAndSave = (jsonMetadata) => {
409 | NativeModules.RNRoam.publishAndSave(jsonMetadata)
410 | }
411 |
412 | const batchProcess = (enable, syncHour) => {
413 | // console.log('batchProcess called with: --> 1', { enable, syncHour });
414 |
415 | NativeModules.RNRoam.batchProcess(enable, syncHour);
416 | };
417 |
418 |
419 | const stopPublishing = () => {
420 | NativeModules.RNRoam.stopPublishing()
421 | }
422 |
423 | // IOS
424 |
425 | const createGeofence = (geofence) => {
426 |
427 | NativeModules.RNRoam.createGeofence(geofence);
428 | };
429 |
430 |
431 | // Android
432 |
433 | // const createGeofence = (geofence) => {
434 | // console.log('createGeofence called with:', geofence);
435 |
436 | // NativeModules.RNRoam.createGeofence();
437 | // }
438 |
439 |
440 |
441 | // const getAllGeofences = (geofences) => {
442 | // NativeModules.RNRoam.getAllGeofences((error, geofences) => {
443 | // if (error) {
444 | // console.error("Error fetching geofences:", error);
445 | // return;
446 | // }
447 |
448 | // console.log(`Geofences count: ${geofences.length}`);
449 |
450 | // geofences.forEach((geofence) => {
451 | // if (geofence.type === "Circular") {
452 | // console.log(`Circular Geofence - Radius: ${geofence.radius}`);
453 | // console.log(`Center: Latitude: ${geofence.center.latitude}, Longitude: ${geofence.center.longitude}`);
454 | // } else if (geofence.type === "Polygon") {
455 | // console.log(`Polygon Geofence - Coordinates: ${JSON.stringify(geofence.coordinates)}`);
456 | // }
457 | // });
458 | // })}
459 |
460 |
461 | const startTracking = (trackingMode) => {
462 | NativeModules.RNRoam.startTracking(trackingMode)
463 | }
464 |
465 | const startTrackingCustom = (
466 | allowBackground,
467 | pauseAutomatic,
468 | activityType,
469 | desiredAccuracy,
470 | showBackIndicator,
471 | distanceFilter,
472 | accuracyFilter,
473 | updateInterval
474 | ) => {
475 | NativeModules.RNRoam.startTrackingCustom(
476 | allowBackground,
477 | pauseAutomatic,
478 | activityType,
479 | desiredAccuracy,
480 | showBackIndicator,
481 | distanceFilter,
482 | accuracyFilter,
483 | updateInterval
484 | )
485 | }
486 |
487 | const startSelfTrackingCustom = (
488 | allowBackground,
489 | pauseAutomatic,
490 | activityType,
491 | desiredAccuracy,
492 | showBackIndicator,
493 | distanceFilter,
494 | accuracyFilter,
495 | updateInterval
496 | ) => {
497 | NativeModules.RNRoam.startSelfTrackingCustom(
498 | allowBackground,
499 | pauseAutomatic,
500 | activityType,
501 | desiredAccuracy,
502 | showBackIndicator,
503 | distanceFilter,
504 | accuracyFilter,
505 | updateInterval
506 | )
507 | }
508 |
509 | const startTrackingTimeInterval = (timeInterval, desiredAccuracy) => {
510 | NativeModules.RNRoam.startTrackingTimeInterval(timeInterval, desiredAccuracy)
511 | }
512 |
513 | const startTrackingDistanceInterval = (
514 | distance,
515 | stationary,
516 | desiredAccuracy
517 | ) => {
518 | NativeModules.RNRoam.startTrackingDistanceInterval(
519 | distance,
520 | stationary,
521 | desiredAccuracy
522 | )
523 | }
524 |
525 | const stopTracking = () => {
526 | NativeModules.RNRoam.stopTracking()
527 | }
528 |
529 | const isLocationTracking = (callback) => {
530 | NativeModules.RNRoam.isLocationTracking(callback)
531 | }
532 |
533 | const setForegroundNotification = (
534 | enabled,
535 | title,
536 | description,
537 | image,
538 | activity,
539 | roamService
540 | ) => {
541 | NativeModules.RNRoam.setForegroundNotification(
542 | enabled,
543 | title,
544 | description,
545 | image,
546 | activity,
547 | roamService
548 | )
549 | }
550 |
551 | const allowMockLocation = (enabled) => {
552 | NativeModules.RNRoam.allowMockLocation(enabled)
553 | }
554 |
555 | const getCurrentLocationListener = (accuracy) => {
556 | NativeModules.RNRoam.getCurrentLocationListener(accuracy)
557 | }
558 |
559 | const getCurrentLocation = (
560 | desiredAccuracy,
561 | accuracy,
562 | successCallback,
563 | errorCallback
564 | ) => {
565 | NativeModules.RNRoam.getCurrentLocation(
566 | desiredAccuracy,
567 | accuracy,
568 | successCallback,
569 | errorCallback
570 | )
571 | }
572 |
573 | const updateCurrentLocation = (desiredAccuracy, accuracy) => {
574 | NativeModules.RNRoam.updateCurrentLocation(desiredAccuracy, accuracy)
575 | }
576 |
577 | const getCurrentLocationIos = (accuracy, successCallback, errorCallback) => {
578 | NativeModules.RNRoam.getCurrentLocationIos(
579 | accuracy,
580 | successCallback,
581 | errorCallback
582 | )
583 | }
584 |
585 | const updateCurrentLocationIos = (accuracy) => {
586 | NativeModules.RNRoam.updateCurrentLocationIos(accuracy)
587 | }
588 |
589 | const updateLocationWhenStationary = (interval) => {
590 | NativeModules.RNRoam.updateLocationWhenStationary(interval)
591 | }
592 |
593 | const logout = (successCallback, errorCallback) => {
594 | NativeModules.RNRoam.logout(successCallback, errorCallback)
595 | }
596 |
597 | const setTrackingInAppState = (appState) => {
598 | NativeModules.RNRoam.setTrackingInAppState(appState)
599 | }
600 |
601 | const offlineLocationTracking = (enabled) => {
602 | NativeModules.RNRoam.offlineLocationTracking(enabled)
603 | }
604 |
605 | const startSelfTracking = (trackingMode) => {
606 | NativeModules.RNRoam.startSelfTracking(trackingMode)
607 | }
608 |
609 | const startSelfTrackingTimeInterval = (timeInterval, desiredAccuracy) => {
610 | NativeModules.RNRoam.startSelfTrackingTimeInterval(
611 | timeInterval,
612 | desiredAccuracy
613 | )
614 | }
615 |
616 | const startSelfTrackingDistanceInterval = (
617 | distance,
618 | stationary,
619 | desiredAccuracy
620 | ) => {
621 | NativeModules.RNRoam.startSelfTrackingDistanceInterval(
622 | distance,
623 | stationary,
624 | desiredAccuracy
625 | )
626 | }
627 |
628 | const stopSelfTracking = () => {
629 | NativeModules.RNRoam.stopSelfTracking()
630 | }
631 |
632 | const enableAccuracyEngine = (accuracy) => {
633 | if (Platform.OS === 'ios') {
634 | NativeModules.RNRoam.enableAccuracyEngine()
635 | } else {
636 | if (accuracy === null || accuracy === undefined) {
637 | NativeModules.RNRoam.enableAccuracyEngine(50)
638 | } else {
639 | NativeModules.RNRoam.enableAccuracyEngine(accuracy)
640 | }
641 | }
642 | }
643 |
644 | const disableAccuracyEngine = () => {
645 | NativeModules.RNRoam.disableAccuracyEngine()
646 | }
647 |
648 | const startListener = (event, callback) =>
649 | eventEmitter.addListener(event, callback)
650 |
651 | const stopListener = (event) => {
652 | eventEmitter.removeAllListeners(event)
653 | }
654 |
655 | const setBatchReceiverConfig = (
656 | networkState,
657 | batchCount,
658 | batchWindow,
659 | successCallback,
660 | errorCallback
661 | ) => {
662 | NativeModules.RNRoam.setBatchReceiverConfig(
663 | networkState,
664 | batchCount,
665 | batchWindow,
666 | successCallback,
667 | errorCallback
668 | )
669 | }
670 |
671 | const getBatchReceiverConfig = (successCallback, errorCallback) => {
672 | NativeModules.RNRoam.getBatchReceiverConfig(successCallback, errorCallback)
673 | }
674 |
675 | const resetBatchReceiverConfig = (successCallback, errorCallback) => {
676 | NativeModules.RNRoam.resetBatchReceiverConfig(successCallback, errorCallback)
677 | }
678 |
679 | const setTrackingConfig = (
680 | accuracy,
681 | timeout,
682 | source,
683 | discardLocation,
684 | successCallback,
685 | errorCallback
686 | ) => {
687 | if (Platform.OS === 'android') {
688 | NativeModules.RNRoam.setTrackingConfig(
689 | accuracy,
690 | timeout,
691 | source,
692 | discardLocation,
693 | successCallback,
694 | errorCallback
695 | )
696 | } else {
697 | NativeModules.RNRoam.setTrackingConfig(
698 | accuracy,
699 | timeout,
700 | discardLocation,
701 | successCallback,
702 | errorCallback
703 | )
704 | }
705 | }
706 |
707 | const getTrackingConfig = (successCallback, errorCallback) => {
708 | NativeModules.RNRoam.getTrackingConfig(successCallback, errorCallback)
709 | }
710 |
711 | const resetTrackingConfig = (successCallback, errorCallback) => {
712 | NativeModules.RNRoam.resetTrackingConfig(successCallback, errorCallback)
713 | }
714 |
715 | const checkActivityPermission = (callback) => {
716 | NativeModules.RNRoam.checkActivityPermission(callback)
717 | }
718 |
719 | const requestActivityPermission = () => {
720 | NativeModules.RNRoam.requestActivityPermission()
721 | }
722 |
723 | const Roam = {
724 | TrackingMode,
725 | DesiredAccuracy,
726 | AppState,
727 | NetworkState,
728 | DesiredAccuracyIOS,
729 | ActivityType,
730 | SubscribeListener,
731 | Publish,
732 | Source,
733 | createUser,
734 | getUser,
735 | setDescription,
736 | toggleEvents,
737 | toggleListener,
738 | getEventsStatus,
739 | getListenerStatus,
740 | subscribe,
741 | unSubscribe,
742 | disableBatteryOptimization,
743 | isBatteryOptimizationEnabled,
744 | checkLocationPermission,
745 | checkLocationServices,
746 | checkBackgroundLocationPermission,
747 | requestLocationPermission,
748 | requestPhoneStatePermission,
749 | requestLocationServices,
750 | requestBackgroundLocationPermission,
751 | locationPermissionStatus,
752 | publishOnly,
753 | publishAndSave,
754 | stopPublishing,
755 | batchProcess,
756 | createGeofence,
757 | // getAllGeofences,
758 | startTracking,
759 | startTrackingCustom,
760 | startSelfTrackingCustom,
761 | startTrackingTimeInterval,
762 | startTrackingDistanceInterval,
763 | stopTracking,
764 | isLocationTracking,
765 | setForegroundNotification,
766 | allowMockLocation,
767 | getCurrentLocationListener,
768 | getCurrentLocation,
769 | updateCurrentLocation,
770 | getCurrentLocationIos,
771 | updateCurrentLocationIos,
772 | logout,
773 | setTrackingInAppState,
774 | offlineLocationTracking,
775 | startSelfTracking,
776 | startSelfTrackingTimeInterval,
777 | startSelfTrackingDistanceInterval,
778 | stopSelfTracking,
779 | enableAccuracyEngine,
780 | disableAccuracyEngine,
781 | startListener,
782 | stopListener,
783 | updateLocationWhenStationary,
784 | setBatchReceiverConfig,
785 | getBatchReceiverConfig,
786 | resetBatchReceiverConfig,
787 | setTrackingConfig,
788 | getTrackingConfig,
789 | resetTrackingConfig,
790 | createTrip,
791 | startQuickTrip,
792 | startTrip,
793 | updateTrip,
794 | endTrip,
795 | pauseTrip,
796 | resumeTrip,
797 | syncTrip,
798 | getTrip,
799 | getActiveTrips,
800 | getTripSummary,
801 | subscribeTrip,
802 | unSubscribeTrip,
803 | deleteTrip,
804 | RoamTrip,
805 | RoamTripStop,
806 | RoamCustomTrackingOptions,
807 | checkActivityPermission,
808 | requestActivityPermission
809 | }
810 |
811 | export default Roam
812 |
--------------------------------------------------------------------------------
/js/index.ts:
--------------------------------------------------------------------------------
1 | import { NativeEventEmitter, NativeModules, Platform } from "react-native";
2 |
3 | if (!NativeModules.RNRoam) {
4 | throw new Error("NativeModules.RNRoam is undefined");
5 | }
6 |
7 | const eventEmitter = new NativeEventEmitter(NativeModules.RNRoam);
8 |
9 | const TrackingMode = {
10 | ACTIVE: "ACTIVE",
11 | BALANCED: "BALANCED",
12 | PASSIVE: "PASSIVE",
13 | CUSTOM: "CUSTOM",
14 | };
15 |
16 | const NetworkState = {
17 | BOTH: "BOTH",
18 | ONLINE: "ONLINE",
19 | OFFLINE: "OFFLINE",
20 | };
21 |
22 | const Source = {
23 | ALL: "ALL",
24 | LAST_KNOWN: "LAST_KNOWN",
25 | GPS: "GPS",
26 | };
27 |
28 | const DesiredAccuracy = {
29 | HIGH: "HIGH",
30 | MEDIUM: "MEDIUM",
31 | LOW: "LOW",
32 | };
33 |
34 | const AppState = {
35 | ALWAYS_ON: "ALWAYS_ON",
36 | FOREGROUND: "FOREGROUND",
37 | BACKGROUND: "BACKGROUND",
38 | };
39 |
40 | const DesiredAccuracyIOS = {
41 | BESTFORNAVIGATION: "BESTFORNAVIGATION",
42 | BEST: "BEST",
43 | NEAREST_TEN_METERS: "NEAREST_TEN_METERS",
44 | HUNDRED_METERS: "HUNDRED_METERS",
45 | KILO_METERS: "KILO_METERS",
46 | THREE_KILOMETERS: "THREE_KILOMETERS",
47 | };
48 |
49 | const ActivityType = {
50 | OTHER: "OTHER",
51 | AUTO_NAVIGATION: "AUTO_NAVIGATION",
52 | OTHER_NAVIGATION: "OTHER_NAVIGATION",
53 | FITNESS: "FITNESS",
54 | };
55 |
56 | const SubscribeListener = {
57 | EVENTS: "EVENTS",
58 | LOCATION: "LOCATION",
59 | BOTH: "BOTH",
60 | };
61 |
62 | const Publish = {
63 | APP_ID: "APP_ID",
64 | USER_ID: "USER_ID",
65 | GEOFENCE_EVENTS: "GEOFENCE_EVENTS",
66 | LOCATION_EVENTS: "LOCATION_EVENTS",
67 | NEARBY_EVENTS: "NEARBY_EVENTS",
68 | TRIPS_EVENTS: "TRIPS_EVENTS",
69 | LOCATION_LISTENER: "LOCATION_LISTENER",
70 | EVENT_LISTENER: "EVENT_LISTENER",
71 | ALTITUDE: "ALTITUDE",
72 | COURSE: "COURSE",
73 | SPEED: "SPEED",
74 | VERTICAL_ACCURACY: "VERTICAL_ACCURACY",
75 | HORIZONTAL_ACCURACY: "HORIZONTAL_ACCURACY",
76 | APP_CONTEXT: "APP_CONTEXT",
77 | ALLOW_MOCKED: "ALLOW_MOCKED",
78 | BATTERY_REMAINING: "BATTERY_REMAINING",
79 | BATTERY_SAVER: "BATTERY_SAVER",
80 | BATTERY_STATUS: "BATTERY_STATUS",
81 | ACTIVITY: "ACTIVITY",
82 | AIRPLANE_MODE: "AIRPLANE_MODE",
83 | DEVICE_MANUFACTURE: "DEVICE_MANUFACTURE",
84 | DEVICE_MODEL: "DEVICE_MODEL",
85 | TRACKING_MODE: "TRACKING_MODE",
86 | LOCATIONPERMISSION: "LOCATIONPERMISSION",
87 | NETWORK_STATUS: "NETWORK_STATUS",
88 | GPS_STATUS: "GPS_STATUS",
89 | OS_VERSION: "OS_VERSION",
90 | RECORDERD_AT: "RECORDERD_AT",
91 | TZ_OFFSET: "TZ_OFFSET",
92 | };
93 |
94 | const createUser = (
95 | description: any,
96 | successCallback: any,
97 | errorCallback: any
98 | ) => {
99 | NativeModules.RNRoam.createUser(
100 | description,
101 | null,
102 | successCallback,
103 | errorCallback
104 | );
105 | };
106 |
107 | const getUser = (userid: any, successCallback: any, errorCallback: any) => {
108 | NativeModules.RNRoam.getUser(userid, successCallback, errorCallback);
109 | };
110 |
111 | const setDescription = (description: any) => {
112 | if (Platform.OS === "android") {
113 | NativeModules.RNRoam.setDescription(description);
114 | } else {
115 | NativeModules.RNRoam.setDescription(description, null);
116 | }
117 | };
118 |
119 | const toggleEvents = (
120 | geofence: any,
121 | trip: any,
122 | location: any,
123 | movingGeofence: any,
124 | successCallback: any,
125 | errorCallback: any
126 | ) => {
127 | NativeModules.RNRoam.toggleEvents(
128 | geofence,
129 | trip,
130 | location,
131 | movingGeofence,
132 | successCallback,
133 | errorCallback
134 | );
135 | };
136 |
137 | const toggleListener = (
138 | location: any,
139 | event: any,
140 | successCallback: any,
141 | errorCallback: any
142 | ) => {
143 | NativeModules.RNRoam.toggleListener(
144 | location,
145 | event,
146 | successCallback,
147 | errorCallback
148 | );
149 | };
150 |
151 | const getEventsStatus = (successCallback: any, errorCallback: any) => {
152 | NativeModules.RNRoam.getEventsStatus(successCallback, errorCallback);
153 | };
154 |
155 | const getListenerStatus = (successCallback: any, errorCallback: any) => {
156 | NativeModules.RNRoam.getListenerStatus(successCallback, errorCallback);
157 | };
158 |
159 | const subscribe = (type: any, userid: any) => {
160 | NativeModules.RNRoam.subscribe(type, userid);
161 | };
162 |
163 | const unSubscribe = (type: any, userid: any) => {
164 | NativeModules.RNRoam.unSubscribe(type, userid);
165 | };
166 |
167 | const disableBatteryOptimization = () => {
168 | NativeModules.RNRoam.disableBatteryOptimization();
169 | };
170 |
171 | const isBatteryOptimizationEnabled = (callback: any) => {
172 | NativeModules.RNRoam.isBatteryOptimizationEnabled(callback);
173 | };
174 |
175 | const checkLocationPermission = (callback: any) => {
176 | NativeModules.RNRoam.checkLocationPermission(callback);
177 | };
178 |
179 | const checkLocationServices = (callback: any) => {
180 | NativeModules.RNRoam.checkLocationServices(callback);
181 | };
182 |
183 | const checkBackgroundLocationPermission = (callback: any) => {
184 | NativeModules.RNRoam.checkBackgroundLocationPermission(callback);
185 | };
186 |
187 | const locationPermissionStatus = (callback: any) => {
188 | NativeModules.RNRoam.locationPermissionStatus(callback);
189 | };
190 |
191 | const requestLocationPermission = () => {
192 | NativeModules.RNRoam.requestLocationPermission();
193 | };
194 |
195 |
196 | const requestPhoneStatePermission = () => {
197 | NativeModules.RNRoam.requestPhoneStatePermission();
198 | };
199 |
200 | const requestLocationServices = () => {
201 | NativeModules.RNRoam.requestLocationServices();
202 | };
203 |
204 | const requestBackgroundLocationPermission = () => {
205 | NativeModules.RNRoam.requestBackgroundLocationPermission();
206 | };
207 |
208 | // -------- Trips V2 ----------
209 |
210 | class RoamTrip {
211 | metadata: any;
212 | description: any;
213 | name: any;
214 | stops: any;
215 | isLocal: any;
216 | tripId: any;
217 | userId: any;
218 | constructor(
219 | metadata: any,
220 | description: any,
221 | name: any,
222 | stops: any,
223 | isLocal: any,
224 | tripId: any,
225 | userId: any
226 | ) {
227 | this.metadata = metadata;
228 | this.description = description;
229 | this.name = name;
230 | this.stops = stops;
231 | this.isLocal = isLocal;
232 | this.tripId = tripId;
233 | this.userId = userId;
234 | }
235 | }
236 |
237 | class RoamTripStop {
238 | id: any;
239 | metadata: any;
240 | description: any;
241 | name: any;
242 | address: any;
243 | geometryRadius: any;
244 | geometry: any;
245 | constructor(
246 | id: any,
247 | metadata: any,
248 | description: any,
249 | name: any,
250 | address: any,
251 | geometryRadius: any,
252 | geometry: any
253 | ) {
254 | this.id = id;
255 | this.metadata = metadata;
256 | this.description = description;
257 | this.name = name;
258 | this.address = address;
259 | this.geometryRadius = geometryRadius;
260 | this.geometry = geometry;
261 | }
262 | }
263 |
264 | class RoamCustomTrackingOptions {
265 | desiredAccuracy: any;
266 | updateInterval: any;
267 | distanceFilter: any;
268 | stopDuration: any;
269 | activityType: any;
270 | desiredAccuracyIOS: any;
271 | allowBackgroundLocationUpdates: any;
272 | pausesLocationUpdatesAutomatically: any;
273 | showsBackgroundLocationIndicator: any;
274 | accuracyFilter: any;
275 | constructor(
276 | desiredAccuracy: any,
277 | updateInterval: any,
278 | distanceFilter: any,
279 | stopDuration: any,
280 | activityType: any,
281 | desiredAccuracyIOS: any,
282 | allowBackgroundLocationUpdates: any,
283 | pausesLocationUpdatesAutomatically: any,
284 | showsBackgroundLocationIndicator: any,
285 | accuracyFilter: any
286 | ) {
287 | this.desiredAccuracy = desiredAccuracy;
288 | this.updateInterval = updateInterval;
289 | this.distanceFilter = distanceFilter;
290 | this.stopDuration = stopDuration;
291 | this.activityType = activityType;
292 | this.desiredAccuracyIOS = desiredAccuracyIOS;
293 | this.allowBackgroundLocationUpdates = allowBackgroundLocationUpdates;
294 | this.pausesLocationUpdatesAutomatically =
295 | pausesLocationUpdatesAutomatically;
296 | this.showsBackgroundLocationIndicator = showsBackgroundLocationIndicator;
297 | this.accuracyFilter = accuracyFilter;
298 | }
299 | }
300 |
301 | function roamCustomTrackingOptionsToMap(customOptions: any) {
302 | if (customOptions === null) {
303 | return null;
304 | }
305 | var customMap = {
306 | desiredAccuracy: customOptions.desiredAccuracy,
307 | updateInterval: customOptions.updateInterval,
308 | distanceFilter: customOptions.distanceFilter,
309 | stopDuration: customOptions.stopDuration,
310 | activityType: customOptions.activityType,
311 | desiredAccuracyIOS: customOptions.desiredAccuracyIOS,
312 | allowBackgroundLocationUpdates:
313 | customOptions.allowBackgroundLocationUpdates,
314 | pausesLocationUpdatesAutomatically:
315 | customOptions.pausesLocationUpdatesAutomatically,
316 | showsBackgroundLocationIndicator:
317 | customOptions.showsBackgroundLocationIndicator,
318 | accuracyFilter: customOptions.accuracyFilter,
319 | };
320 | return customMap;
321 | }
322 |
323 | function roamTripStopsToMap(stop: any) {
324 | if (stop === null) {
325 | return null;
326 | }
327 | var stopsList = [];
328 | for (let i = 0; i < stop.length; i++) {
329 | var stopMap = {
330 | RoamTripStop: stop[i].id,
331 | stopName: stop[i].name,
332 | stopDescription: stop[i].description,
333 | address: stop[i].address,
334 | geometryRadius: stop[i].geometryRadius,
335 | geometryCoordinates: stop[i].geometry,
336 | metadata: stop[i].metadata,
337 | };
338 | stopsList.push(stopMap);
339 | }
340 |
341 | return stopsList;
342 | }
343 |
344 | function roamTripToMap(roamTrip: any) {
345 | if (roamTrip === null) {
346 | return null;
347 | }
348 |
349 | var roamTripMap = {
350 | tripId: roamTrip.tripId,
351 | tripDescription: roamTrip.description,
352 | tripName: roamTrip.name,
353 | metadata: roamTrip.metadata,
354 | isLocal: roamTrip.isLocal,
355 | stops: roamTripStopsToMap(roamTrip.stops),
356 | userId: roamTrip.userId,
357 | };
358 | return roamTripMap;
359 | }
360 |
361 | const createTrip = (
362 | roamTrip: any,
363 | successCallback: any,
364 | errorCallback: any
365 | ) => {
366 | NativeModules.RNRoam.createTrip(
367 | roamTripToMap(roamTrip),
368 | successCallback,
369 | errorCallback
370 | );
371 | };
372 |
373 | const startQuickTrip = (
374 | roamTrip: any,
375 | trackingMode: any,
376 | customTrackingOption: any,
377 | successCallback: any,
378 | errorCallback: any
379 | ) => {
380 | NativeModules.RNRoam.startQuickTrip(
381 | roamTripToMap(roamTrip),
382 | trackingMode,
383 | roamCustomTrackingOptionsToMap(customTrackingOption),
384 | successCallback,
385 | errorCallback
386 | );
387 | };
388 |
389 | const startTrip = (tripId: any, successCallback: any, errorCallback: any) => {
390 | NativeModules.RNRoam.startTrip(tripId, successCallback, errorCallback);
391 | };
392 |
393 | const updateTrip = (
394 | roamTrip: any,
395 | successCallback: any,
396 | errorCallback: any
397 | ) => {
398 | NativeModules.RNRoam.updateTrip(
399 | roamTripToMap(roamTrip),
400 | successCallback,
401 | errorCallback
402 | );
403 | };
404 |
405 | const endTrip = (
406 | tripId: any,
407 | forceStopTracking: any,
408 | successCallback: any,
409 | errorCallback: any
410 | ) => {
411 | NativeModules.RNRoam.endTrip(
412 | tripId,
413 | forceStopTracking,
414 | successCallback,
415 | errorCallback
416 | );
417 | };
418 |
419 | const pauseTrip = (tripId: any, successCallback: any, errorCallback: any) => {
420 | NativeModules.RNRoam.pauseTrip(tripId, successCallback, errorCallback);
421 | };
422 |
423 | const resumeTrip = (tripId: any, successCallback: any, errorCallback: any) => {
424 | NativeModules.RNRoam.resumeTrip(tripId, successCallback, errorCallback);
425 | };
426 |
427 | const syncTrip = (tripId: any, successCallback: any, errorCallback: any) => {
428 | NativeModules.RNRoam.syncTrip(tripId, successCallback, errorCallback);
429 | };
430 |
431 | const getTrip = (tripId: any, successCallback: any, errorCallback: any) => {
432 | NativeModules.RNRoam.getTrip(tripId, successCallback, errorCallback);
433 | };
434 |
435 | const getActiveTrips = (
436 | isLocal: any,
437 | successCallback: any,
438 | errorCallback: any
439 | ) => {
440 | NativeModules.RNRoam.getActiveTrips(isLocal, successCallback, errorCallback);
441 | };
442 |
443 | const getTripSummary = (
444 | tripId: any,
445 | successCallback: any,
446 | errorCallback: any
447 | ) => {
448 | NativeModules.RNRoam.getTripSummary(tripId, successCallback, errorCallback);
449 | };
450 |
451 | const subscribeTrip = (tripId: any) => {
452 | NativeModules.RNRoam.subscribeTripStatus(tripId);
453 | };
454 |
455 | const unSubscribeTrip = (tripId: any) => {
456 | NativeModules.RNRoam.unSubscribeTripStatus(tripId);
457 | };
458 |
459 | const deleteTrip = (tripId: any, successCallback: any, errorCallback: any) => {
460 | NativeModules.RNRoam.deleteTrip(tripId, successCallback, errorCallback);
461 | };
462 |
463 | // -------- END ------------
464 |
465 | const publishOnly = (array: any, jsonMetadata: any) => {
466 | NativeModules.RNRoam.publishOnly(array, jsonMetadata);
467 | };
468 |
469 |
470 |
471 |
472 | const publishAndSave = (jsonMetadata: any) => {
473 | NativeModules.RNRoam.publishAndSave(jsonMetadata);
474 | };
475 |
476 | const stopPublishing = () => {
477 | NativeModules.RNRoam.stopPublishing();
478 | };
479 |
480 | type RNRoamType = {
481 | batchProcess: (enable: boolean, syncHour: number) => void;
482 | };
483 |
484 | const { RNRoam } = NativeModules as { RNRoam?: RNRoamType };
485 |
486 | const batchProcess = (enable: boolean, syncHour: number): void => {
487 | console.log('batchProcess called with:', { enable, syncHour });
488 |
489 | if (RNRoam?.batchProcess) {
490 | try {
491 | RNRoam.batchProcess(enable, syncHour);
492 | console.log('batchProcess executed successfully.');
493 | } catch (error) {
494 | console.error('Error executing batchProcess:', error);
495 | }
496 | } else {
497 | console.warn('RNRoam module is not linked properly.');
498 | }
499 | };
500 | export const createGeofence = (geofence: { [key: string]: any }) => {
501 | if (NativeModules.RNRoam && NativeModules.RNRoam.createGeofence) {
502 | NativeModules.RNRoam.createGeofence(geofence)
503 | .then((response: any) => {
504 | console.log('Geofence created:', response);
505 | })
506 | .catch((error: any) => {
507 | console.error('Error creating geofence:', error);
508 | });
509 | } else {
510 | console.error('createGeofence method is not available');
511 | }
512 | };
513 |
514 | // export const getAllGeofences = (geofences: "") => {
515 | // // Logic for fetching geofences
516 | // console.log('Fetching all geofences');
517 |
518 | // // Ensure the correct argument is passed - a callback function
519 | // NativeModules.RNRoam.getAllGeofences((geofences: "") => {
520 | // console.log('Received geofences:', geofences);
521 | // });
522 | // };
523 |
524 |
525 |
526 | const startTracking = (trackingMode: any) => {
527 | NativeModules.RNRoam.startTracking(trackingMode);
528 | };
529 |
530 | const startTrackingCustom = (
531 | allowBackground: any,
532 | pauseAutomatic: any,
533 | activityType: any,
534 | desiredAccuracy: any,
535 | showBackIndicator: any,
536 | distanceFilter: any,
537 | accuracyFilter: any,
538 | updateInterval: any
539 | ) => {
540 | NativeModules.RNRoam.startTrackingCustom(
541 | allowBackground,
542 | pauseAutomatic,
543 | activityType,
544 | desiredAccuracy,
545 | showBackIndicator,
546 | distanceFilter,
547 | accuracyFilter,
548 | updateInterval
549 | );
550 | };
551 |
552 | const startSelfTrackingCustom = (
553 | allowBackground: any,
554 | pauseAutomatic: any,
555 | activityType: any,
556 | desiredAccuracy: any,
557 | showBackIndicator: any,
558 | distanceFilter: any,
559 | accuracyFilter: any,
560 | updateInterval: any
561 | ) => {
562 | NativeModules.RNRoam.startSelfTrackingCustom(
563 | allowBackground,
564 | pauseAutomatic,
565 | activityType,
566 | desiredAccuracy,
567 | showBackIndicator,
568 | distanceFilter,
569 | accuracyFilter,
570 | updateInterval
571 | );
572 | };
573 |
574 | const startTrackingTimeInterval = (timeInterval: any, desiredAccuracy: any) => {
575 | NativeModules.RNRoam.startTrackingTimeInterval(timeInterval, desiredAccuracy);
576 | };
577 |
578 | const startTrackingDistanceInterval = (
579 | distance: any,
580 | stationary: any,
581 | desiredAccuracy: any
582 | ) => {
583 | NativeModules.RNRoam.startTrackingDistanceInterval(
584 | distance,
585 | stationary,
586 | desiredAccuracy
587 | );
588 | };
589 |
590 | const stopTracking = () => {
591 | NativeModules.RNRoam.stopTracking();
592 | };
593 |
594 | const isLocationTracking = (callback: any) => {
595 | NativeModules.RNRoam.isLocationTracking(callback);
596 | };
597 |
598 | const setForegroundNotification = (
599 | enabled: any,
600 | title: any,
601 | description: any,
602 | image: any,
603 | activity: any,
604 | roamService: any
605 | ) => {
606 | NativeModules.RNRoam.setForegroundNotification(
607 | enabled,
608 | title,
609 | description,
610 | image,
611 | activity,
612 | roamService
613 | );
614 | };
615 |
616 | const allowMockLocation = (enabled: any) => {
617 | NativeModules.RNRoam.allowMockLocation(enabled);
618 | };
619 |
620 | const getCurrentLocationListener = (accuracy: any) => {
621 | NativeModules.RNRoam.getCurrentLocationListener(accuracy);
622 | };
623 |
624 | const getCurrentLocation = (
625 | desiredAccuracy: any,
626 | accuracy: any,
627 | successCallback: any,
628 | errorCallback: any
629 | ) => {
630 | NativeModules.RNRoam.getCurrentLocation(
631 | desiredAccuracy,
632 | accuracy,
633 | successCallback,
634 | errorCallback
635 | );
636 | };
637 |
638 | const updateCurrentLocation = (desiredAccuracy: any, accuracy: any) => {
639 | NativeModules.RNRoam.updateCurrentLocation(desiredAccuracy, accuracy);
640 | };
641 |
642 | const getCurrentLocationIos = (
643 | accuracy: any,
644 | successCallback: any,
645 | errorCallback: any
646 | ) => {
647 | NativeModules.RNRoam.getCurrentLocationIos(
648 | accuracy,
649 | successCallback,
650 | errorCallback
651 | );
652 | };
653 |
654 | const updateCurrentLocationIos = (accuracy: any) => {
655 | NativeModules.RNRoam.updateCurrentLocationIos(accuracy);
656 | };
657 |
658 | const updateLocationWhenStationary = (interval: any) => {
659 | NativeModules.RNRoam.updateLocationWhenStationary(interval);
660 | };
661 |
662 | const logout = (successCallback: any, errorCallback: any) => {
663 | NativeModules.RNRoam.logout(successCallback, errorCallback);
664 | };
665 |
666 | const setTrackingInAppState = (appState: any) => {
667 | NativeModules.RNRoam.setTrackingInAppState(appState);
668 | };
669 |
670 | const offlineLocationTracking = (enabled: any) => {
671 | NativeModules.RNRoam.offlineLocationTracking(enabled);
672 | };
673 |
674 | const startSelfTracking = (trackingMode: any) => {
675 | NativeModules.RNRoam.startSelfTracking(trackingMode);
676 | };
677 |
678 | const startSelfTrackingTimeInterval = (
679 | timeInterval: any,
680 | desiredAccuracy: any
681 | ) => {
682 | NativeModules.RNRoam.startSelfTrackingTimeInterval(
683 | timeInterval,
684 | desiredAccuracy
685 | );
686 | };
687 |
688 | const startSelfTrackingDistanceInterval = (
689 | distance: any,
690 | stationary: any,
691 | desiredAccuracy: any
692 | ) => {
693 | NativeModules.RNRoam.startSelfTrackingDistanceInterval(
694 | distance,
695 | stationary,
696 | desiredAccuracy
697 | );
698 | };
699 |
700 | const stopSelfTracking = () => {
701 | NativeModules.RNRoam.stopSelfTracking();
702 | };
703 |
704 | const enableAccuracyEngine = (accuracy?: any) => {
705 | if (Platform.OS === "ios") {
706 | NativeModules.RNRoam.enableAccuracyEngine();
707 | } else {
708 | if (accuracy === null || accuracy === undefined) {
709 | NativeModules.RNRoam.enableAccuracyEngine(50);
710 | } else {
711 | NativeModules.RNRoam.enableAccuracyEngine(accuracy);
712 | }
713 | }
714 | };
715 |
716 | const disableAccuracyEngine = () => {
717 | NativeModules.RNRoam.disableAccuracyEngine();
718 | };
719 |
720 | const startListener = (event: string, callback: (...args: any[]) => any) =>
721 | eventEmitter.addListener(event, callback);
722 |
723 | const stopListener = (event: string) => {
724 | eventEmitter.removeAllListeners(event);
725 | };
726 |
727 | const setBatchReceiverConfig = (
728 | networkState: any,
729 | batchCount: any,
730 | batchWindow: any,
731 | successCallback: any,
732 | errorCallback: any
733 | ) => {
734 | NativeModules.RNRoam.setBatchReceiverConfig(
735 | networkState,
736 | batchCount,
737 | batchWindow,
738 | successCallback,
739 | errorCallback
740 | );
741 | };
742 |
743 | const getBatchReceiverConfig = (successCallback: any, errorCallback: any) => {
744 | NativeModules.RNRoam.getBatchReceiverConfig(successCallback, errorCallback);
745 | };
746 |
747 | const resetBatchReceiverConfig = (successCallback: any, errorCallback: any) => {
748 | NativeModules.RNRoam.resetBatchReceiverConfig(successCallback, errorCallback);
749 | };
750 |
751 | const setTrackingConfig = (
752 | accuracy: any,
753 | timeout: any,
754 | source: any,
755 | discardLocation: any,
756 | successCallback: any,
757 | errorCallback: any
758 | ) => {
759 | NativeModules.RNRoam.setTrackingConfig(
760 | accuracy,
761 | timeout,
762 | source,
763 | discardLocation,
764 | successCallback,
765 | errorCallback
766 | );
767 | };
768 |
769 | const getTrackingConfig = (successCallback: any, errorCallback: any) => {
770 | NativeModules.RNRoam.getTrackingConfig(successCallback, errorCallback);
771 | };
772 |
773 | const resetTrackingConfig = (successCallback: any, errorCallback: any) => {
774 | NativeModules.RNRoam.resetTrackingConfig(successCallback, errorCallback);
775 | };
776 |
777 | const checkActivityPermission = (callback: any) => {
778 | NativeModules.RNRoam.checkActivityPermission(callback);
779 | };
780 |
781 | const requestActivityPermission = () => {
782 | NativeModules.RNRoam.requestActivityPermission();
783 | };
784 |
785 | const Roam = {
786 | TrackingMode,
787 | DesiredAccuracy,
788 | AppState,
789 | NetworkState,
790 | DesiredAccuracyIOS,
791 | ActivityType,
792 | SubscribeListener,
793 | Publish,
794 | Source,
795 | createUser,
796 | getUser,
797 | setDescription,
798 | toggleEvents,
799 | toggleListener,
800 | getEventsStatus,
801 | getListenerStatus,
802 | subscribe,
803 | unSubscribe,
804 | disableBatteryOptimization,
805 | isBatteryOptimizationEnabled,
806 | checkLocationPermission,
807 | checkLocationServices,
808 | checkBackgroundLocationPermission,
809 | requestLocationPermission,
810 | requestPhoneStatePermission,
811 | requestLocationServices,
812 | requestBackgroundLocationPermission,
813 | locationPermissionStatus,
814 | publishOnly,
815 | publishAndSave,
816 | batchProcess,
817 | createGeofence,
818 | // getAllGeofences,
819 | stopPublishing,
820 | startTracking,
821 | startTrackingCustom,
822 | startSelfTrackingCustom,
823 | startTrackingTimeInterval,
824 | startTrackingDistanceInterval,
825 | stopTracking,
826 | isLocationTracking,
827 | setForegroundNotification,
828 | allowMockLocation,
829 | getCurrentLocationListener,
830 | getCurrentLocation,
831 | updateCurrentLocation,
832 | getCurrentLocationIos,
833 | updateCurrentLocationIos,
834 | logout,
835 | setTrackingInAppState,
836 | offlineLocationTracking,
837 | startSelfTracking,
838 | startSelfTrackingTimeInterval,
839 | startSelfTrackingDistanceInterval,
840 | stopSelfTracking,
841 | enableAccuracyEngine,
842 | disableAccuracyEngine,
843 | startListener,
844 | stopListener,
845 | updateLocationWhenStationary,
846 | setBatchReceiverConfig,
847 | getBatchReceiverConfig,
848 | resetBatchReceiverConfig,
849 | setTrackingConfig,
850 | getTrackingConfig,
851 | resetTrackingConfig,
852 | createTrip,
853 | startQuickTrip,
854 | startTrip,
855 | updateTrip,
856 | endTrip,
857 | pauseTrip,
858 | resumeTrip,
859 | syncTrip,
860 | getTrip,
861 | getActiveTrips,
862 | getTripSummary,
863 | subscribeTrip,
864 | unSubscribeTrip,
865 | deleteTrip,
866 | RoamTrip,
867 | RoamTripStop,
868 | RoamCustomTrackingOptions,
869 | checkActivityPermission,
870 | requestActivityPermission,
871 | };
872 |
873 | export default Roam;
874 |
--------------------------------------------------------------------------------
/android/src/main/java/com/roam/reactnative/RNRoamUtils.java:
--------------------------------------------------------------------------------
1 | package com.roam.reactnative;
2 |
3 | import android.location.Location;
4 | import android.text.TextUtils;
5 | import android.util.Log;
6 |
7 | import com.facebook.react.bridge.Arguments;
8 | import com.facebook.react.bridge.ReadableArray;
9 | import com.facebook.react.bridge.ReadableMap;
10 | import com.facebook.react.bridge.WritableArray;
11 | import com.facebook.react.bridge.WritableMap;
12 | import com.roam.sdk.models.BatchLocation;
13 | import com.roam.sdk.models.BatchReceiverConfig;
14 | import com.roam.sdk.models.RoamError;
15 | import com.roam.sdk.models.RoamLocation;
16 | import com.roam.sdk.models.RoamTripStatus;
17 | import com.roam.sdk.models.RoamUser;
18 | import com.roam.sdk.models.TrackingConfig;
19 | import com.roam.sdk.models.centroid.Centroid;
20 | import com.roam.sdk.models.centroid.CentroidCoordinate;
21 | import com.roam.sdk.models.centroid.Positions;
22 | import com.roam.sdk.models.createtrip.Coordinates;
23 | import com.roam.sdk.models.events.RoamEvent;
24 | import com.roam.sdk.trips_v2.RoamTrip;
25 | import com.roam.sdk.trips_v2.models.EndLocation;
26 | import com.roam.sdk.trips_v2.models.Error;
27 | import com.roam.sdk.trips_v2.models.Errors;
28 | import com.roam.sdk.trips_v2.models.Events;
29 | import com.roam.sdk.trips_v2.models.Geometry;
30 | import com.roam.sdk.trips_v2.models.RoamActiveTripsResponse;
31 | import com.roam.sdk.trips_v2.models.RoamDeleteTripResponse;
32 | import com.roam.sdk.trips_v2.models.RoamSyncTripResponse;
33 | import com.roam.sdk.trips_v2.models.RoamTripResponse;
34 | import com.roam.sdk.trips_v2.models.Routes;
35 | import com.roam.sdk.trips_v2.models.StartLocation;
36 | import com.roam.sdk.trips_v2.models.Stop;
37 | import com.roam.sdk.trips_v2.models.TripDetails;
38 | import com.roam.sdk.trips_v2.models.Trips;
39 | import com.roam.sdk.trips_v2.models.User;
40 | import com.roam.sdk.trips_v2.request.RoamTripStops;
41 |
42 | import org.json.JSONObject;
43 |
44 | import java.util.ArrayList;
45 | import java.util.List;
46 |
47 |
48 | class RNRoamUtils {
49 |
50 | public static final String APP_ID = "APP_ID";
51 | public static final String USER_ID = "USER_ID";
52 | public static final String GEOFENCE_EVENTS = "GEOFENCE_EVENTS";
53 | public static final String LOCATION_EVENTS = "LOCATION_EVENTS";
54 | public static final String NEARBY_EVENTS = "NEARBY_EVENTS";
55 | public static final String TRIPS_EVENTS = "TRIPS_EVENTS";
56 | public static final String LOCATION_LISTENER = "LOCATION_LISTENER";
57 | public static final String EVENT_LISTENER = "EVENT_LISTENER";
58 | public static final String ALTITUDE = "ALTITUDE";
59 | public static final String COURSE = "COURSE";
60 | public static final String SPEED = "SPEED";
61 | public static final String VERTICAL_ACCURACY = "VERTICAL_ACCURACY";
62 | public static final String HORIZONTAL_ACCURACY = "HORIZONTAL_ACCURACY";
63 | public static final String APP_CONTEXT = "APP_CONTEXT";
64 | public static final String ALLOW_MOCKED = "ALLOW_MOCKED";
65 | public static final String BATTERY_REMAINING = "BATTERY_REMAINING";
66 | public static final String BATTERY_SAVER = "BATTERY_SAVER";
67 | public static final String BATTERY_STATUS = "BATTERY_STATUS";
68 | public static final String ACTIVITY = "ACTIVITY";
69 | public static final String AIRPLANE_MODE = "AIRPLANE_MODE";
70 | public static final String DEVICE_MANUFACTURE = "DEVICE_MANUFACTURE";
71 | public static final String DEVICE_MODEL = "DEVICE_MODEL";
72 | public static final String TRACKING_MODE = "TRACKING_MODE";
73 | public static final String LOCATIONPERMISSION = "LOCATIONPERMISSION";
74 | public static final String NETWORK_STATUS = "NETWORK_STATUS";
75 | public static final String GPS_STATUS = "GPS_STATUS";
76 | public static final String OS_VERSION = "OS_VERSION";
77 | public static final String RECORDERD_AT = "RECORDERD_AT";
78 | public static final String TZ_OFFSET = "TZ_OFFSET";
79 | public static final String METADATA = "METADATA";
80 |
81 |
82 | static String isGranted(boolean hasGranted) {
83 | if (hasGranted) {
84 | return "GRANTED";
85 | }
86 | return "DENIED";
87 | }
88 |
89 | static String checkEnabled(boolean hasEnabled) {
90 | if (hasEnabled) {
91 | return "ENABLED";
92 | }
93 | return "DISABLED";
94 | }
95 |
96 | static WritableMap mapForUser(RoamUser roamUser) {
97 | if (roamUser == null) {
98 | return null;
99 | }
100 | WritableMap map = Arguments.createMap();
101 | map.putString("userId", roamUser.getUserId());
102 | map.putString("description", roamUser.getDescription());
103 | if (roamUser.getGeofenceEvents() != null){
104 | map.putBoolean("geofenceEvents", roamUser.getGeofenceEvents());
105 | }
106 | if (roamUser.getLocationEvents() != null){
107 | map.putBoolean("locationEvents", roamUser.getLocationEvents());
108 | }
109 | if (roamUser.getTripsEvents() != null){
110 | map.putBoolean("tripsEvents", roamUser.getTripsEvents());
111 | }
112 | if (roamUser.getMovingGeofenceEvents() != null){
113 | map.putBoolean("movingGeofenceEvents", roamUser.getMovingGeofenceEvents());
114 | }
115 | if (roamUser.getEventListenerStatus() != null){
116 | map.putBoolean("eventListenerStatus", roamUser.getEventListenerStatus());
117 | }
118 | if (roamUser.getLocationListenerStatus() != null){
119 | map.putBoolean("locationListenerStatus", roamUser.getLocationListenerStatus());
120 | }
121 | return map;
122 | }
123 |
124 |
125 | static WritableArray mapForBatchReceiverConfig(List configs){
126 | WritableArray array = Arguments.createArray();
127 | for (BatchReceiverConfig config: configs){
128 | WritableMap map = Arguments.createMap();
129 | map.putInt("batchCount", config.getBatchCount());
130 | map.putInt("batchWindow", config.getBatchWindow().intValue());
131 | map.putString("networkState", config.getNetworkState());
132 | array.pushMap(map);
133 | }
134 | return array;
135 | }
136 |
137 | static WritableArray mapForLocationList(List locationList) {
138 | WritableArray array = Arguments.createArray();
139 |
140 | for (RoamLocation roamLocation : locationList) {
141 | WritableMap map = Arguments.createMap();
142 |
143 | map.putString("userId", TextUtils.isEmpty(roamLocation.getUserId()) ? " " : roamLocation.getUserId());
144 |
145 | if (locationList.size() > 1) {
146 | map.putMap("location", RNRoamUtils.mapForBatchLocation(roamLocation.getBatchLocations()));
147 | } else {
148 | map.putMap("location", RNRoamUtils.mapForLocation(roamLocation.getLocation()));
149 | }
150 |
151 | map.putString("activity", TextUtils.isEmpty(roamLocation.getActivity()) ? " " : roamLocation.getActivity());
152 |
153 | WritableArray installedApplicationsArray = Arguments.createArray();
154 | for (String app : roamLocation.getInstalledApplications()) {
155 | installedApplicationsArray.pushString(app);
156 | }
157 | map.putArray("installedApplications", installedApplicationsArray);
158 | map.putString("recordedAt", roamLocation.getRecordedAt());
159 | map.putString("timezone", roamLocation.getTimezoneOffset());
160 | map.putString("trackingMode", roamLocation.getTrackingMode());
161 | map.putString("appContext", roamLocation.getAppContext());
162 | map.putString("batteryStatus", roamLocation.getBatteryStatus());
163 | map.putInt("batteryRemaining", roamLocation.getBatteryRemaining());
164 | map.putBoolean("batterySaver", roamLocation.getBatterySaver());
165 | map.putBoolean("networkStatus", roamLocation.getNetworkStatus());
166 | map.putString("networkState", roamLocation.getNetworkState());
167 | map.putBoolean("locationPermission", roamLocation.getLocationPermission());
168 | map.putString("deviceModel", roamLocation.getDeviceModel());
169 | map.putString("networkType", roamLocation.getNetworkType());
170 | map.putString("buildID", roamLocation.getBuildId());
171 | map.putString("kernelVersion", roamLocation.getKernelVersion());
172 | map.putString("ipAddress", roamLocation.getIpAddress());
173 | map.putString("publicIpAddress", roamLocation.getPublicIpAddress());
174 | map.putString("deviceName", roamLocation.getDeviceName());
175 | map.putString("manufacturer", roamLocation.getManufacturer());
176 | map.putInt("androidSdkVersion", roamLocation.getAndroidSdkVersion());
177 | map.putString("androidReleaseVersion", roamLocation.getAndroidReleaseVersion());
178 | map.putString("buildType", roamLocation.getBuildType());
179 | map.putString("buildVersionIncremental", roamLocation.getBuildVersionIncremental());
180 | map.putString("aaid", roamLocation.getAaid());
181 | map.putString("wifiSSID", roamLocation.getWifiSsid());
182 | map.putString("localeCountry", roamLocation.getLocaleCountry());
183 | map.putString("localeLanguage", roamLocation.getLocaleLanguage());
184 | map.putString("carrierName", roamLocation.getCarrierName());
185 | map.putString("appInstallationDate", roamLocation.getAppInstallationDate());
186 | map.putString("appVersion", roamLocation.getAppVersion());
187 | map.putString("testCentroid", roamLocation.getTestCentroid());
188 |
189 | map.putString("appName", roamLocation.getAppName());
190 | map.putString("systemName", roamLocation.getSystemName());
191 | map.putString("sdkVersion", roamLocation.getSdkVersion());
192 | map.putString("locationId", roamLocation.getLocationId());
193 | map.putString("appId", roamLocation.getAppId());
194 | map.putInt("androidSdkVersion", roamLocation.getAndroidSdkVersion());
195 | map.putString("androidReleaseVersion", roamLocation.getAndroidReleaseVersion());
196 | map.putString("buildVersionIncremental", roamLocation.getBuildVersionIncremental());
197 | map.putString("packageName", roamLocation.getPackageName());
198 |
199 | map.putString("mcc", roamLocation.getMcc());
200 | map.putString("mnc", roamLocation.getMnc());
201 | map.putString("iso", roamLocation.getIso());
202 | map.putString("rat", roamLocation.getRat());
203 | map.putString("cid", roamLocation.getCid());
204 | map.putString("lac", roamLocation.getLac());
205 | map.putString("psc", roamLocation.getPsc());
206 | map.putString("enodeBid", roamLocation.getEnodeBid());
207 | map.putString("tac", roamLocation.getTac());
208 | map.putString("pci", roamLocation.getPci());
209 | map.putString("bsi", roamLocation.getBsi());
210 | map.putString("nci", roamLocation.getNci());
211 | map.putString("timingAdvance", roamLocation.getTiming_advance());
212 | map.putString("arfcn", roamLocation.getArfcn());
213 | map.putString("earfcn", roamLocation.getEarfcn());
214 | map.putString("rssi", roamLocation.getRssi());
215 | map.putString("signalLevel", roamLocation.getSignalLevel());
216 | map.putString("rsrp", roamLocation.getRsrp());
217 | map.putString("rsrq", roamLocation.getRsrq());
218 | map.putString("cqi", roamLocation.getCqi());
219 | map.putString("ber", roamLocation.getBer());
220 | map.putString("uarfcn", roamLocation.getUarfcn());
221 | map.putString("wifiBssid", roamLocation.getWifiBssid());
222 | map.putString("wifiRssi", roamLocation.getWifiRssi());
223 | map.putString("wifiMacAddress", roamLocation.getWifiMacAddress());
224 | map.putString("wifiFrequencyBand", roamLocation.getWifiFrequencyBand());
225 | map.putString("wifiChannelNumber", roamLocation.getWifiChannelNumber());
226 | map.putString("wifiLinkSpeed", roamLocation.getWifiLinkSpeed());
227 | map.putString("wifiDhcpGateway", roamLocation.getWifiDhcpGateway());
228 | map.putString("wifiBytesTransferredTx", roamLocation.getWifiBytesTransferredTx());
229 | map.putString("wifiBytesTransferredRx", roamLocation.getWifiBytesTransferredRx());
230 | map.putString("wifiProxySettingHost", roamLocation.getWifiProxySettingHost());
231 | map.putString("wifiProxySettingPort", roamLocation.getWifiProxySettingPort());
232 | map.putString("wifiChannelWidth", roamLocation.getWifiChannelWidth());
233 | map.putString("wifiSubnetMask", roamLocation.getWifiSubnetMask());
234 | map.putString("wifiLeaseDuration", roamLocation.getWifiLeaseDuration());
235 | // map.putBoolean("hiddenWifiDetection", roamLocation.getHiddenWifiDetection());
236 | map.putString("hiddenWifiDetectionDetails", roamLocation.getHiddenWifiDetectionDetails());
237 | map.putString("scanNearbyWifi", roamLocation.getScanNearbyWifi());
238 |
239 | map.putString("networkInterfaceName", roamLocation.getNetworkInterfaceName());
240 | map.putString("dnsServer", roamLocation.getDnsServer());
241 | map.putString("vpnActive", roamLocation.getVpnActive());
242 | map.putString("captivePortalStatus", roamLocation.getCaptivePortalStatus());
243 | map.putString("meteredConnectionStatus", roamLocation.getMeteredConnectionStatus());
244 | map.putString("upstreamBandwidthEstimate", roamLocation.getUpstreamBandwidthEstimate());
245 | map.putString("downstreamBandwidthEstimate", roamLocation.getDownstreamBandwidthEstimate());
246 | map.putString("roamingStatus", roamLocation.getRoamingStatus());
247 | map.putString("simState", roamLocation.getSimState());
248 | map.putString("activeSubscriptionInfo", roamLocation.getActiveSubscriptionInfo());
249 | map.putString("subscriptionInfo", roamLocation.getSubscriptionInfo());
250 | map.putString("esimInfo", roamLocation.getEsimInfo());
251 | map.putString("preferredNetworkMode", roamLocation.getPreferredNetworkMode());
252 | map.putString("cellidBasedLocation", roamLocation.getCellidBasedLocation());
253 | map.putString("carrierConfigManager", roamLocation.getCarrierConfigManager());
254 | map.putString("publicIpAddressApi", roamLocation.getPublicIpAddressApi());
255 |
256 |
257 |
258 | // map.putMap("centroid", RNRoamUtils.mapForCentroid(roamLocation.getCentroid()));
259 | // System.out.println("Mapped centroid: " + RNRoamUtils.mapForCentroid(roamLocation.getCentroid()));
260 | // System.out.println("centroid" + roamLocation.getCentroid());
261 | System.out.println("map" + map);
262 | array.pushMap(map);
263 | }
264 | return array;
265 | }
266 |
267 | static WritableMap mapForCentroid(Centroid centroid) {
268 | System.out.println("Centroid..."+centroid);
269 | if (centroid == null) {
270 | return null;
271 | }
272 |
273 | WritableMap map = Arguments.createMap();
274 | CentroidCoordinate centroidCoordinate = centroid.getCentroid();
275 | if (centroidCoordinate != null) {
276 | WritableMap centroidCoordinateMap = Arguments.createMap();
277 | centroidCoordinateMap.putDouble("latitude", centroidCoordinate.getLatitude());
278 | centroidCoordinateMap.putDouble("longitude", centroidCoordinate.getLongitude());
279 | map.putMap("centroidCoordinate", centroidCoordinateMap);
280 | System.out.println("centroidCoordinateMap..."+centroidCoordinateMap);
281 | }
282 |
283 | List positions = centroid.getPositions();
284 | if (positions != null) {
285 | WritableArray positionsArray = Arguments.createArray();
286 | for (int i = 0; i < positions.size(); i++) {
287 | Positions position = positions.get(i);
288 | if (position != null) {
289 | WritableMap positionMap = Arguments.createMap();
290 | positionMap.putDouble("latitude", position.getLatitude());
291 | positionMap.putDouble("longitude", position.getLongitude());
292 | positionsArray.pushMap(positionMap);
293 | }
294 | }
295 | map.putArray("positions", positionsArray);
296 | System.out.println("positionsArray..."+positionsArray);
297 | }
298 | return map;
299 | }
300 |
301 |
302 |
303 |
304 | static WritableArray mapForTripStatusListener(List list){
305 | WritableArray array = Arguments.createArray();
306 | for (RoamTripStatus roamTripStatus: list) {
307 | WritableMap map = Arguments.createMap();
308 | map.putString("tripId", roamTripStatus.getTripId());
309 | map.putDouble("latitude", roamTripStatus.getLatitude());
310 | map.putDouble("longitude", roamTripStatus.getLongitude());
311 | map.putInt("speed", roamTripStatus.getSpeed());
312 | map.putDouble("distance", roamTripStatus.getDistance());
313 | map.putDouble("duration", roamTripStatus.getDuration());
314 | map.putDouble("pace", roamTripStatus.getPace());
315 | map.putDouble("totalElevation", roamTripStatus.getTotalElevation());
316 | map.putDouble("elevationGain", roamTripStatus.getElevationGain());
317 | map.putDouble("altitude", roamTripStatus.getAltitude());
318 | map.putString("startedTime", roamTripStatus.getStartedTime());
319 | map.putString("state", roamTripStatus.getState());
320 | array.pushMap(map);
321 | }
322 | return array;
323 | }
324 |
325 | static WritableMap mapForTrackingConfig(TrackingConfig config){
326 | WritableMap writableMap = Arguments.createMap();
327 | writableMap.putInt("accuracy", config.getAccuracy());
328 | writableMap.putInt("timeout", config.getTimeout());
329 | writableMap.putString("source", config.getSource());
330 | writableMap.putBoolean("discardLocation", config.getDiscardLocation());
331 | return writableMap;
332 | }
333 |
334 | static WritableMap mapForRoamEvent(RoamEvent roamEvent){
335 | if (roamEvent == null) return null;
336 |
337 | WritableMap map = Arguments.createMap();
338 | map.putString("tripId", roamEvent.getTrip_id());
339 | map.putString("nearbyUserId", roamEvent.getNearby_user_id());
340 | map.putString("userId", roamEvent.getUser_id());
341 | map.putString("geofenceId", roamEvent.getGeofence_id());
342 | map.putString("locationId", roamEvent.getLocation_id());
343 | map.putString("activity", roamEvent.getActivity());
344 | map.putDouble("distance", roamEvent.getDistance());
345 | if (roamEvent.getLocation().getCoordinates().size() == 2){
346 | map.putDouble("longitude", roamEvent.getLocation().getCoordinates().get(0));
347 | map.putDouble("latitude", roamEvent.getLocation().getCoordinates().get(1));
348 | map.putString("type", roamEvent.getLocation().getType());
349 | }
350 | map.putDouble("horizontalAccuracy", roamEvent.getHorizontal_accuracy());
351 | map.putDouble("veritcalAccuracy", roamEvent.getVertical_accuracy());
352 | map.putInt("speed", roamEvent.getSpeed());
353 | map.putDouble("course", roamEvent.getCourse());
354 | map.putString("createdAt", roamEvent.getCreated_at());
355 | map.putString("recordedAt", roamEvent.getRecorded_at());
356 | map.putString("eventSource", roamEvent.getEvent_source());
357 | map.putString("eventVersion", roamEvent.getEvent_version());
358 | map.putString("eventDescription", roamEvent.getDescription());
359 | map.putString("eventType", roamEvent.getEvent_type());
360 |
361 | return map;
362 | }
363 |
364 |
365 | static WritableMap mapForLocation(Location location) {
366 | if (location == null) {
367 | return null;
368 | }
369 | WritableMap map = Arguments.createMap();
370 | map.putDouble("latitude", location.getLatitude());
371 | map.putDouble("longitude", location.getLongitude());
372 | map.putDouble("accuracy", location.getAccuracy());
373 | map.putDouble("altitude", location.getAltitude());
374 | map.putDouble("speed", location.getSpeed());
375 | map.putDouble("verticalAccuracy", location.getVerticalAccuracyMeters());
376 | map.putDouble("course", location.getBearing());
377 | return map;
378 | }
379 |
380 | static WritableMap mapForBatchLocation(BatchLocation location) {
381 | if (location == null) {
382 | return null;
383 | }
384 | WritableMap map = Arguments.createMap();
385 | map.putDouble("latitude", location.getLatitude());
386 | map.putDouble("longitude", location.getLongitude());
387 | map.putDouble("accuracy", location.getAccuracy());
388 | map.putDouble("altitude", location.getAltitude());
389 | map.putDouble("speed", location.getSpeed());
390 | return map;
391 | }
392 |
393 | static WritableMap mapForError(RoamError roamError) {
394 | WritableMap map = Arguments.createMap();
395 | map.putString("code", roamError.getCode());
396 | map.putString("message", roamError.getMessage());
397 | return map;
398 | }
399 |
400 | static WritableMap mapForRoamTripResponse(RoamTripResponse roamTripResponse){
401 | if (roamTripResponse == null) return null;
402 | WritableMap map = Arguments.createMap();
403 | map.putString("code", roamTripResponse.getCode().toString());
404 | map.putString("message", roamTripResponse.getMessage());
405 | map.putString("description", roamTripResponse.getDescription());
406 | map.putMap("trip", mapForTripDetails(roamTripResponse.getTripDetails()));
407 | return map;
408 | }
409 |
410 | static WritableMap mapForTripDetails(TripDetails tripDetails){
411 | if (tripDetails == null) return null;
412 | WritableMap trip = Arguments.createMap();
413 | trip.putString("tripId", tripDetails.getTripId());
414 | trip.putString("name", tripDetails.getTripName());
415 | trip.putString("tripDescription", tripDetails.getTripDescription());
416 | trip.putString("tripState", tripDetails.getTripState());
417 | trip.putDouble("totalDistance", tripDetails.getTotalDistance());
418 | trip.putDouble("totalDuration", tripDetails.getTotalDuration());
419 | trip.putDouble("totalElevationGain", tripDetails.getTotalElevationGain());
420 | trip.putString("metadata", tripDetails.getMetadata() != null ? tripDetails.getMetadata().toString() : null);
421 | trip.putMap("startLocation", mapForTripLocation(tripDetails.getStartLocation()));
422 | trip.putMap("endLocation", mapForTripLocation(tripDetails.getEndLocation()));
423 | trip.putMap("user", mapForTripUser(tripDetails.getUser()));
424 | trip.putString("startedAt", tripDetails.getStartedAt());
425 | trip.putString("endedAt", tripDetails.getEndedAt());
426 | trip.putString("createdAt", tripDetails.getCreatedAt());
427 | trip.putString("updatedAt", tripDetails.getUpdatedAt());
428 | trip.putBoolean("isLocal", tripDetails.getIsLocal());
429 | trip.putBoolean("hasMore", tripDetails.getHasMore());
430 | if (tripDetails.getStops() != null){
431 | WritableArray stopsArray = Arguments.createArray();
432 | for (Stop stop: tripDetails.getStops()){
433 | stopsArray.pushMap(mapForStop(stop));
434 | }
435 | trip.putArray("stops", stopsArray);
436 | } else {
437 | trip.putArray("stops", null);
438 | }
439 | if (tripDetails.getEvents() != null){
440 | WritableArray eventsArray = Arguments.createArray();
441 | for (Events events: tripDetails.getEvents()){
442 | eventsArray.pushMap(mapForEvent(events));
443 | }
444 | trip.putArray("events", eventsArray);
445 | } else {
446 | trip.putArray("events", null);
447 | }
448 | if (tripDetails.getRoutes() != null){
449 | WritableArray routesArray = Arguments.createArray();
450 | for (Routes routes: tripDetails.getRoutes()){
451 | routesArray.pushMap(mapForRoutes(routes));
452 | }
453 | trip.putArray("routes", routesArray);
454 | } else {
455 | trip.putArray("routes", null);
456 | }
457 | trip.putString("routeIndex", tripDetails.getRouteIndex() != null ? tripDetails.getRouteIndex().toString() : null);
458 | if (tripDetails.getLocationCount() != null) {
459 | trip.putInt("locationCount", tripDetails.getLocationCount());
460 | }
461 | return trip;
462 | }
463 |
464 | static WritableMap mapForTripLocation(StartLocation startLocation){
465 | if (startLocation == null) return null;
466 | WritableMap map = Arguments.createMap();
467 | map.putString("id", startLocation.getId());
468 | map.putString("name", startLocation.getName());
469 | map.putString("description", startLocation.getDescription());
470 | map.putString("address", startLocation.getAddress());
471 | map.putString("metadata", startLocation.getMetadata() != null ? startLocation.getMetadata().toString() : null);
472 | map.putString("recordedAt", startLocation.getRecordedAt());
473 | map.putMap("geometry", mapForGeometry(startLocation.getGeometry()));
474 | return map;
475 | }
476 |
477 | static WritableMap mapForTripLocation(EndLocation endLocation){
478 | if (endLocation == null) return null;
479 | WritableMap map = Arguments.createMap();
480 | map.putString("id", endLocation.getId());
481 | map.putString("name", endLocation.getName());
482 | map.putString("description", endLocation.getDescription());
483 | map.putString("address", endLocation.getAddress());
484 | map.putString("metadata", endLocation.getMetadata() != null ? endLocation.getMetadata().toString() : null);
485 | map.putString("recordedAt", endLocation.getRecordedAt());
486 | map.putMap("geometry", mapForGeometry(endLocation.getGeometry()));
487 | return map;
488 | }
489 |
490 | static WritableMap mapForGeometry(Geometry geometry){
491 | if (geometry == null) return null;
492 | WritableMap map = Arguments.createMap();
493 | map.putString("type", geometry.getType());
494 | WritableArray coordinates = Arguments.createArray();
495 | for(Double value: geometry.getCoordinates()){
496 | coordinates.pushDouble(value);
497 | }
498 | map.putArray("coordinates", coordinates);
499 | return map;
500 | }
501 |
502 | static WritableMap mapForCoordinates(Coordinates coordinates){
503 | if (coordinates == null) return null;
504 | WritableMap map = Arguments.createMap();
505 | map.putString("type", coordinates.getType());
506 | WritableArray coordinatesArray = Arguments.createArray();
507 | for(Double value: coordinates.getCoordinates()){
508 | coordinatesArray.pushDouble(value);
509 | }
510 | map.putArray("coordinates", coordinatesArray);
511 | return map;
512 | }
513 |
514 | static WritableMap mapForTripUser(User user){
515 | if (user == null) return null;
516 | WritableMap map = Arguments.createMap();
517 | map.putString("name", user.getName());
518 | map.putString("description", user.getDescription());
519 | map.putString("metadata", user.getMetadata() != null ? user.getMetadata().toString() : null);
520 | map.putString("id", user.getId());
521 | return map;
522 | }
523 |
524 | static WritableMap mapForStop(Stop stop){
525 | if (stop == null) return null;
526 | WritableMap map = Arguments.createMap();
527 | map.putString("id", stop.getId());
528 | map.putString("name", stop.getStopName());
529 | map.putString("description", stop.getStopDescription());
530 | map.putString("address", stop.getAddress());
531 | map.putString("metadata", stop.getMetadata() != null ? stop.getMetadata().toString() : null);
532 | map.putDouble("geometryRadius", stop.getGeometryRadius());
533 | map.putString("createdAt", stop.getCreatedAt());
534 | map.putString("updatedAt", stop.getUpdatedAt());
535 | map.putString("arrivedAt", stop.getArrivedAt());
536 | map.putString("departedAt", stop.getDepartedAt());
537 | map.putMap("geometry", mapForGeometry(stop.getGeometry()));
538 | return map;
539 | }
540 |
541 | static WritableMap mapForEvent(Events events){
542 | if (events == null) return null;
543 | WritableMap map = Arguments.createMap();
544 | map.putString("id", events.getId());
545 | map.putString("tripId", events.getTripId());
546 | map.putString("userId", events.getUserId());
547 | map.putString("eventType", events.getEventType());
548 | map.putString("createAt", events.getCreatedAt());
549 | map.putString("eventSource", events.getEventSource());
550 | map.putString("eventVersion", events.getEventVersion());
551 | map.putString("locationId", events.getLocationId());
552 | return map;
553 | }
554 |
555 | static WritableMap mapForRoutes(Routes routes){
556 | if (routes == null) return null;
557 | WritableMap map = Arguments.createMap();
558 | map.putString("metadata", routes.getMetadata() != null ? routes.getMetadata().toString() : null);
559 | map.putString("activity", routes.getActivity());
560 | map.putDouble("speed", routes.getSpeed());
561 | map.putDouble("altitude", routes.getAltitude());
562 | map.putDouble("distance", routes.getDistance());
563 | map.putDouble("duration", routes.getDuration());
564 | map.putDouble("elevationGain", routes.getElevationGain());
565 | map.putMap("coordinates", mapForCoordinates(routes.getCoordinates()));
566 | map.putString("recordedAt", routes.getRecordedAt());
567 | map.putString("locationId", routes.getLocationId());
568 | map.putDouble("bearing", routes.getBearing());
569 | return map;
570 | }
571 |
572 | static WritableMap mapForTripError(Error error){
573 | if (error == null) return null;
574 | WritableMap map = Arguments.createMap();
575 | if (error.getErrors() != null){
576 | WritableArray errorsArray = Arguments.createArray();
577 | for (Errors errors: error.getErrors()){
578 | WritableMap errorsMap = Arguments.createMap();
579 | errorsMap.putString("field", errors.getField());
580 | errorsMap.putString("message", errors.getMessage());
581 | errorsArray.pushMap(errorsMap);
582 | }
583 | map.putArray("errors", errorsArray);
584 | } else {
585 | map.putArray("errors", null);
586 | }
587 | map.putInt("code", error.getErrorCode());
588 | map.putString("message", error.getErrorMessage());
589 | map.putString("description", error.getErrorDescription());
590 | return map;
591 | }
592 |
593 | static WritableMap mapForRoamSyncTripResponse(RoamSyncTripResponse roamSyncTripResponse){
594 | if (roamSyncTripResponse == null) return null;
595 | WritableMap map = Arguments.createMap();
596 | map.putString("msg", roamSyncTripResponse.getMessage());
597 | map.putString("description", roamSyncTripResponse.getDescription());
598 | map.putInt("code", roamSyncTripResponse.getCode());
599 | WritableMap data = Arguments.createMap();
600 | if (roamSyncTripResponse.getData() != null) {
601 | data.putString("tripId", roamSyncTripResponse.getData().getTrip_id());
602 | if (roamSyncTripResponse.getData().getIsSynced() != null){
603 | data.putBoolean("isSynced", roamSyncTripResponse.getData().getIsSynced());
604 | }
605 | }
606 | map.putMap("data", data);
607 | return map;
608 | }
609 |
610 | static WritableMap mapForActiveTripsResponse(RoamActiveTripsResponse roamActiveTripsResponse){
611 | if (roamActiveTripsResponse == null) return null;
612 | WritableMap map = Arguments.createMap();
613 | map.putInt("code", roamActiveTripsResponse.getCode());
614 | map.putString("message", roamActiveTripsResponse.getMessage());
615 | map.putString("description", roamActiveTripsResponse.getDescription());
616 | map.putBoolean("hasMore", roamActiveTripsResponse.isHas_more());
617 | if (roamActiveTripsResponse.getTrips() != null){
618 | WritableArray tripsArray = Arguments.createArray();
619 | for(Trips trips: roamActiveTripsResponse.getTrips()){
620 | tripsArray.pushMap(mapForTrips(trips));
621 | }
622 | map.putArray("trips", tripsArray);
623 | } else {
624 | map.putArray("trips", null);
625 | }
626 | return map;
627 | }
628 |
629 | static WritableMap mapForTrips(Trips trips){
630 | if (trips == null) return null;
631 | WritableMap map = Arguments.createMap();
632 | map.putString("id", trips.getTripId());
633 | map.putString("tripState", trips.getTripState());
634 | map.putDouble("totalDistance", trips.getTotalDistance());
635 | map.putDouble("totalDuration", trips.getTotalDuration());
636 | map.putDouble("totalElevationGain", trips.getTotalElevationGain());
637 | map.putString("metadata", trips.metadata() != null ? trips.metadata().toString() : null);
638 | map.putMap("user", mapForTripUser(trips.getUser()));
639 | map.putString("startedAt", trips.getStartedAt());
640 | map.putString("endedAt", trips.getEndedAt());
641 | map.putString("createdAt", trips.getCreatedAt());
642 | map.putString("updatedAt", trips.getUpdatedAt());
643 | if (trips.getStop() != null){
644 | WritableArray stopsArray = Arguments.createArray();
645 | for (Stop stop: trips.getStop()){
646 | stopsArray.pushMap(mapForStop(stop));
647 | }
648 | map.putArray("stops", stopsArray);
649 | } else {
650 | map.putArray("stops", null);
651 | }
652 | if (trips.getEvents() != null){
653 | WritableArray eventsArray = Arguments.createArray();
654 | for (Events events: trips.getEvents()){
655 | eventsArray.pushMap(mapForEvent(events));
656 | }
657 | map.putArray("events", eventsArray);
658 | } else {
659 | map.putArray("events", null);
660 | }
661 | map.putString("syncStatus", trips.getSyncStatus());
662 | return map;
663 | }
664 |
665 | static WritableMap mapForRoamDeleteTripResponse(RoamDeleteTripResponse roamDeleteTripResponse){
666 | if (roamDeleteTripResponse == null) return null;
667 | WritableMap map = Arguments.createMap();
668 | map.putString("message", roamDeleteTripResponse.getMessage());
669 | map.putString("description", roamDeleteTripResponse.getDescription());
670 | map.putInt("code", roamDeleteTripResponse.getCode());
671 | WritableMap trip = Arguments.createMap();
672 | if (roamDeleteTripResponse.getTrip() != null) {
673 | trip.putString("id", roamDeleteTripResponse.getTrip().getId());
674 | if (roamDeleteTripResponse.getTrip().getIs_deleted() != null){
675 | trip.putBoolean("isDeleted", roamDeleteTripResponse.getTrip().getIs_deleted());
676 | }
677 | }
678 | map.putMap("trip", trip);
679 | return map;
680 | }
681 |
682 |
683 |
684 | static RoamTripStops decodeRoamTripsStop(ReadableMap map){
685 | String id = map.hasKey("RoamTripStop") ? map.getString("RoamTripStop") : null;
686 | String stopName = map.hasKey("stopName") ? map.getString("stopName") : null;
687 | String stopDescription = map.hasKey("stopDescription") ? map.getString("stopDescription") : null;
688 | String address = map.hasKey("address") ? map.getString("address") : null;
689 | Double geometryRadius = map.hasKey("geometryRadius") ? map.getDouble("geometryRadius") : null;
690 | ReadableArray geometryCoordinates = map.hasKey("geometryCoordinates") ? map.getArray("geometryCoordinates") : null;
691 | List geometryCoordinatesList = new ArrayList<>();
692 | if (geometryCoordinates != null && geometryCoordinates.size() == 2){
693 | geometryCoordinatesList.add(geometryCoordinates.getDouble(0));
694 | geometryCoordinatesList.add(geometryCoordinates.getDouble(1));
695 | }
696 | ReadableMap metadata = map.hasKey("metadata") ? map.getMap("metadata") : null;
697 | RoamTripStops stop = new RoamTripStops();
698 | if (id != null){
699 | stop.setStopId(id);
700 | }
701 | if (stopName != null){
702 | stop.setStopName(stopName);
703 | }
704 | if (stopDescription != null){
705 | stop.setStopDescription(stopDescription);
706 | }
707 | if (address != null){
708 | stop.setAddress(address);
709 | }
710 | stop.setGeometryRadius(geometryRadius);
711 | if (geometryCoordinatesList.size() == 2){
712 | stop.setGeometry(geometryCoordinatesList);
713 | }
714 | if (metadata != null){
715 | JSONObject jsonObject = new JSONObject(metadata.toHashMap());
716 | stop.setMetadata(jsonObject);
717 | }
718 | return stop;
719 | }
720 |
721 | static RoamTrip decodeRoamTrip(ReadableMap map){
722 | Log.e("TAG", map.toString());
723 | try{
724 | Log.e("TAG", map.getString("tripId"));
725 | }catch (Exception e){
726 | e.printStackTrace();
727 | }
728 | String tripId = map.hasKey("tripId") ? map.getString("tripId") : null;
729 | Log.e("TAG", "tripId: " + tripId);
730 | String tripDescription = map.hasKey("tripDescription") ? map.getString("tripDescription") : null;
731 | String tripName = map.hasKey("tripName") ? map.getString("tripName") : null;
732 | ReadableMap metadata = map.hasKey("metadata") ? map.getMap("metadata") : null;
733 | Boolean isLocal = map.hasKey("isLocal") ? map.getBoolean("isLocal") : null;
734 | ReadableArray stops = map.hasKey("stops") ? map.getArray("stops") : null;
735 | String userId = map.hasKey("userId") ? map.getString("userId") : null;
736 | RoamTrip.Builder roamTripBuilder = new RoamTrip.Builder();
737 | if (tripId != null){
738 | Log.e("TAG", "tripId: " + tripId);
739 | roamTripBuilder.setTripId(tripId);
740 | }
741 | if (tripDescription != null){
742 | roamTripBuilder.setTripDescription(tripDescription);
743 | }
744 | if (tripName != null){
745 | roamTripBuilder.setTripName(tripName);
746 | }
747 | if (metadata != null){
748 | roamTripBuilder.setMetadata(new JSONObject(metadata.toHashMap()));
749 | }
750 | if(isLocal != null){
751 | roamTripBuilder.setIsLocal(isLocal);
752 | }
753 | if (stops != null){
754 | List stopsList = new ArrayList<>();
755 | for(int i=0; i stopsList = new ArrayList<>();
796 | for(int i=0; i list) {
866 | WritableArray writableArray = RNRoamUtils.mapForBatchReceiverConfig(list);
867 | successCallback.invoke(writableArray);
868 | }
869 |
870 | @Override
871 | public void onFailure(RoamError roamError) {
872 | errorCallback.invoke(RNRoamUtils.mapForError(roamError));
873 | }
874 | });
875 | }
876 |
877 | @ReactMethod
878 | public void getBatchReceiverConfig(Callback successCallback, Callback errorCallback){
879 | Roam.getBatchReceiverConfig(new RoamBatchReceiverCallback() {
880 | @Override
881 | public void onSuccess(List list) {
882 | successCallback.invoke(RNRoamUtils.mapForBatchReceiverConfig(list));
883 | }
884 |
885 | @Override
886 | public void onFailure(RoamError roamError) {
887 | errorCallback.invoke(RNRoamUtils.mapForError(roamError));
888 | }
889 | });
890 | }
891 |
892 | @ReactMethod
893 | public void resetBatchReceiverConfig(Callback successCallback, Callback errorCallback){
894 | Roam.resetBatchReceiverConfig(new RoamBatchReceiverCallback() {
895 | @Override
896 | public void onSuccess(List list) {
897 | successCallback.invoke(RNRoamUtils.mapForBatchReceiverConfig(list));
898 | }
899 |
900 | @Override
901 | public void onFailure(RoamError roamError) {
902 | errorCallback.invoke(RNRoamUtils.mapForError(roamError));
903 | }
904 | });
905 | }
906 |
907 |
908 | @ReactMethod
909 | public void offlineLocationTracking(boolean value) {
910 | Roam.offlineLocationTracking(value);
911 | }
912 |
913 | @ReactMethod
914 | public void publishAndSave(ReadableMap readableMap) {
915 | RoamPublish.Builder roamPublish = new RoamPublish.Builder();
916 | if (readableMap != null && readableMap.getMap(RNRoamUtils.METADATA) != null) {
917 | try {
918 | ReadableMap rm = readableMap.getMap(RNRoamUtils.METADATA);
919 | JSONObject jsonObject = new JSONObject(rm.toString());
920 | if (jsonObject.getJSONObject("NativeMap").length() > 0) {
921 | roamPublish.metadata(jsonObject.getJSONObject("NativeMap"));
922 | }
923 | roamPublish.metadata(jsonObject.getJSONObject("NativeMap"));
924 | } catch (JSONException e) {
925 | }
926 | }
927 | Roam.publishAndSave(roamPublish.build(), new PublishCallback() {
928 | @Override
929 | public void onSuccess(String s) {
930 |
931 | }
932 |
933 | @Override
934 | public void onError(RoamError roamError) {
935 |
936 | }
937 | });
938 | }
939 |
940 | @ReactMethod
941 | public void publishOnly(ReadableArray readableArray, ReadableMap readableMap) {
942 | RoamPublish.Builder roamPublish = new RoamPublish.Builder();
943 | if (readableArray != null && readableArray.size() > 0) {
944 | for (int i = 0; i < readableArray.size(); i++) {
945 | if (readableArray.getString(i).equals(RNRoamUtils.APP_ID)) {
946 | roamPublish.appId();
947 | continue;
948 | }
949 | if (readableArray.getString(i).equals(RNRoamUtils.USER_ID)) {
950 | roamPublish.userId();
951 | continue;
952 | }
953 | if (readableArray.getString(i).equals(RNRoamUtils.GEOFENCE_EVENTS)) {
954 | roamPublish.geofenceEvents();
955 | continue;
956 | }
957 | if (readableArray.getString(i).equals(RNRoamUtils.LOCATION_EVENTS)) {
958 | roamPublish.locationEvents();
959 | continue;
960 | }
961 | if (readableArray.getString(i).equals(RNRoamUtils.NEARBY_EVENTS)) {
962 | roamPublish.nearbyEvents();
963 | continue;
964 | }
965 | if (readableArray.getString(i).equals(RNRoamUtils.TRIPS_EVENTS)) {
966 | roamPublish.tripsEvents();
967 | continue;
968 | }
969 | if (readableArray.getString(i).equals(RNRoamUtils.LOCATION_LISTENER)) {
970 | roamPublish.locationListener();
971 | continue;
972 | }
973 | if (readableArray.getString(i).equals(RNRoamUtils.EVENT_LISTENER)) {
974 | roamPublish.eventListener();
975 | continue;
976 | }
977 | if (readableArray.getString(i).equals(RNRoamUtils.ALTITUDE)) {
978 | roamPublish.altitude();
979 | continue;
980 | }
981 | if (readableArray.getString(i).equals(RNRoamUtils.COURSE)) {
982 | roamPublish.course();
983 | continue;
984 | }
985 | if (readableArray.getString(i).equals(RNRoamUtils.SPEED)) {
986 | roamPublish.speed();
987 | continue;
988 | }
989 | if (readableArray.getString(i).equals(RNRoamUtils.HORIZONTAL_ACCURACY)) {
990 | roamPublish.horizontalAccuracy();
991 | continue;
992 | }
993 | if (readableArray.getString(i).equals(RNRoamUtils.VERTICAL_ACCURACY)) {
994 | roamPublish.verticalAccuracy();
995 | continue;
996 | }
997 | if (readableArray.getString(i).equals(RNRoamUtils.APP_CONTEXT)) {
998 | roamPublish.appContext();
999 | continue;
1000 | }
1001 | if (readableArray.getString(i).equals(RNRoamUtils.ALLOW_MOCKED)) {
1002 | roamPublish.allowMocked();
1003 | continue;
1004 | }
1005 | if (readableArray.getString(i).equals(RNRoamUtils.BATTERY_REMAINING)) {
1006 | roamPublish.batteryRemaining();
1007 | continue;
1008 | }
1009 | if (readableArray.getString(i).equals(RNRoamUtils.BATTERY_SAVER)) {
1010 | roamPublish.batterySaver();
1011 | continue;
1012 | }
1013 | if (readableArray.getString(i).equals(RNRoamUtils.BATTERY_STATUS)) {
1014 | roamPublish.batteryStatus();
1015 | continue;
1016 | }
1017 | if (readableArray.getString(i).equals(RNRoamUtils.ACTIVITY)) {
1018 | roamPublish.activity();
1019 | continue;
1020 | }
1021 | if (readableArray.getString(i).equals(RNRoamUtils.AIRPLANE_MODE)) {
1022 | roamPublish.airplaneMode();
1023 | continue;
1024 | }
1025 | if (readableArray.getString(i).equals(RNRoamUtils.DEVICE_MANUFACTURE)) {
1026 | roamPublish.deviceManufacturer();
1027 | continue;
1028 | }
1029 | if (readableArray.getString(i).equals(RNRoamUtils.DEVICE_MODEL)) {
1030 | roamPublish.deviceModel();
1031 | continue;
1032 | }
1033 | if (readableArray.getString(i).equals(RNRoamUtils.TRACKING_MODE)) {
1034 | roamPublish.trackingMode();
1035 | continue;
1036 | }
1037 | if (readableArray.getString(i).equals(RNRoamUtils.LOCATIONPERMISSION)) {
1038 | roamPublish.locationPermission();
1039 | continue;
1040 | }
1041 | if (readableArray.getString(i).equals(RNRoamUtils.NETWORK_STATUS)) {
1042 | roamPublish.networkStatus();
1043 | continue;
1044 | }
1045 | if (readableArray.getString(i).equals(RNRoamUtils.GPS_STATUS)) {
1046 | roamPublish.gpsStatus();
1047 | continue;
1048 | }
1049 | if (readableArray.getString(i).equals(RNRoamUtils.OS_VERSION)) {
1050 | roamPublish.osVersion();
1051 | continue;
1052 | }
1053 | if (readableArray.getString(i).equals(RNRoamUtils.RECORDERD_AT)) {
1054 | roamPublish.recordedAt();
1055 | continue;
1056 | }
1057 | if (readableArray.getString(i).equals(RNRoamUtils.TZ_OFFSET)) {
1058 | roamPublish.tzOffset();
1059 | continue;
1060 | }
1061 | if (readableArray.getString(i).equals(RNRoamUtils.RECORDERD_AT)) {
1062 | roamPublish.recordedAt();
1063 | continue;
1064 | }
1065 | if (readableArray.getString(i).equals(RNRoamUtils.ACTIVITY)) {
1066 | roamPublish.activity();
1067 | }
1068 | }
1069 | }
1070 | if (readableMap != null && readableMap.getMap(RNRoamUtils.METADATA) != null) {
1071 | try {
1072 | ReadableMap rm = readableMap.getMap(RNRoamUtils.METADATA);
1073 | JSONObject jsonObject = new JSONObject(rm.toString());
1074 | if (jsonObject.getJSONObject("NativeMap").length() > 0) {
1075 | roamPublish.metadata(jsonObject.getJSONObject("NativeMap"));
1076 | }
1077 | roamPublish.metadata(jsonObject.getJSONObject("NativeMap"));
1078 | } catch (JSONException e) {
1079 | }
1080 | }
1081 | Roam.publishOnly(roamPublish.build(), new PublishCallback() {
1082 | @Override
1083 | public void onSuccess(String s) {
1084 |
1085 | }
1086 |
1087 | @Override
1088 | public void onError(RoamError roamError) {
1089 |
1090 | }
1091 | });
1092 | }
1093 |
1094 |
1095 |
1096 | @ReactMethod
1097 | public void stopPublishing() {
1098 | Roam.stopPublishing(new PublishCallback() {
1099 | @Override
1100 | public void onSuccess(String s) {
1101 |
1102 | }
1103 |
1104 | @Override
1105 | public void onError(RoamError roamError) {
1106 |
1107 | }
1108 | });
1109 | }
1110 |
1111 | // @ReactMethod
1112 | // public void batchProcess(boolean enable, int syncHour) {
1113 | // // This method has been disabled due to missing roam-batch-connector dependency
1114 | // Log.d("RNRoam", "batchProcess method is currently disabled");
1115 | // }
1116 |
1117 | @ReactMethod
1118 | public void enableAccuracyEngine(int accuracy) {
1119 | Roam.enableAccuracyEngine(accuracy);
1120 | }
1121 |
1122 | @ReactMethod
1123 | public void disableAccuracyEngine() {
1124 | Roam.disableAccuracyEngine();
1125 | }
1126 |
1127 | @ReactMethod
1128 | public void startSelfTracking(String trackingMode) {
1129 | switch (trackingMode) {
1130 | case "ACTIVE":
1131 | Roam.startTracking(RoamTrackingMode.ACTIVE, new TrackingCallback() {
1132 | @Override
1133 | public void onSuccess(String s) {
1134 |
1135 | }
1136 |
1137 | @Override
1138 | public void onError(RoamError roamError) {
1139 |
1140 | }
1141 | });
1142 | break;
1143 | case "BALANCED":
1144 | Roam.startTracking(RoamTrackingMode.BALANCED, new TrackingCallback() {
1145 | @Override
1146 | public void onSuccess(String s) {
1147 |
1148 | }
1149 |
1150 | @Override
1151 | public void onError(RoamError roamError) {
1152 |
1153 | }
1154 | });
1155 | break;
1156 | case "PASSIVE":
1157 | Roam.startTracking(RoamTrackingMode.PASSIVE, new TrackingCallback() {
1158 | @Override
1159 | public void onSuccess(String s) {
1160 |
1161 | }
1162 |
1163 | @Override
1164 | public void onError(RoamError roamError) {
1165 |
1166 | }
1167 | });
1168 | break;
1169 | }
1170 | }
1171 |
1172 | @ReactMethod
1173 | public void startSelfTrackingTimeInterval(int timeInterval, String desiredAccuracy) {
1174 | RoamTrackingMode.Builder builder = new RoamTrackingMode.Builder(timeInterval);
1175 | switch (desiredAccuracy) {
1176 | case "MEDIUM":
1177 | builder.setDesiredAccuracy(RoamTrackingMode.DesiredAccuracy.MEDIUM);
1178 | break;
1179 | case "LOW":
1180 | builder.setDesiredAccuracy(RoamTrackingMode.DesiredAccuracy.LOW);
1181 | break;
1182 | default:
1183 | builder.setDesiredAccuracy(RoamTrackingMode.DesiredAccuracy.HIGH);
1184 | break;
1185 | }
1186 | Roam.startTracking(builder.build(), new TrackingCallback() {
1187 | @Override
1188 | public void onSuccess(String s) {
1189 |
1190 | }
1191 |
1192 | @Override
1193 | public void onError(RoamError roamError) {
1194 |
1195 | }
1196 | });
1197 | }
1198 |
1199 | @ReactMethod
1200 | public void startSelfTrackingDistanceInterval(int distance, int stationary, String desiredAccuracy) {
1201 | RoamTrackingMode.Builder builder = new RoamTrackingMode.Builder(distance, stationary);
1202 | switch (desiredAccuracy) {
1203 | case "MEDIUM":
1204 | builder.setDesiredAccuracy(RoamTrackingMode.DesiredAccuracy.MEDIUM);
1205 | break;
1206 | case "LOW":
1207 | builder.setDesiredAccuracy(RoamTrackingMode.DesiredAccuracy.LOW);
1208 | break;
1209 | default:
1210 | builder.setDesiredAccuracy(RoamTrackingMode.DesiredAccuracy.HIGH);
1211 | break;
1212 | }
1213 | Roam.startTracking(builder.build(), new TrackingCallback() {
1214 | @Override
1215 | public void onSuccess(String s) {
1216 |
1217 | }
1218 |
1219 | @Override
1220 | public void onError(RoamError roamError) {
1221 |
1222 | }
1223 | });
1224 | }
1225 |
1226 | @ReactMethod
1227 | public void stopSelfTracking() {
1228 | Roam.stopTracking(new TrackingCallback() {
1229 | @Override
1230 | public void onSuccess(String s) {
1231 |
1232 | }
1233 |
1234 | @Override
1235 | public void onError(RoamError roamError) {
1236 |
1237 | }
1238 | });
1239 | }
1240 |
1241 | @ReactMethod
1242 | public void checkActivityPermission(Callback callback){
1243 | callback.invoke(RNRoamUtils.isGranted(Roam.checkActivityPermission()));
1244 | }
1245 |
1246 | @ReactMethod
1247 | public void requestActivityPermission(){
1248 | Activity activity = getCurrentActivity();
1249 | if (activity != null){
1250 | Roam.requestActivityPermission(activity);
1251 | }
1252 | }
1253 |
1254 | }
--------------------------------------------------------------------------------