├── .circleci
└── config.yml
├── .eslintrc
├── .github
├── ISSUE_TEMPLATE.md
└── workflows
│ ├── radar-pre-release-actions.yml
│ ├── radar-release-actions.yml
│ └── update-native-sdks.yml
├── .gitignore
├── .npmignore
├── LICENSE
├── MIGRATION.md
├── README.md
├── android
├── .npmignore
├── build.gradle
├── build.gradle.template
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── io
│ └── radar
│ └── react
│ ├── RNRadarModule.java
│ ├── RNRadarPackage.java
│ ├── RNRadarReceiver.java
│ ├── RNRadarUtils.java
│ └── RNRadarVerifiedReceiver.java
├── app.plugin.js
├── babel.config.js
├── copyAssets.sh
├── example
├── .gitignore
├── App.tsx
├── app.json
├── assets
│ ├── adaptive-icon.png
│ ├── favicon.png
│ ├── icon.png
│ └── splash.png
├── babel.config.js
├── components
│ └── exampleButton.js
├── eas.json
├── index.js
├── metro.config.js
├── package-lock.json
├── package.json
└── tsconfig.json
├── hooks
└── pre-commit
├── ios
├── .npmignore
├── Cartfile.private
├── Cartfile.resolved
├── Cartfile.resolved.template
├── RNRadar.h
├── RNRadar.m
└── RNRadar.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ └── RNRadar.xcscheme
├── logo.png
├── package-lock.json
├── package.json
├── plugin
├── src
│ ├── index.ts
│ ├── types.ts
│ ├── withRadar.ts
│ ├── withRadarAndroid.ts
│ └── withRadarIOS.ts
└── tsconfig.json
├── react-native-radar.podspec
├── react-native-radar.podspec.template
├── react-native.config.js
├── scripts
├── check-beta-tag.cjs
└── check-latest-tag.cjs
├── src
├── @types
│ ├── RadarNativeInterface.ts
│ └── types.ts
├── helpers.js
├── index.native.ts
├── index.ts
├── index.web.js
└── ui
│ ├── autocomplete.jsx
│ ├── back.png
│ ├── close.png
│ ├── images.js
│ ├── map-logo.png
│ ├── map.jsx
│ ├── marker.png
│ ├── radar-logo.png
│ ├── search.png
│ └── styles.js
├── test
├── index.test.js
└── jest.setup.js
└── tsconfig.json
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | orbs:
3 | macos: circleci/macos@2
4 | jobs:
5 | node:
6 | working_directory: ~/react-native-radar
7 | docker:
8 | - image: cimg/node:18.0
9 | steps:
10 | - checkout
11 | - run: npm install
12 | - run: npm install -g typescript
13 | - run:
14 | name: Test
15 | command: |
16 | mkdir -p test-results/jest
17 | npm run test
18 | environment:
19 | JEST_JUNIT_OUTPUT: test-results/jest/junit.xml
20 | - run:
21 | name: Type-check
22 | command: npm run build-all
23 | - persist_to_workspace:
24 | root: ~/react-native-radar
25 | paths:
26 | - android
27 | - ios
28 | - README.md
29 | - react-native-radar.podspec
30 | - dist
31 | - app.plugin.js
32 | - plugin/build
33 | - example
34 | - package.json
35 | - store_test_results:
36 | path: test-results
37 | - store_artifacts:
38 | path: test-results
39 | android:
40 | working_directory: ~/react-native-radar/example
41 | docker:
42 | - image: cimg/android:2024.01.1-browsers
43 | steps:
44 | - attach_workspace:
45 | at: ~/react-native-radar
46 | - run:
47 | name: Install Dependencies
48 | command: npm install
49 | - run:
50 | name: Install Radar from local path
51 | command: npm run install-radar-rebuild
52 | - run: sudo yarn global add react-native
53 | - run:
54 | name: Install Ninja
55 | command: |
56 | sudo apt-get update -o Acquire::AllowInsecureRepositories=true
57 | sudo apt-get install -y ninja-build
58 | - run: chown -R $USER:$USER android
59 | - run: cd android && ./gradlew
60 | ios:
61 | macos:
62 | xcode: "15.3.0"
63 | working_directory: ~/react-native-radar/example
64 | steps:
65 | - attach_workspace:
66 | at: ~/react-native-radar
67 | - run:
68 | name: Install Dependencies
69 | command: npm install
70 | - run:
71 | name: Install Radar from local path
72 | command: npm run install-radar-rebuild
73 | - run: cd ios
74 | - run: xcodebuild -workspace ios/Example.xcworkspace -scheme Example -sdk iphonesimulator
75 |
76 |
77 | workflows:
78 | version: 2
79 | node-android-ios:
80 | jobs:
81 | - node
82 | - android:
83 | requires:
84 | - node
85 | - ios:
86 | requires:
87 | - node
88 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "jest": true,
5 | "jest/globals": true
6 | },
7 | "extends": "airbnb",
8 | "parser": "babel-eslint",
9 | "plugins": [
10 | "react",
11 | "jest"
12 | ],
13 | "rules": {
14 | "consistent-return": 0,
15 | "func-names": 0,
16 | "global-require": 0,
17 | "max-len": 0,
18 | "no-alert": 0,
19 | "no-param-reassign": 0,
20 | "no-plusplus": 0,
21 | "no-shadow": 0,
22 | "no-throw-literal": 0,
23 | "no-underscore-dangle": 0,
24 | "no-unused-vars": ["error", {
25 | "argsIgnorePattern": "_",
26 | "varsIgnorePattern": "_"
27 | }],
28 | "object-curly-newline": 0,
29 | "operator-linebreak": 0,
30 | "prefer-destructuring": ["error", {
31 | "VariableDeclarator": { "array": false, "object": true },
32 | "AssignmentExpression": { "array": false, "object": false }
33 | }],
34 | "react/jsx-one-expression-per-line": 0,
35 | "react/jsx-wrap-multilines": 0,
36 | "react/no-array-index-key": 0,
37 | "react/no-danger": 0,
38 | "react/prop-types": 0,
39 | "no-restricted-properties": [0, {
40 | "object": "Math",
41 | "property": "pow"
42 | }],
43 | "no-bitwise": 0,
44 | "padded-blocks": 0
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
6 |
7 | ## Summary
8 |
9 | ## Code to reproduce
10 |
11 | ## Steps to reproduce
12 |
13 | ## OS version
14 |
15 | ## SDK installation method
16 |
17 | ## SDK version
18 |
19 | ## Other information
20 |
--------------------------------------------------------------------------------
/.github/workflows/radar-pre-release-actions.yml:
--------------------------------------------------------------------------------
1 | name: Publish beta package to npmjs
2 | on:
3 | release:
4 | types: [ prereleased ]
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v2
10 | # Setup .npmrc file to publish to npm
11 | - uses: actions/setup-node@v2
12 | with:
13 | node-version: '16.x'
14 | registry-url: 'https://registry.npmjs.org'
15 | - run: npm ci
16 | - run: npm run check-beta-tag
17 | - run: npm run build
18 | - run: npm run copy-assets
19 | - run: npm run build-plugin
20 | - run: npm publish --tag beta
21 | env:
22 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
--------------------------------------------------------------------------------
/.github/workflows/radar-release-actions.yml:
--------------------------------------------------------------------------------
1 | name: Publish latest package to npmjs
2 | on:
3 | release:
4 | types: [ released ]
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v2
10 | # Setup .npmrc file to publish to npm
11 | - uses: actions/setup-node@v2
12 | with:
13 | node-version: '16.x'
14 | registry-url: 'https://registry.npmjs.org'
15 | - run: npm ci
16 | - run: npm run check-latest-tag
17 | - run: npm run build
18 | - run: npm run copy-assets
19 | - run: npm run build-plugin
20 | - run: npm publish
21 | env:
22 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
--------------------------------------------------------------------------------
/.github/workflows/update-native-sdks.yml:
--------------------------------------------------------------------------------
1 | # Bump Native SDK version numbers whenever a repository dispatch of a release
2 | # is received
3 | name: Bump Native SDKs
4 | on:
5 | repository_dispatch:
6 | types: ['ios-sdk-release', 'android-sdk-release']
7 | jobs:
8 | update_android_sdk_version:
9 | runs-on: ubuntu-latest
10 | if: github.event.client_payload.platform == 'android'
11 | steps:
12 | - name: Event Information
13 | run: echo ${{ github.event.client_payload.release }}
14 |
15 | # checkout the repo
16 | - uses: actions/checkout@v2
17 |
18 | # copy the template file to its final destination
19 | - name: Copy android/build.gradle template file
20 | uses: canastro/copy-action@master
21 | with:
22 | source: 'android/build.gradle.template'
23 | target: 'android/build.gradle'
24 |
25 | # render the template using the input sdk version
26 | - name: Render radar-sdk-android release version onto build.gradle
27 | uses: jayamanikharyono/jinja-action@v0.1
28 | with:
29 | data: version=${{ github.event.client_payload.release }}
30 | path: 'android/build.gradle'
31 |
32 | # Update package.json to latest version
33 | - name: Update package.json to latest
34 | run: npm version ${{ github.event.client_payload.release }} --commit-hooks false --git-tag-version false
35 |
36 | # open a pull request with the new sdk version
37 | - name: Create Pull Request
38 | uses: peter-evans/create-pull-request@v3
39 | with:
40 | title: Automated radar-sdk-android version bump to ${{ github.event.client_payload.release }}
41 | reviewers: radarlabs/eng
42 | token: ${{ secrets.GITHUB_TOKEN }}
43 | update_ios_sdk_version:
44 | runs-on: ubuntu-latest
45 | if: github.event.client_payload.platform == 'ios'
46 | steps:
47 | - name: Event Information
48 | run: echo ${{ github.event.client_payload.release }}
49 |
50 | # checkout the repo
51 | - uses: actions/checkout@v2
52 |
53 | # copy the podspec template to its final destination
54 | - name: Copy the podspec template
55 | uses: canastro/copy-action@master
56 | with:
57 | source: 'react-native-radar.podspec.template'
58 | target: 'react-native-radar.podspec'
59 |
60 | # render the podspec template with the sdk version
61 | - name: Render radar-sdk-ios release version onto podspec template
62 | uses: jayamanikharyono/jinja-action@v0.1
63 | with:
64 | data: version=${{ github.event.client_payload.release }}
65 | path: 'react-native-radar.podspec'
66 |
67 | # copy the Cartfile template to its final destination
68 | - name: Copy ios/Cartfile.resolved template
69 | uses: canastro/copy-action@master
70 | with:
71 | source: 'ios/Cartfile.resolved.template'
72 | target: 'ios/Cartfile.resolved'
73 |
74 | # render the Cartfile template with the sdk version
75 | - name: Render radar-sdk-ios release version onto Cartfile template
76 | uses: jayamanikharyono/jinja-action@v0.1
77 | with:
78 | data: version=${{ github.event.client_payload.release }}
79 | path: 'ios/Cartfile.resolved'
80 |
81 | # Update package.json to latest version
82 | - name: Update package.json to latest
83 | run: npm version ${{ github.event.client_payload.release }} --commit-hooks false --git-tag-version false
84 |
85 | # open a pull request with the new sdk version
86 | - name: Create Pull Request
87 | uses: peter-evans/create-pull-request@v3
88 | with:
89 | title: Automated radar-sdk-ios version bump to ${{ github.event.client_payload.release }}
90 | reviewers: radarlabs/eng
91 | token: ${{ secrets.GITHUB_TOKEN }}
92 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | build/
3 | *.pbxuser
4 | !default.pbxuser
5 | *.mode1v3
6 | !default.mode1v3
7 | *.mode2v3
8 | !default.mode2v3
9 | *.perspectivev3
10 | !default.perspectivev3
11 | xcuserdata
12 | *.xccheckout
13 | **/*.xcworkspace
14 | profile
15 | *.moved-aside
16 | DerivedData
17 | .idea/
18 | .gradle/
19 | *.iml
20 | *.iws
21 | out/
22 | local.properties
23 | node_modules/
24 | npm-debug.log
25 | *.framework
26 | android/.project
27 | ios/Carthage/Checkouts
28 | ios/Carthage/Build
29 | junit.xml
30 | dist/
31 |
32 | example2
33 | react-native-radar-*.tgz
34 | example/ios/
35 | example/android/
36 | junit.xml
37 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | example/
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | Copyright 2019 Radar Labs, Inc.
179 |
180 | Licensed under the Apache License, Version 2.0 (the "License");
181 | you may not use this file except in compliance with the License.
182 | You may obtain a copy of the License at
183 |
184 | http://www.apache.org/licenses/LICENSE-2.0
185 |
186 | Unless required by applicable law or agreed to in writing, software
187 | distributed under the License is distributed on an "AS IS" BASIS,
188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189 | See the License for the specific language governing permissions and
190 | limitations under the License.
--------------------------------------------------------------------------------
/MIGRATION.md:
--------------------------------------------------------------------------------
1 | # Migration guides
2 |
3 | ## 3.9.x to 3.10.0
4 |
5 | - Web support is no longer included in default export and is now a separate export `RadarRNWeb`. Call `import Radar, { RadarRNWeb } from 'react-native-radar'`
6 |
7 | ## 3.9.x to 3.9.2
8 | - On `options` for `autocompleteUI`, `threshold` is now `minCharacters`.
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | [](https://www.npmjs.com/package/react-native-radar)
4 |
5 | [Radar](https://radar.com) is the leading geofencing and location tracking platform.
6 |
7 | The Radar SDK abstracts away cross-platform differences between location services, allowing you to add geofencing, location tracking, trip tracking, geocoding, and search to your apps with just a few lines of code.
8 |
9 | ## Documentation
10 |
11 | See the Radar overview documentation [here](https://radar.com/documentation).
12 |
13 | Then, see the Radar React Native module documentation [here](https://radar.com/documentation/sdk/react-native).
14 |
15 | ## Examples
16 |
17 | See an example app in `example/`.
18 |
19 | Setup Radar public key check pre-commit hook with `cp -r hooks .git` to prevent accidental key leak when working with the Example app.
20 |
21 | To run example app with local `react-native-radar` dependency:
22 |
23 | - install node dependencies with `npm ci` and typescript if needed with `npm install -g typescript`.
24 | - build local `react-native-radar` with `npm run build-all`.
25 | - navigate to the example dir with `cd example`.
26 | - install node dependency of example with `npm ci`.
27 | - build native app using expo pre-build and `react-native-plugin` with `npm run install-radar-rebuild`.
28 | - run iOS and android example app with `npx expo run:ios` or `npx expo run:android`.
29 |
30 |
31 | ## Support
32 |
33 | Have questions? We're here to help! Email us at [support@radar.com](mailto:support@radar.com).
34 |
--------------------------------------------------------------------------------
/android/.npmignore:
--------------------------------------------------------------------------------
1 | src/test/
2 | build/
3 | *.iml
4 | local.properties
5 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:7.0.3'
9 | }
10 | }
11 |
12 | apply plugin: 'com.android.library'
13 |
14 | android {
15 | compileSdkVersion 31
16 |
17 | defaultConfig {
18 | minSdkVersion 16
19 | targetSdkVersion 31
20 | versionCode 1
21 | versionName '3.20.3'
22 | consumerProguardFiles 'proguard-rules.pro'
23 | }
24 | lintOptions {
25 | abortOnError false
26 | }
27 | testOptions {
28 | unitTests.returnDefaultValues = true
29 | }
30 | configurations.all {
31 | resolutionStrategy {
32 | force 'androidx.core:core:1.6.0'
33 | force 'androidx.core:core-ktx:1.6.0'
34 | }
35 | }
36 | }
37 |
38 | repositories {
39 | mavenCentral()
40 | google()
41 | maven {
42 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
43 | url "$rootDir/../node_modules/react-native/android"
44 | }
45 | }
46 |
47 | dependencies {
48 | api 'com.facebook.react:react-native:+'
49 | api 'io.radar:sdk:3.21.3'
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/android/build.gradle.template:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:7.0.3'
9 | }
10 | }
11 |
12 | apply plugin: 'com.android.library'
13 |
14 | android {
15 | compileSdkVersion 31
16 |
17 | defaultConfig {
18 | minSdkVersion 16
19 | targetSdkVersion 31
20 | versionCode 1
21 | versionName '{{ version }}'
22 | }
23 | lintOptions {
24 | abortOnError false
25 | }
26 | testOptions {
27 | unitTests.returnDefaultValues = true
28 | }
29 | configurations.all {
30 | resolutionStrategy {
31 | force 'androidx.core:core:1.6.0'
32 | force 'androidx.core:core-ktx:1.6.0'
33 | }
34 | }
35 | }
36 |
37 | repositories {
38 | mavenCentral()
39 | google()
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 | }
45 |
46 | dependencies {
47 | api 'com.facebook.react:react-native:+'
48 | api 'io.radar:sdk:{{ version }}'
49 | }
50 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | android.useAndroidX=true
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jul 19 10:39:56 EDT 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
7 |
--------------------------------------------------------------------------------
/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/android/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn com.huawei.**
2 |
3 | -dontwarn com.google.android.play.integrity.**
4 | -dontwarn com.google.android.play.core.integrity.**
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/src/main/java/io/radar/react/RNRadarPackage.java:
--------------------------------------------------------------------------------
1 | package io.radar.react;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collections;
5 | import java.util.List;
6 |
7 | import com.facebook.react.ReactPackage;
8 | import com.facebook.react.bridge.NativeModule;
9 | import com.facebook.react.bridge.ReactApplicationContext;
10 | import com.facebook.react.uimanager.ViewManager;
11 | import com.facebook.react.bridge.JavaScriptModule;
12 |
13 | public class RNRadarPackage implements ReactPackage {
14 |
15 | @Override
16 | public List createNativeModules(ReactApplicationContext reactContext) {
17 | return Arrays.asList(new RNRadarModule(reactContext));
18 | }
19 |
20 | public List> createJSModules() {
21 | return Collections.emptyList();
22 | }
23 |
24 | @Override
25 | public List createViewManagers(ReactApplicationContext reactContext) {
26 | return Collections.emptyList();
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/android/src/main/java/io/radar/react/RNRadarReceiver.java:
--------------------------------------------------------------------------------
1 | package io.radar.react;
2 |
3 | import android.content.Context;
4 | import android.location.Location;
5 | import android.util.Log;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 |
10 | import com.facebook.react.ReactApplication;
11 | import com.facebook.react.ReactInstanceManager;
12 | import com.facebook.react.ReactNativeHost;
13 | import com.facebook.react.bridge.Arguments;
14 | import com.facebook.react.bridge.ReactContext;
15 | import com.facebook.react.bridge.ReactMethod;
16 | import com.facebook.react.bridge.WritableMap;
17 | import com.facebook.react.modules.core.DeviceEventManagerModule;
18 |
19 | import io.radar.sdk.Radar;
20 | import io.radar.sdk.RadarReceiver;
21 | import io.radar.sdk.model.RadarEvent;
22 | import io.radar.sdk.model.RadarUser;
23 | import java.util.concurrent.atomic.AtomicInteger;
24 |
25 | public class RNRadarReceiver extends RadarReceiver {
26 |
27 | private ReactNativeHost reactNativeHost;
28 | private static final String TAG = "RNRadarReceiver";
29 | protected boolean hasListeners = false;
30 |
31 | private void sendEvent(final String eventName, final Object data) {
32 | final ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
33 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
34 | if (reactContext != null && hasListeners) {
35 | reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
36 | }
37 | }
38 |
39 | @Override
40 | public void onEventsReceived(@NonNull Context context, @NonNull RadarEvent[] events, @Nullable RadarUser user) {
41 | try {
42 | ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
43 | reactNativeHost = reactApplication.getReactNativeHost();
44 |
45 | WritableMap map = Arguments.createMap();
46 | map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
47 | if (user != null) {
48 | map.putMap("user", RNRadarUtils.mapForJson(user.toJson()));
49 | }
50 |
51 | sendEvent("events", map);
52 | } catch (Exception e) {
53 | Log.e(TAG, "Exception", e);
54 | }
55 | }
56 |
57 | @Override
58 | public void onLocationUpdated(@NonNull Context context, @NonNull Location location, @NonNull RadarUser user) {
59 | try {
60 | ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
61 | reactNativeHost = reactApplication.getReactNativeHost();
62 |
63 | WritableMap map = Arguments.createMap();
64 | map.putMap("location", RNRadarUtils.mapForJson(Radar.jsonForLocation(location)));
65 | map.putMap("user", RNRadarUtils.mapForJson(user.toJson()));
66 |
67 | sendEvent("location", map);
68 | } catch (Exception e) {
69 | Log.e(TAG, "Exception", e);
70 | }
71 | }
72 |
73 | @Override
74 | public void onClientLocationUpdated(@NonNull Context context, @NonNull Location location, boolean stopped, @NonNull Radar.RadarLocationSource source) {
75 | try {
76 | ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
77 | reactNativeHost = reactApplication.getReactNativeHost();
78 |
79 | WritableMap map = Arguments.createMap();
80 | map.putMap("location", RNRadarUtils.mapForJson(Radar.jsonForLocation(location)));
81 | map.putBoolean("stopped", stopped);
82 | map.putString("source", source.toString());
83 |
84 | sendEvent("clientLocation", map);
85 | } catch (Exception e) {
86 | Log.e(TAG, "Exception", e);
87 | }
88 | }
89 |
90 | @Override
91 | public void onError(@NonNull Context context, @NonNull Radar.RadarStatus status) {
92 | try {
93 | ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
94 | reactNativeHost = reactApplication.getReactNativeHost();
95 |
96 | sendEvent("error", status.toString());
97 | } catch (Exception e) {
98 | Log.e(TAG, "Exception", e);
99 | }
100 | }
101 |
102 | @Override
103 | public void onLog(@NonNull Context context, @NonNull String message) {
104 | try {
105 | ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
106 | reactNativeHost = reactApplication.getReactNativeHost();
107 |
108 | sendEvent("log", message);
109 | } catch (Exception e) {
110 | Log.e(TAG, "Exception", e);
111 | }
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/android/src/main/java/io/radar/react/RNRadarUtils.java:
--------------------------------------------------------------------------------
1 | package io.radar.react;
2 |
3 | import com.facebook.react.bridge.ReadableArray;
4 | import com.facebook.react.bridge.ReadableMapKeySetIterator;
5 | import java.util.Iterator;
6 | import java.util.Map;
7 | import java.util.HashMap;
8 |
9 | import org.json.JSONArray;
10 | import org.json.JSONException;
11 | import org.json.JSONObject;
12 |
13 | import com.facebook.react.bridge.ReadableMap;
14 | import com.facebook.react.bridge.WritableArray;
15 | import com.facebook.react.bridge.WritableMap;
16 | import com.facebook.react.bridge.WritableNativeArray;
17 | import com.facebook.react.bridge.WritableNativeMap;
18 |
19 | class RNRadarUtils {
20 |
21 | static WritableMap mapForJson(JSONObject obj) throws JSONException {
22 | if (obj == null) {
23 | return null;
24 | }
25 |
26 | WritableMap writableMap = new WritableNativeMap();
27 | Iterator iterator = obj.keys();
28 | while (iterator.hasNext()) {
29 | String key = iterator.next();
30 | Object value = obj.get(key);
31 | if (value instanceof JSONObject) {
32 | writableMap.putMap(key, mapForJson((JSONObject)value));
33 | } else if (value instanceof JSONArray) {
34 | writableMap.putArray(key, arrayForJson((JSONArray)value));
35 | } else if (value instanceof Boolean) {
36 | writableMap.putBoolean(key, (Boolean)value);
37 | } else if (value instanceof Integer) {
38 | writableMap.putInt(key, (Integer)value);
39 | } else if (value instanceof Double) {
40 | writableMap.putDouble(key, (Double)value);
41 | } else if (value instanceof Float) {
42 | String valueStr = value.toString();
43 | Double valueDouble = Double.valueOf(valueStr);
44 | writableMap.putDouble(key, valueDouble);
45 | } else if (value instanceof String) {
46 | writableMap.putString(key, (String)value);
47 | }
48 | }
49 | return writableMap;
50 | }
51 |
52 | static WritableArray arrayForJson(JSONArray arr) throws JSONException {
53 | if (arr == null) {
54 | return null;
55 | }
56 |
57 | WritableArray writableArr = new WritableNativeArray();
58 | for (int i = 0; i < arr.length(); i++) {
59 | Object value = arr.get(i);
60 | if (value instanceof JSONObject) {
61 | writableArr.pushMap(mapForJson((JSONObject)value));
62 | } else if (value instanceof JSONArray) {
63 | writableArr.pushArray(arrayForJson((JSONArray)value));
64 | } else if (value instanceof Boolean) {
65 | writableArr.pushBoolean((Boolean)value);
66 | } else if (value instanceof Integer) {
67 | writableArr.pushInt((Integer)value);
68 | } else if (value instanceof Double) {
69 | writableArr.pushDouble((Double)value);
70 | } else if (value instanceof String) {
71 | writableArr.pushString((String)value);
72 | }
73 | }
74 | return writableArr;
75 | }
76 |
77 | static JSONObject jsonForMap(ReadableMap readableMap) throws JSONException {
78 | if (readableMap == null) {
79 | return null;
80 | }
81 |
82 | JSONObject obj = new JSONObject();
83 | ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
84 | while (iterator.hasNextKey()) {
85 | String key = iterator.nextKey();
86 | switch (readableMap.getType(key)) {
87 | case Null:
88 | obj.put(key, JSONObject.NULL);
89 | break;
90 | case Boolean:
91 | obj.put(key, readableMap.getBoolean(key));
92 | break;
93 | case Number:
94 | obj.put(key, readableMap.getDouble(key));
95 | break;
96 | case String:
97 | obj.put(key, readableMap.getString(key));
98 | break;
99 | case Map:
100 | obj.put(key, jsonForMap(readableMap.getMap(key)));
101 | break;
102 | case Array:
103 | obj.put(key, jsonForArray(readableMap.getArray(key)));
104 | break;
105 | }
106 | }
107 | return obj;
108 | }
109 |
110 | static JSONArray jsonForArray(ReadableArray readableArr) throws JSONException {
111 | if (readableArr == null) {
112 | return null;
113 | }
114 |
115 | JSONArray arr = new JSONArray();
116 | for (int i = 0; i < readableArr.size(); i++) {
117 | switch (readableArr.getType(i)) {
118 | case Null:
119 | break;
120 | case Boolean:
121 | arr.put(readableArr.getBoolean(i));
122 | break;
123 | case Number:
124 | arr.put(readableArr.getDouble(i));
125 | break;
126 | case String:
127 | arr.put(readableArr.getString(i));
128 | break;
129 | case Map:
130 | arr.put(jsonForMap(readableArr.getMap(i)));
131 | break;
132 | case Array:
133 | arr.put(jsonForArray(readableArr.getArray(i)));
134 | break;
135 | }
136 | }
137 | return arr;
138 | }
139 |
140 | static String[] stringArrayForArray(ReadableArray readableArr) {
141 | String[] arr;
142 | if (readableArr != null) {
143 | int size = readableArr.size();
144 | arr = new String[size];
145 | for (int i = 0; i < size; i++) {
146 | arr[i] = readableArr.getString(i);
147 | }
148 | } else {
149 | arr = new String[0];
150 | }
151 | return arr;
152 | }
153 | static Map stringStringMap(ReadableMap readableMap) {
154 | if (readableMap == null) {
155 | return null;
156 | }
157 |
158 | Map stringMap = new HashMap();
159 | ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
160 | while (iterator.hasNextKey()) {
161 | String key = iterator.nextKey();
162 | stringMap.put(key, readableMap.getString(key));
163 | }
164 | return stringMap;
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/android/src/main/java/io/radar/react/RNRadarVerifiedReceiver.java:
--------------------------------------------------------------------------------
1 | package io.radar.react;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import androidx.annotation.NonNull;
7 |
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.ReactMethod;
14 | import com.facebook.react.bridge.WritableMap;
15 | import com.facebook.react.modules.core.DeviceEventManagerModule;
16 |
17 | import io.radar.sdk.Radar;
18 | import io.radar.sdk.RadarVerifiedReceiver;
19 | import io.radar.sdk.model.RadarVerifiedLocationToken;
20 |
21 | public class RNRadarVerifiedReceiver extends RadarVerifiedReceiver {
22 |
23 | private ReactNativeHost reactNativeHost;
24 | private static final String TAG = "RNRadarVerifiedReceiver";
25 | protected boolean hasListeners = false;
26 |
27 | private void sendEvent(final String eventName, final Object data) {
28 | final ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
29 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
30 | if (reactContext != null && hasListeners) {
31 | reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
32 | }
33 | }
34 |
35 | @Override
36 | public void onTokenUpdated(@NonNull Context context, @NonNull RadarVerifiedLocationToken token) {
37 | try {
38 | ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
39 | reactNativeHost = reactApplication.getReactNativeHost();
40 |
41 | sendEvent("token", RNRadarUtils.mapForJson(token.toJson()));
42 | } catch (Exception e) {
43 | Log.e(TAG, "Exception", e);
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/app.plugin.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./plugin/build');
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = function (api) {
2 | api.cache(true);
3 | const presets = [
4 | '@babel/preset-env',
5 | '@babel/preset-react',
6 | 'module:metro-react-native-babel-preset',
7 | ];
8 | return {
9 | presets,
10 | };
11 | };
12 |
--------------------------------------------------------------------------------
/copyAssets.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | source_dir="./src/ui"
4 | target_dir="./dist/ui"
5 |
6 | for file in "$source_dir"/*.png
7 | do
8 | cp "$file" "$target_dir"
9 | done
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2 |
3 | # dependencies
4 | node_modules/
5 |
6 | # Expo
7 | .expo/
8 | dist/
9 | web-build/
10 |
11 | # Native
12 | *.orig.*
13 | *.jks
14 | *.p8
15 | *.p12
16 | *.key
17 | *.mobileprovision
18 |
19 | # Metro
20 | .metro-health-check*
21 |
22 | # debug
23 | npm-debug.*
24 | yarn-debug.*
25 | yarn-error.*
26 |
27 | # macOS
28 | .DS_Store
29 | *.pem
30 |
31 | # local env files
32 | .env*.local
33 |
34 | # typescript
35 | *.tsbuildinfo
36 |
--------------------------------------------------------------------------------
/example/App.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from "react";
2 | import { StyleSheet, Text, View, ScrollView, Platform } from "react-native";
3 | import Radar, {
4 | Map,
5 | Autocomplete,
6 | RadarClientLocationUpdate,
7 | RadarLocationUpdate,
8 | RadarEventUpdate,
9 | } from "react-native-radar";
10 | import MapLibreGL from "@maplibre/maplibre-react-native";
11 | import ExampleButton from "./components/exampleButton";
12 |
13 | // The current version of MapLibre does not support the new react native architecture
14 | MapLibreGL.setAccessToken(null);
15 |
16 | const stringify = (obj: any) => JSON.stringify(obj, null, 2);
17 |
18 | Radar.on("events", (result: RadarEventUpdate) => {
19 | console.log("events:", stringify(result));
20 | });
21 |
22 | Radar.on("location", (result: RadarLocationUpdate) => {
23 | console.log("location:", stringify(result));
24 | });
25 |
26 | Radar.on("clientLocation", (result: RadarClientLocationUpdate) => {
27 | console.log("clientLocation:", stringify(result));
28 | });
29 |
30 | Radar.on("error", (err: any) => {
31 | console.log("error:", stringify(err));
32 | });
33 |
34 | Radar.on("log", (result: string) => {
35 | console.log("log:", stringify(result));
36 | });
37 |
38 | export default function App() {
39 | // add in your test code here!
40 | const [displayText, setDisplayText] = useState("");
41 |
42 | const handlePopulateText = (displayText: string) => {
43 | setDisplayText(displayText);
44 | };
45 | Radar.initialize(
46 | "prj_test_pk_0000000000000000000000000000000000000000",
47 | true
48 | );
49 |
50 | useEffect(() => {
51 | Radar.setLogLevel("debug");
52 |
53 | Radar.setUserId("foo");
54 |
55 | Radar.setDescription("description");
56 |
57 | Radar.setMetadata({
58 | foo: "bar",
59 | baz: true,
60 | qux: 1,
61 | });
62 | }, []);
63 |
64 | return (
65 |
66 | {/* The current version of MapLibre does not support the new react native architecture */}
67 | {Platform.OS !== "web" && (
68 | <>
69 |
70 |
71 |
72 |
73 |
81 |
82 | >
83 | )}
84 |
90 |
91 | {displayText}
92 |
93 |
94 | {
97 | Radar.getUserId()
98 | .then((result) => {
99 | handlePopulateText("getUserId:" + result);
100 | })
101 | .catch((err) => {
102 | handlePopulateText("getUserId:" + err);
103 | });
104 | }}
105 | />
106 | {
109 | Radar.getDescription()
110 | .then((result) => {
111 | handlePopulateText("getDescription:" + result);
112 | })
113 | .catch((err) => {
114 | handlePopulateText("getDescription:" + err);
115 | });
116 | }}
117 | />
118 | {
121 | Radar.getMetadata()
122 | .then((result) => {
123 | handlePopulateText("getMetadata:" + stringify(result));
124 | })
125 | .catch((err) => {
126 | handlePopulateText("getMetadata:" + err);
127 | });
128 | }}
129 | />
130 | {
133 | Radar.requestPermissions(false)
134 | .then((result) => {
135 | handlePopulateText("requestPermissions:" + result);
136 | })
137 | .catch((err) => {
138 | handlePopulateText("requestPermissions:" + err);
139 | });
140 | }}
141 | />
142 |
143 | {
146 | Radar.requestPermissions(true)
147 | .then((result) => {
148 | handlePopulateText("requestPermissions:" + result);
149 | })
150 | .catch((err) => {
151 | handlePopulateText("requestPermissions:" + err);
152 | });
153 | }}
154 | />
155 | {
158 | Radar.getPermissionsStatus()
159 | .then((result) => {
160 | handlePopulateText("getPermissionsStatus:" + result);
161 | })
162 | .catch((err) => {
163 | handlePopulateText("getPermissionsStatus:" + err);
164 | });
165 | }}
166 | />
167 | {
170 | Radar.getLocation()
171 | .then((result) => {
172 | handlePopulateText("getLocation:" + stringify(result));
173 | })
174 | .catch((err) => {
175 | handlePopulateText("getLocation:" + err);
176 | });
177 | }}
178 | />
179 | {
182 | Radar.trackOnce()
183 | .then((result) => {
184 | handlePopulateText("trackOnce:" + stringify(result));
185 | })
186 | .catch((err) => {
187 | handlePopulateText("trackOnce:" + err);
188 | });
189 | }}
190 | />
191 |
192 | {
195 | Radar.trackOnce({
196 | location: {
197 | latitude: 39.2904,
198 | longitude: -76.6122,
199 | accuracy: 60,
200 | },
201 | })
202 | .then((result) => {
203 | handlePopulateText(
204 | "trackOnce manual with location accuracy::" +
205 | stringify(result)
206 | );
207 | })
208 | .catch((err) => {
209 | handlePopulateText(
210 | "trackOnce manual with location accuracy::" + err
211 | );
212 | });
213 | }}
214 | />
215 | {
218 | Radar.trackOnce({
219 | desiredAccuracy: "medium",
220 | beacons: true,
221 | })
222 | .then((result) => {
223 | handlePopulateText(
224 | "trackOnce manual with beacons:" + stringify(result)
225 | );
226 | })
227 | .catch((err) => {
228 | handlePopulateText("trackOnce manual with beacons:" + err);
229 | });
230 | }}
231 | />
232 | {
235 | Radar.trackOnce({
236 | latitude: 39.2904,
237 | longitude: -76.6122,
238 | accuracy: 65,
239 | })
240 | .then((result) => {
241 | handlePopulateText(
242 | "trackOnce for back compatible:" + stringify(result)
243 | );
244 | })
245 | .catch((err) => {
246 | handlePopulateText("trackOnce for back compatible:" + err);
247 | });
248 | }}
249 | />
250 |
251 | {
254 | Radar.searchPlaces({
255 | near: {
256 | latitude: 40.783826,
257 | longitude: -73.975363,
258 | },
259 | radius: 1000,
260 | chains: ["starbucks"],
261 | chainMetadata: {
262 | customFlag: "true",
263 | },
264 | countryCodes: ["CA", "US"],
265 | limit: 10,
266 | })
267 | .then((result) => {
268 | handlePopulateText("searchPlaces:" + stringify(result));
269 | })
270 | .catch((err) => {
271 | handlePopulateText("searchPlaces:" + err);
272 | });
273 | }}
274 | />
275 |
276 | {
279 | Radar.searchGeofences({
280 | radius: 1000,
281 | tags: ["venue"],
282 | limit: 10,
283 | includeGeometry: true,
284 | })
285 | .then((result) => {
286 | handlePopulateText("searchGeofences:" + stringify(result));
287 | })
288 | .catch((err) => {
289 | handlePopulateText("searchGeofences:" + err);
290 | });
291 | }}
292 | />
293 |
294 | {
297 | Radar.autocomplete({
298 | query: "brooklyn roasting",
299 | limit: 10,
300 | })
301 | .then((result) => {
302 | handlePopulateText("autocomplete:" + stringify(result));
303 | })
304 | .catch((err) => {
305 | handlePopulateText("autocomplete:" + err);
306 | });
307 | }}
308 | />
309 |
310 | {
313 | Radar.geocode({ address: "20 jay st brooklyn" })
314 | .then((result) => {
315 | handlePopulateText("geocode:" + stringify(result));
316 | })
317 | .catch((err) => {
318 | handlePopulateText("geocode:" + err);
319 | });
320 | }}
321 | />
322 |
323 | {
326 | Radar.reverseGeocode({
327 | location: {
328 | latitude: 40.783826,
329 | longitude: -73.975363,
330 | },
331 | })
332 | .then((result) => {
333 | handlePopulateText("reverseGeocode:" + stringify(result));
334 | })
335 | .catch((err) => {
336 | handlePopulateText("reverseGeocode:" + err);
337 | });
338 | }}
339 | />
340 |
341 | {
344 | Radar.ipGeocode()
345 | .then((result) => {
346 | handlePopulateText("ipGeocode:" + stringify(result));
347 | })
348 | .catch((err) => {
349 | handlePopulateText("ipGeocode:" + err);
350 | });
351 | }}
352 | />
353 |
354 | {
357 | Radar.validateAddress({
358 | latitude: 0,
359 | longitude: 0,
360 | city: "New York",
361 | stateCode: "NY",
362 | postalCode: "10003",
363 | countryCode: "US",
364 | street: "Broadway",
365 | number: "841",
366 | })
367 | .then((result) => {
368 | handlePopulateText("validateAddress:" + stringify(result));
369 | })
370 | .catch((err) => {
371 | handlePopulateText("validateAddress:" + err);
372 | });
373 | }}
374 | />
375 |
376 | {
379 | Radar.getDistance({
380 | origin: {
381 | latitude: 40.78382,
382 | longitude: -73.97536,
383 | },
384 | destination: {
385 | latitude: 40.7039,
386 | longitude: -73.9867,
387 | },
388 | modes: ["foot", "car"],
389 | units: "imperial",
390 | })
391 | .then((result) => {
392 | handlePopulateText("getDistance:" + stringify(result));
393 | })
394 | .catch((err) => {
395 | handlePopulateText("getDistance:" + err);
396 | });
397 | }}
398 | />
399 |
400 | {
403 | Radar.getMatrix({
404 | origins: [
405 | {
406 | latitude: 40.78382,
407 | longitude: -73.97536,
408 | },
409 | {
410 | latitude: 40.7039,
411 | longitude: -73.9867,
412 | },
413 | ],
414 | destinations: [
415 | {
416 | latitude: 40.64189,
417 | longitude: -73.78779,
418 | },
419 | {
420 | latitude: 35.99801,
421 | longitude: -78.94294,
422 | },
423 | ],
424 | mode: "car",
425 | units: "imperial",
426 | })
427 | .then((result) => {
428 | handlePopulateText("getMatrix:" + stringify(result));
429 | })
430 | .catch((err) => {
431 | handlePopulateText("getMatrix:" + err);
432 | });
433 | }}
434 | />
435 |
436 | {
439 | Radar.startTrip({
440 | tripOptions: {
441 | externalId: "300",
442 | destinationGeofenceTag: "store",
443 | destinationGeofenceExternalId: "123",
444 | mode: "car",
445 | scheduledArrivalAt: new Date(
446 | "2023-10-10T12:20:30Z"
447 | ).getTime(),
448 | metadata: {
449 | "test-trip-meta": "test-trip-data",
450 | },
451 | },
452 | })
453 | .then((result) => {
454 | handlePopulateText("startTrip:" + stringify(result));
455 | })
456 | .catch((err) => {
457 | handlePopulateText("startTrip:" + err);
458 | });
459 | }}
460 | />
461 |
462 | {
465 | Radar.startTrip({
466 | tripOptions: {
467 | externalId: "302",
468 | destinationGeofenceTag: "store",
469 | destinationGeofenceExternalId: "123",
470 | mode: "car",
471 | scheduledArrivalAt: new Date(
472 | "2023-10-10T12:20:30Z"
473 | ).getTime(),
474 | },
475 | trackingOptions: {
476 | desiredStoppedUpdateInterval: 30,
477 | fastestStoppedUpdateInterval: 30,
478 | desiredMovingUpdateInterval: 30,
479 | fastestMovingUpdateInterval: 30,
480 | desiredSyncInterval: 20,
481 | desiredAccuracy: "high",
482 | stopDuration: 0,
483 | stopDistance: 0,
484 | replay: "none",
485 | sync: "all",
486 | showBlueBar: true,
487 | useStoppedGeofence: false,
488 | stoppedGeofenceRadius: 0,
489 | useMovingGeofence: false,
490 | movingGeofenceRadius: 0,
491 | syncGeofences: false,
492 | syncGeofencesLimit: 0,
493 | beacons: false,
494 | foregroundServiceEnabled: false,
495 | },
496 | })
497 | .then((result) => {
498 | handlePopulateText("startTrip:" + stringify(result));
499 | })
500 | .catch((err) => {
501 | handlePopulateText("startTrip:" + err);
502 | });
503 | }}
504 | />
505 |
506 | {
509 | Radar.completeTrip()
510 | .then((result) => {
511 | handlePopulateText("completeTrip:" + stringify(result));
512 | })
513 | .catch((err) => {
514 | handlePopulateText("completeTrip:" + err);
515 | });
516 | }}
517 | />
518 |
519 | {
522 | Radar.logConversion({
523 | name: "in_app_purchase",
524 | revenue: 150,
525 | metadata: {
526 | sku: "123456789",
527 | },
528 | })
529 | .then((result) => {
530 | handlePopulateText("logConversion:" + stringify(result));
531 | })
532 | .catch((err) => {
533 | handlePopulateText("logConversion:" + err);
534 | });
535 | }}
536 | />
537 |
538 | {
541 | Radar.logConversion({
542 | name: "in_app_purchase",
543 | metadata: {
544 | sku: "123456789",
545 | },
546 | })
547 | .then((result) => {
548 | handlePopulateText("logConversion:" + stringify(result));
549 | })
550 | .catch((err) => {
551 | handlePopulateText("logConversion:" + err);
552 | });
553 | }}
554 | />
555 |
556 | {
559 | Radar.trackVerified()
560 | .then((result) => {
561 | handlePopulateText("trackVerified:" + stringify(result));
562 | })
563 | .catch((err) => {
564 | handlePopulateText("trackVerified:" + err);
565 | });
566 | }}
567 | />
568 |
569 | {
572 | Radar.startTrackingVerified();
573 | }}
574 | />
575 |
576 | {
579 | Radar.isTrackingVerified()
580 | .then((result) => {
581 | handlePopulateText("isTrackingVerified:" + stringify(result));
582 | })
583 | .catch((err) => {
584 | handlePopulateText("isTrackingVerified:" + err);
585 | });
586 | }}
587 | />
588 |
589 | {
592 | Radar.stopTrackingVerified();
593 | }}
594 | />
595 |
596 | {
599 | Radar.setProduct("test");
600 | }}
601 | />
602 |
603 | {
606 | Radar.getVerifiedLocationToken()
607 | .then((result) => {
608 | handlePopulateText(
609 | "getVerifiedLocationToken:" + stringify(result)
610 | );
611 | })
612 | .catch((err) => {
613 | handlePopulateText("getVerifiedLocationToken:" + err);
614 | });
615 | }}
616 | />
617 |
618 | {
621 | Radar.nativeSdkVersion().then((nativeVersion) => {
622 | handlePopulateText(
623 | `sdk: ${Radar.rnSdkVersion()}, native: ${nativeVersion}`
624 | );
625 | });
626 | }}
627 | />
628 |
629 |
630 |
631 | );
632 | }
633 |
634 | const styles = StyleSheet.create({
635 | container: {
636 | flex: 1,
637 | backgroundColor: "#fff",
638 | alignItems: "center",
639 | justifyContent: "center",
640 | },
641 | displayText: {
642 | flex: 1,
643 | },
644 | });
645 |
--------------------------------------------------------------------------------
/example/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "expo": {
3 | "name": "Example",
4 | "slug": "Example",
5 | "version": "1.0.0",
6 | "orientation": "portrait",
7 | "icon": "./assets/icon.png",
8 | "userInterfaceStyle": "light",
9 | "splash": {
10 | "image": "./assets/splash.png",
11 | "resizeMode": "contain",
12 | "backgroundColor": "#ffffff"
13 | },
14 | "assetBundlePatterns": [
15 | "**/*"
16 | ],
17 | "owner": "radarlabs",
18 | "ios": {
19 | "supportsTablet": true,
20 | "bundleIdentifier": "com.radar.reactnative.example"
21 | },
22 | "android": {
23 | "adaptiveIcon": {
24 | "foregroundImage": "./assets/adaptive-icon.png",
25 | "backgroundColor": "#ffffff"
26 | },
27 | "package": "com.radar.reactnative.example",
28 | "permissions": [
29 | "android.permission.ACCESS_BACKGROUND_LOCATION",
30 | "android.permission.FOREGROUND_SERVICE",
31 | "android.permission.FOREGROUND_SERVICE_LOCATION",
32 | "android.permission.ACTIVITY_RECOGNITION",
33 | "android.permission.ACCESS_FINE_LOCATION"
34 | ]
35 | },
36 | "web": {
37 | "favicon": "./assets/favicon.png"
38 | },
39 | "plugins": [
40 | [
41 | "react-native-radar",
42 | {
43 | "iosFraud": true,
44 | "iosNSLocationAlwaysAndWhenInUseUsageDescription": "test value",
45 | "iosBackgroundMode": true,
46 | "androidFraud": false,
47 | "androidBackgroundPermission": true,
48 | "addRadarSDKMotion": true,
49 | "androidActivityRecognition": true,
50 | "androidForegroundService": true
51 | }
52 | ],
53 | [
54 | "@maplibre/maplibre-react-native"
55 | ],
56 | [
57 | "expo-build-properties",
58 | {
59 | "ios": {
60 | "newArchEnabled": false
61 | },
62 | "android": {
63 | "newArchEnabled": false,
64 | "enableProguardInReleaseBuilds": true,
65 | "enableShrinkResourcesInReleaseBuilds": true
66 | }
67 | }
68 | ]
69 | ],
70 | "extra": {
71 | "eas": {
72 | "projectId": "caf6acc9-b3c5-4d95-af29-fd017a05abb8"
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/example/assets/adaptive-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/example/assets/adaptive-icon.png
--------------------------------------------------------------------------------
/example/assets/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/example/assets/favicon.png
--------------------------------------------------------------------------------
/example/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/example/assets/icon.png
--------------------------------------------------------------------------------
/example/assets/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/example/assets/splash.png
--------------------------------------------------------------------------------
/example/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = function(api) {
2 | api.cache(true);
3 | return {
4 | presets: ['babel-preset-expo'],
5 | };
6 | };
7 |
--------------------------------------------------------------------------------
/example/components/exampleButton.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Button } from "react-native";
3 |
4 | const ExampleButton = ({ title, onPress }) => {
5 | return ;
6 | };
7 |
8 | export default ExampleButton;
--------------------------------------------------------------------------------
/example/eas.json:
--------------------------------------------------------------------------------
1 | {
2 | "cli": {
3 | "version": ">= 7.2.0"
4 | },
5 | "build": {
6 | "development": {
7 | "developmentClient": true,
8 | "distribution": "internal"
9 | },
10 | "preview": {
11 | "distribution": "internal"
12 | },
13 | "production": {}
14 | },
15 | "submit": {
16 | "production": {}
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | import { registerRootComponent } from 'expo';
2 |
3 | import App from './App';
4 |
5 | // registerRootComponent calls AppRegistry.registerComponent('main', () => App);
6 | // It also ensures that whether you load the app in Expo Go or in a native build,
7 | // the environment is set up appropriately
8 | registerRootComponent(App);
9 |
--------------------------------------------------------------------------------
/example/metro.config.js:
--------------------------------------------------------------------------------
1 | // Learn more https://docs.expo.io/guides/customizing-metro
2 | const { getDefaultConfig } = require('expo/metro-config');
3 |
4 | /** @type {import('expo/metro-config').MetroConfig} */
5 | const config = getDefaultConfig(__dirname);
6 |
7 | module.exports = config;
8 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example",
3 | "version": "1.0.0",
4 | "main": "node_modules/expo/AppEntry.js",
5 | "scripts": {
6 | "start": "expo start",
7 | "android": "expo run:android",
8 | "ios": "expo run:ios",
9 | "web": "expo start --web",
10 | "install-radar": "npm un react-native-radar ; npm i --install-links ../",
11 | "install-radar-rebuild-dirty": "npm run install-radar && expo prebuild",
12 | "install-radar-rebuild": "npm run install-radar && expo prebuild --clean"
13 | },
14 | "dependencies": {
15 | "@expo/metro-runtime": "~4.0.1",
16 | "@maplibre/maplibre-react-native": "^10.0.0-alpha.5",
17 | "expo": "^52.0.44",
18 | "expo-build-properties": "~0.13.2",
19 | "expo-status-bar": "~2.0.1",
20 | "react": "18.3.1",
21 | "react-dom": "18.3.1",
22 | "react-native": "0.76.9",
23 | "react-native-radar": "file:..",
24 | "react-native-web": "~0.19.10"
25 | },
26 | "devDependencies": {
27 | "@babel/core": "^7.20.0",
28 | "@types/react": "~18.3.12",
29 | "typescript": "~5.3.3"
30 | },
31 | "private": true,
32 | "browserslist": {
33 | "production": [
34 | ">0.2%",
35 | "not dead",
36 | "not op_mini all"
37 | ],
38 | "development": [
39 | "last 1 chrome version",
40 | "last 1 firefox version",
41 | "last 1 safari version"
42 | ]
43 | },
44 | "proxy": "http://localhost:8081"
45 | }
46 |
--------------------------------------------------------------------------------
/example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "expo/tsconfig.base",
3 | "compilerOptions": {
4 | "strict": true
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/hooks/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | key_matches=$(grep -Eo "prj_...._pk_.{40}" example/App.*)
4 | zerokey=".*:?prj_...._pk_0{40}"
5 |
6 | for key in $key_matches;
7 | do
8 | if [[ ! $key =~ $zerokey ]]; then
9 | echo "Aborted\nDetected Radar API key: $key"
10 | exit 1
11 | fi
12 | done
13 |
--------------------------------------------------------------------------------
/ios/.npmignore:
--------------------------------------------------------------------------------
1 | Carthage/
2 |
--------------------------------------------------------------------------------
/ios/Cartfile.private:
--------------------------------------------------------------------------------
1 | github "radarlabs/radar-sdk-ios"
2 |
--------------------------------------------------------------------------------
/ios/Cartfile.resolved:
--------------------------------------------------------------------------------
1 | github "radarlabs/radar-sdk-ios" "3.21.2"
2 |
--------------------------------------------------------------------------------
/ios/Cartfile.resolved.template:
--------------------------------------------------------------------------------
1 | github "radarlabs/radar-sdk-ios" "{{ version }}"
2 |
--------------------------------------------------------------------------------
/ios/RNRadar.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import
4 | #import
5 |
6 | @interface RNRadar : RCTEventEmitter
7 |
8 | @end
9 |
--------------------------------------------------------------------------------
/ios/RNRadar.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 46256DBD21E01B6F00E10B7F /* RNRadarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 46256DBC21E01B6F00E10B7F /* RNRadarTests.m */; };
11 | 466EF48D21DFC28700ED0E09 /* RNRadarUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 466EF48C21DFC28700ED0E09 /* RNRadarUtilsTests.m */; };
12 | 46B8EB3421DFE009009DFE97 /* libRNRadar.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 134814201AA4EA6300B7C361 /* libRNRadar.a */; };
13 | B3E7B58A1CC2AC0600A0062D /* RNRadar.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNRadar.m */; };
14 | /* End PBXBuildFile section */
15 |
16 | /* Begin PBXContainerItemProxy section */
17 | 466EF49021DFC28700ED0E09 /* PBXContainerItemProxy */ = {
18 | isa = PBXContainerItemProxy;
19 | containerPortal = 58B511D31A9E6C8500147676 /* Project object */;
20 | proxyType = 1;
21 | remoteGlobalIDString = 58B511DA1A9E6C8500147676;
22 | remoteInfo = RNRadar;
23 | };
24 | /* End PBXContainerItemProxy section */
25 |
26 | /* Begin PBXCopyFilesBuildPhase section */
27 | 466F032221DFE54C001EBC47 /* CopyFiles */ = {
28 | isa = PBXCopyFilesBuildPhase;
29 | buildActionMask = 2147483647;
30 | dstPath = "";
31 | dstSubfolderSpec = 16;
32 | files = (
33 | );
34 | runOnlyForDeploymentPostprocessing = 0;
35 | };
36 | 58B511D91A9E6C8500147676 /* CopyFiles */ = {
37 | isa = PBXCopyFilesBuildPhase;
38 | buildActionMask = 2147483647;
39 | dstPath = "include/$(PRODUCT_NAME)";
40 | dstSubfolderSpec = 16;
41 | files = (
42 | );
43 | runOnlyForDeploymentPostprocessing = 0;
44 | };
45 | /* End PBXCopyFilesBuildPhase section */
46 |
47 | /* Begin PBXFileReference section */
48 | 134814201AA4EA6300B7C361 /* libRNRadar.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNRadar.a; sourceTree = BUILT_PRODUCTS_DIR; };
49 | 46256DBC21E01B6F00E10B7F /* RNRadarTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNRadarTests.m; sourceTree = ""; };
50 | 466EF48C21DFC28700ED0E09 /* RNRadarUtilsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNRadarUtilsTests.m; sourceTree = ""; };
51 | 466EF48E21DFC28700ED0E09 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
52 | B3E7B5881CC2AC0600A0062D /* RNRadar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNRadar.h; sourceTree = ""; };
53 | B3E7B5891CC2AC0600A0062D /* RNRadar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNRadar.m; sourceTree = ""; };
54 | DDD9848B243135300042F1A1 /* RNRadarTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RNRadarTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
55 | /* End PBXFileReference section */
56 |
57 | /* Begin PBXFrameworksBuildPhase section */
58 | 466EF48721DFC28700ED0E09 /* Frameworks */ = {
59 | isa = PBXFrameworksBuildPhase;
60 | buildActionMask = 2147483647;
61 | files = (
62 | 46B8EB3421DFE009009DFE97 /* libRNRadar.a in Frameworks */,
63 | );
64 | runOnlyForDeploymentPostprocessing = 0;
65 | };
66 | 58B511D81A9E6C8500147676 /* Frameworks */ = {
67 | isa = PBXFrameworksBuildPhase;
68 | buildActionMask = 2147483647;
69 | files = (
70 | );
71 | runOnlyForDeploymentPostprocessing = 0;
72 | };
73 | /* End PBXFrameworksBuildPhase section */
74 |
75 | /* Begin PBXGroup section */
76 | 134814211AA4EA7D00B7C361 /* Products */ = {
77 | isa = PBXGroup;
78 | children = (
79 | 134814201AA4EA6300B7C361 /* libRNRadar.a */,
80 | );
81 | name = Products;
82 | sourceTree = "";
83 | };
84 | 466EF48B21DFC28700ED0E09 /* RNRadarTests */ = {
85 | isa = PBXGroup;
86 | children = (
87 | 46256DBC21E01B6F00E10B7F /* RNRadarTests.m */,
88 | 466EF48C21DFC28700ED0E09 /* RNRadarUtilsTests.m */,
89 | 466EF48E21DFC28700ED0E09 /* Info.plist */,
90 | );
91 | path = RNRadarTests;
92 | sourceTree = "";
93 | };
94 | 466EF49521DFC34600ED0E09 /* Frameworks */ = {
95 | isa = PBXGroup;
96 | children = (
97 | );
98 | name = Frameworks;
99 | sourceTree = "";
100 | };
101 | 58B511D21A9E6C8500147676 = {
102 | isa = PBXGroup;
103 | children = (
104 | B3E7B5881CC2AC0600A0062D /* RNRadar.h */,
105 | B3E7B5891CC2AC0600A0062D /* RNRadar.m */,
106 | 466EF48B21DFC28700ED0E09 /* RNRadarTests */,
107 | 134814211AA4EA7D00B7C361 /* Products */,
108 | 466EF49521DFC34600ED0E09 /* Frameworks */,
109 | DDD9848B243135300042F1A1 /* RNRadarTests.xctest */,
110 | );
111 | sourceTree = "";
112 | };
113 | /* End PBXGroup section */
114 |
115 | /* Begin PBXNativeTarget section */
116 | 466EF48921DFC28700ED0E09 /* RNRadarTests */ = {
117 | isa = PBXNativeTarget;
118 | buildConfigurationList = 466EF49421DFC28700ED0E09 /* Build configuration list for PBXNativeTarget "RNRadarTests" */;
119 | buildPhases = (
120 | 466EF48621DFC28700ED0E09 /* Sources */,
121 | 466EF48721DFC28700ED0E09 /* Frameworks */,
122 | 466EF48821DFC28700ED0E09 /* Resources */,
123 | 466F032221DFE54C001EBC47 /* CopyFiles */,
124 | );
125 | buildRules = (
126 | );
127 | dependencies = (
128 | 466EF49121DFC28700ED0E09 /* PBXTargetDependency */,
129 | );
130 | name = RNRadarTests;
131 | productName = RNRadarTests;
132 | productReference = DDD9848B243135300042F1A1 /* RNRadarTests.xctest */;
133 | productType = "com.apple.product-type.bundle.unit-test";
134 | };
135 | 58B511DA1A9E6C8500147676 /* RNRadar */ = {
136 | isa = PBXNativeTarget;
137 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNRadar" */;
138 | buildPhases = (
139 | 58B511D71A9E6C8500147676 /* Sources */,
140 | 58B511D81A9E6C8500147676 /* Frameworks */,
141 | 58B511D91A9E6C8500147676 /* CopyFiles */,
142 | );
143 | buildRules = (
144 | );
145 | dependencies = (
146 | );
147 | name = RNRadar;
148 | productName = RCTDataManager;
149 | productReference = 134814201AA4EA6300B7C361 /* libRNRadar.a */;
150 | productType = "com.apple.product-type.library.static";
151 | };
152 | /* End PBXNativeTarget section */
153 |
154 | /* Begin PBXProject section */
155 | 58B511D31A9E6C8500147676 /* Project object */ = {
156 | isa = PBXProject;
157 | attributes = {
158 | LastUpgradeCheck = 1130;
159 | ORGANIZATIONNAME = Facebook;
160 | TargetAttributes = {
161 | 466EF48921DFC28700ED0E09 = {
162 | CreatedOnToolsVersion = 10.1;
163 | ProvisioningStyle = Automatic;
164 | };
165 | 58B511DA1A9E6C8500147676 = {
166 | CreatedOnToolsVersion = 6.1.1;
167 | };
168 | };
169 | };
170 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNRadar" */;
171 | compatibilityVersion = "Xcode 3.2";
172 | developmentRegion = en;
173 | hasScannedForEncodings = 0;
174 | knownRegions = (
175 | en,
176 | Base,
177 | );
178 | mainGroup = 58B511D21A9E6C8500147676;
179 | productRefGroup = 58B511D21A9E6C8500147676;
180 | projectDirPath = "";
181 | projectRoot = "";
182 | targets = (
183 | 58B511DA1A9E6C8500147676 /* RNRadar */,
184 | 466EF48921DFC28700ED0E09 /* RNRadarTests */,
185 | );
186 | };
187 | /* End PBXProject section */
188 |
189 | /* Begin PBXResourcesBuildPhase section */
190 | 466EF48821DFC28700ED0E09 /* Resources */ = {
191 | isa = PBXResourcesBuildPhase;
192 | buildActionMask = 2147483647;
193 | files = (
194 | );
195 | runOnlyForDeploymentPostprocessing = 0;
196 | };
197 | /* End PBXResourcesBuildPhase section */
198 |
199 | /* Begin PBXSourcesBuildPhase section */
200 | 466EF48621DFC28700ED0E09 /* Sources */ = {
201 | isa = PBXSourcesBuildPhase;
202 | buildActionMask = 2147483647;
203 | files = (
204 | 46256DBD21E01B6F00E10B7F /* RNRadarTests.m in Sources */,
205 | 466EF48D21DFC28700ED0E09 /* RNRadarUtilsTests.m in Sources */,
206 | );
207 | runOnlyForDeploymentPostprocessing = 0;
208 | };
209 | 58B511D71A9E6C8500147676 /* Sources */ = {
210 | isa = PBXSourcesBuildPhase;
211 | buildActionMask = 2147483647;
212 | files = (
213 | B3E7B58A1CC2AC0600A0062D /* RNRadar.m in Sources */,
214 | );
215 | runOnlyForDeploymentPostprocessing = 0;
216 | };
217 | /* End PBXSourcesBuildPhase section */
218 |
219 | /* Begin PBXTargetDependency section */
220 | 466EF49121DFC28700ED0E09 /* PBXTargetDependency */ = {
221 | isa = PBXTargetDependency;
222 | target = 58B511DA1A9E6C8500147676 /* RNRadar */;
223 | targetProxy = 466EF49021DFC28700ED0E09 /* PBXContainerItemProxy */;
224 | };
225 | /* End PBXTargetDependency section */
226 |
227 | /* Begin XCBuildConfiguration section */
228 | 466EF49221DFC28700ED0E09 /* Debug */ = {
229 | isa = XCBuildConfiguration;
230 | buildSettings = {
231 | ALWAYS_SEARCH_USER_PATHS = NO;
232 | CLANG_ANALYZER_NONNULL = YES;
233 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
234 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
235 | CLANG_ENABLE_OBJC_WEAK = YES;
236 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
237 | CLANG_WARN_COMMA = YES;
238 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
239 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
240 | CLANG_WARN_INFINITE_RECURSION = YES;
241 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
242 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
243 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
244 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
245 | CLANG_WARN_STRICT_PROTOTYPES = YES;
246 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
247 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
248 | CODE_SIGN_IDENTITY = "iPhone Developer";
249 | CODE_SIGN_STYLE = Automatic;
250 | DEBUG_INFORMATION_FORMAT = dwarf;
251 | DEVELOPMENT_TEAM = "";
252 | ENABLE_TESTABILITY = YES;
253 | FRAMEWORK_SEARCH_PATHS = (
254 | "$(inherited)",
255 | "$(PROJECT_DIR)/Carthage/Build/iOS",
256 | "$(PROJECT_DIR)",
257 | );
258 | GCC_C_LANGUAGE_STANDARD = gnu11;
259 | GCC_NO_COMMON_BLOCKS = YES;
260 | HEADER_SEARCH_PATHS = (
261 | "$(inherited)",
262 | "$(SRCROOT)/../node_modules/react-native/React/**",
263 | "$(SRCROOT)/../node_modules/react-native/Libraries/**",
264 | );
265 | INFOPLIST_FILE = RNRadarTests/Info.plist;
266 | IPHONEOS_DEPLOYMENT_TARGET = 12.1;
267 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
268 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
269 | MTL_FAST_MATH = YES;
270 | ONLY_ACTIVE_ARCH = YES;
271 | OTHER_LDFLAGS = "-lc++";
272 | PRODUCT_BUNDLE_IDENTIFIER = io.radar.RNRadarTests;
273 | PRODUCT_NAME = "$(TARGET_NAME)";
274 | PROVISIONING_PROFILE_SPECIFIER = "";
275 | TARGETED_DEVICE_FAMILY = "1,2";
276 | VALID_ARCHS = "arm64 arm64e armv7 armv7s i386";
277 | };
278 | name = Debug;
279 | };
280 | 466EF49321DFC28700ED0E09 /* Release */ = {
281 | isa = XCBuildConfiguration;
282 | buildSettings = {
283 | ALWAYS_SEARCH_USER_PATHS = NO;
284 | CLANG_ANALYZER_NONNULL = YES;
285 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
286 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
287 | CLANG_ENABLE_OBJC_WEAK = YES;
288 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
289 | CLANG_WARN_COMMA = YES;
290 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
291 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
292 | CLANG_WARN_INFINITE_RECURSION = YES;
293 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
294 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
295 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
296 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
297 | CLANG_WARN_STRICT_PROTOTYPES = YES;
298 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
299 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
300 | CODE_SIGN_IDENTITY = "iPhone Developer";
301 | CODE_SIGN_STYLE = Automatic;
302 | COPY_PHASE_STRIP = NO;
303 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
304 | DEVELOPMENT_TEAM = "";
305 | FRAMEWORK_SEARCH_PATHS = (
306 | "$(inherited)",
307 | "$(PROJECT_DIR)/Carthage/Build/iOS",
308 | "$(PROJECT_DIR)",
309 | );
310 | GCC_C_LANGUAGE_STANDARD = gnu11;
311 | GCC_NO_COMMON_BLOCKS = YES;
312 | HEADER_SEARCH_PATHS = (
313 | "$(inherited)",
314 | "$(SRCROOT)/../node_modules/react-native/React/**",
315 | "$(SRCROOT)/../node_modules/react-native/Libraries/**",
316 | );
317 | INFOPLIST_FILE = RNRadarTests/Info.plist;
318 | IPHONEOS_DEPLOYMENT_TARGET = 12.1;
319 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
320 | MTL_FAST_MATH = YES;
321 | OTHER_LDFLAGS = "-lc++";
322 | PRODUCT_BUNDLE_IDENTIFIER = io.radar.RNRadarTests;
323 | PRODUCT_NAME = "$(TARGET_NAME)";
324 | PROVISIONING_PROFILE_SPECIFIER = "";
325 | TARGETED_DEVICE_FAMILY = "1,2";
326 | VALID_ARCHS = "arm64 arm64e armv7 armv7s i386";
327 | };
328 | name = Release;
329 | };
330 | 58B511ED1A9E6C8500147676 /* Debug */ = {
331 | isa = XCBuildConfiguration;
332 | buildSettings = {
333 | ALWAYS_SEARCH_USER_PATHS = YES;
334 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
335 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
336 | CLANG_CXX_LIBRARY = "libc++";
337 | CLANG_ENABLE_MODULES = YES;
338 | CLANG_ENABLE_OBJC_ARC = YES;
339 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
340 | CLANG_WARN_BOOL_CONVERSION = YES;
341 | CLANG_WARN_COMMA = YES;
342 | CLANG_WARN_CONSTANT_CONVERSION = YES;
343 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
344 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
345 | CLANG_WARN_EMPTY_BODY = YES;
346 | CLANG_WARN_ENUM_CONVERSION = YES;
347 | CLANG_WARN_INFINITE_RECURSION = YES;
348 | CLANG_WARN_INT_CONVERSION = YES;
349 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
350 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
351 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
352 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
353 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
354 | CLANG_WARN_STRICT_PROTOTYPES = YES;
355 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
356 | CLANG_WARN_UNREACHABLE_CODE = YES;
357 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
358 | COPY_PHASE_STRIP = NO;
359 | ENABLE_STRICT_OBJC_MSGSEND = YES;
360 | ENABLE_TESTABILITY = YES;
361 | GCC_C_LANGUAGE_STANDARD = gnu99;
362 | GCC_DYNAMIC_NO_PIC = NO;
363 | GCC_NO_COMMON_BLOCKS = YES;
364 | GCC_OPTIMIZATION_LEVEL = 0;
365 | GCC_PREPROCESSOR_DEFINITIONS = (
366 | "DEBUG=1",
367 | "$(inherited)",
368 | );
369 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
370 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
371 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
372 | GCC_WARN_UNDECLARED_SELECTOR = YES;
373 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
374 | GCC_WARN_UNUSED_FUNCTION = YES;
375 | GCC_WARN_UNUSED_VARIABLE = YES;
376 | IPHONEOS_DEPLOYMENT_TARGET = 12.1;
377 | MTL_ENABLE_DEBUG_INFO = YES;
378 | ONLY_ACTIVE_ARCH = YES;
379 | SDKROOT = iphoneos;
380 | };
381 | name = Debug;
382 | };
383 | 58B511EE1A9E6C8500147676 /* Release */ = {
384 | isa = XCBuildConfiguration;
385 | buildSettings = {
386 | ALWAYS_SEARCH_USER_PATHS = YES;
387 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
388 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
389 | CLANG_CXX_LIBRARY = "libc++";
390 | CLANG_ENABLE_MODULES = YES;
391 | CLANG_ENABLE_OBJC_ARC = YES;
392 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
393 | CLANG_WARN_BOOL_CONVERSION = YES;
394 | CLANG_WARN_COMMA = YES;
395 | CLANG_WARN_CONSTANT_CONVERSION = YES;
396 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
397 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
398 | CLANG_WARN_EMPTY_BODY = YES;
399 | CLANG_WARN_ENUM_CONVERSION = YES;
400 | CLANG_WARN_INFINITE_RECURSION = YES;
401 | CLANG_WARN_INT_CONVERSION = YES;
402 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
403 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
404 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
405 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
406 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
407 | CLANG_WARN_STRICT_PROTOTYPES = YES;
408 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
409 | CLANG_WARN_UNREACHABLE_CODE = YES;
410 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
411 | COPY_PHASE_STRIP = YES;
412 | ENABLE_NS_ASSERTIONS = NO;
413 | ENABLE_STRICT_OBJC_MSGSEND = YES;
414 | GCC_C_LANGUAGE_STANDARD = gnu99;
415 | GCC_NO_COMMON_BLOCKS = YES;
416 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
417 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
418 | GCC_WARN_UNDECLARED_SELECTOR = YES;
419 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
420 | GCC_WARN_UNUSED_FUNCTION = YES;
421 | GCC_WARN_UNUSED_VARIABLE = YES;
422 | IPHONEOS_DEPLOYMENT_TARGET = 12.1;
423 | MTL_ENABLE_DEBUG_INFO = NO;
424 | SDKROOT = iphoneos;
425 | VALIDATE_PRODUCT = YES;
426 | };
427 | name = Release;
428 | };
429 | 58B511F01A9E6C8500147676 /* Debug */ = {
430 | isa = XCBuildConfiguration;
431 | buildSettings = {
432 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
433 | FRAMEWORK_SEARCH_PATHS = (
434 | "$(inherited)",
435 | "$(PROJECT_DIR)",
436 | "${SRCROOT}/../../../ios/**",
437 | "${SRCROOT}/../../../ios/Pods/RadarSDK/**",
438 | "$(PROJECT_DIR)/Carthage/Build/iOS",
439 | );
440 | HEADER_SEARCH_PATHS = (
441 | "$(inherited)",
442 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
443 | "$(SRCROOT)/../../../React/**",
444 | "$(SRCROOT)/../../react-native/React/**",
445 | "${SRCROOT}/../../../ios/Pods/RadarSDK/**",
446 | "${SRCROOT}/../../../ios/RadarSDK/**",
447 | "$(SRCROOT)/Carthage/Build/iOS/**",
448 | "${SRCROOT}/../../../ios/**",
449 | );
450 | LIBRARY_SEARCH_PATHS = "$(inherited)";
451 | ONLY_ACTIVE_ARCH = YES;
452 | OTHER_LDFLAGS = "$(inherited)";
453 | PRODUCT_NAME = RNRadar;
454 | SKIP_INSTALL = YES;
455 | VALID_ARCHS = "arm64 arm64e armv7 armv7s ";
456 | };
457 | name = Debug;
458 | };
459 | 58B511F11A9E6C8500147676 /* Release */ = {
460 | isa = XCBuildConfiguration;
461 | buildSettings = {
462 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
463 | FRAMEWORK_SEARCH_PATHS = (
464 | "$(inherited)",
465 | "$(PROJECT_DIR)",
466 | "${SRCROOT}/../../../ios/**",
467 | "${SRCROOT}/../../../ios/Pods/RadarSDK/**",
468 | "$(PROJECT_DIR)/Carthage/Build/iOS",
469 | );
470 | HEADER_SEARCH_PATHS = (
471 | "$(inherited)",
472 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
473 | "$(SRCROOT)/../../../React/**",
474 | "$(SRCROOT)/../../react-native/React/**",
475 | "${SRCROOT}/../../../ios/Pods/RadarSDK/**",
476 | "${SRCROOT}/../../../ios/RadarSDK/**",
477 | "$(SRCROOT)/Carthage/Build/iOS/**",
478 | "${SRCROOT}/../../../ios/**",
479 | );
480 | LIBRARY_SEARCH_PATHS = "$(inherited)";
481 | OTHER_LDFLAGS = "$(inherited)";
482 | PRODUCT_NAME = RNRadar;
483 | SKIP_INSTALL = YES;
484 | VALID_ARCHS = "arm64 arm64e armv7 armv7s ";
485 | };
486 | name = Release;
487 | };
488 | /* End XCBuildConfiguration section */
489 |
490 | /* Begin XCConfigurationList section */
491 | 466EF49421DFC28700ED0E09 /* Build configuration list for PBXNativeTarget "RNRadarTests" */ = {
492 | isa = XCConfigurationList;
493 | buildConfigurations = (
494 | 466EF49221DFC28700ED0E09 /* Debug */,
495 | 466EF49321DFC28700ED0E09 /* Release */,
496 | );
497 | defaultConfigurationIsVisible = 0;
498 | defaultConfigurationName = Release;
499 | };
500 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNRadar" */ = {
501 | isa = XCConfigurationList;
502 | buildConfigurations = (
503 | 58B511ED1A9E6C8500147676 /* Debug */,
504 | 58B511EE1A9E6C8500147676 /* Release */,
505 | );
506 | defaultConfigurationIsVisible = 0;
507 | defaultConfigurationName = Release;
508 | };
509 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNRadar" */ = {
510 | isa = XCConfigurationList;
511 | buildConfigurations = (
512 | 58B511F01A9E6C8500147676 /* Debug */,
513 | 58B511F11A9E6C8500147676 /* Release */,
514 | );
515 | defaultConfigurationIsVisible = 0;
516 | defaultConfigurationName = Release;
517 | };
518 | /* End XCConfigurationList section */
519 | };
520 | rootObject = 58B511D31A9E6C8500147676 /* Project object */;
521 | }
522 |
--------------------------------------------------------------------------------
/ios/RNRadar.xcodeproj/xcshareddata/xcschemes/RNRadar.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
50 |
51 |
52 |
53 |
59 |
60 |
66 |
67 |
68 |
69 |
71 |
72 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/logo.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-radar",
3 | "description": "React Native module for Radar, the leading geofencing and location tracking platform",
4 | "homepage": "https://radar.com",
5 | "license": "Apache-2.0",
6 | "version": "3.20.3",
7 | "main": "dist/index.js",
8 | "files": [
9 | "/android",
10 | "/ios",
11 | "README.md",
12 | "react-native-radar.podspec",
13 | "/dist",
14 | "app.plugin.js",
15 | "/plugin/build"
16 | ],
17 | "types": "dist/index.d.ts",
18 | "scripts": {
19 | "test": "jest ./test/*.test.js",
20 | "check-latest-tag": "node ./scripts/check-latest-tag.cjs",
21 | "check-beta-tag": "node ./scripts/check-beta-tag.cjs",
22 | "build": "tsc",
23 | "copy-assets": "./copyAssets.sh",
24 | "build-plugin": "tsc --build plugin/",
25 | "build-all": "npm run build && npm run build-plugin && npm run copy-assets"
26 | },
27 | "jest": {
28 | "preset": "react-native",
29 | "clearMocks": true,
30 | "reporters": [
31 | "default",
32 | "jest-junit"
33 | ],
34 | "modulePathIgnorePatterns": [
35 | "example",
36 | "example2"
37 | ],
38 | "setupFiles": [
39 | "./test/jest.setup.js"
40 | ]
41 | },
42 | "peerDependencies": {
43 | "@maplibre/maplibre-react-native": ">=9.0.1 || >=10.0.0-alpha",
44 | "expo": ">=43.0.5",
45 | "react": ">= 16.8.6",
46 | "react-native": ">= 0.60.0"
47 | },
48 | "peerDependenciesMeta": {
49 | "@maplibre/maplibre-react-native": {
50 | "optional": true
51 | },
52 | "expo": {
53 | "optional": true
54 | }
55 | },
56 | "devDependencies": {
57 | "@babel/core": "^7.2.2",
58 | "@babel/preset-env": "^7.2.3",
59 | "@babel/preset-react": "^7.0.0",
60 | "@babel/register": "^7.0.0",
61 | "babel-core": "^7.0.0-bridge.0",
62 | "babel-eslint": "^10.0.1",
63 | "babel-jest": "^23.4.2",
64 | "braces": ">=2.3.2",
65 | "eslint": "^5.6.1",
66 | "eslint-config-airbnb": "^17.1.0",
67 | "eslint-plugin-import": "^2.14.0",
68 | "eslint-plugin-jest": "^22.1.2",
69 | "eslint-plugin-jsx-a11y": "^6.1.1",
70 | "eslint-plugin-react": "^7.11.1",
71 | "expo": "^51.0.0",
72 | "expo-module-scripts": "^3.5.2",
73 | "jest": "^29.7.0",
74 | "jest-junit": "^16.0.0",
75 | "logkitty": ">=0.7.1",
76 | "metro-react-native-babel-preset": "^0.51.1",
77 | "npm-run-all": "^4.1.5",
78 | "react": "^18.2.0",
79 | "react-native": "^0.74.5",
80 | "typescript": "^5.3.3"
81 | },
82 | "bugs": {
83 | "url": "https://github.com/radarlabs/react-native-radar/issues"
84 | },
85 | "repository": {
86 | "type": "git",
87 | "url": "https://github.com/radarlabs/react-native-radar.git"
88 | },
89 | "dependencies": {
90 | "@babel/runtime": "^7.21.0",
91 | "@react-native-community/netinfo": "^7.1.3",
92 | "radar-sdk-js": "^3.7.1"
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/plugin/src/index.ts:
--------------------------------------------------------------------------------
1 | import { withRadar } from './withRadar';
2 |
3 | export { withRadar };
4 |
5 | export default withRadar;
--------------------------------------------------------------------------------
/plugin/src/types.ts:
--------------------------------------------------------------------------------
1 | export interface RadarPluginProps {
2 | iosFraud?: boolean;
3 | androidFraud?: boolean;
4 | iosNSLocationWhenInUseUsageDescription?: string;
5 | iosNSLocationAlwaysAndWhenInUseUsageDescription?: string;
6 | iosBackgroundMode?: boolean;
7 | androidBackgroundPermission?: boolean;
8 | androidForegroundService?: boolean;
9 | androidActivityRecognition?: boolean;
10 | addRadarSDKMotion?: boolean;
11 | iosNSMotionUsageDescription?: string;
12 | }
--------------------------------------------------------------------------------
/plugin/src/withRadar.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ConfigPlugin,
3 | createRunOncePlugin,
4 | WarningAggregator,
5 | } from "expo/config-plugins";
6 |
7 |
8 | import { withRadarAndroid } from "./withRadarAndroid";
9 | import { withRadarIOS } from "./withRadarIOS";
10 | const pkg = require("../../package.json");
11 |
12 | import type { RadarPluginProps } from "./types";
13 |
14 | const withRadarPlugin: ConfigPlugin = (config, args = {}) => {
15 | try {
16 | config = withRadarAndroid(config, args);
17 | } catch (e) {
18 | WarningAggregator.addWarningAndroid(
19 | "react-native-radar",
20 | "There was a problem configuring react-native-radar in your native Android project: " +
21 | e
22 | );
23 | }
24 | try {
25 | config = withRadarIOS(config, args);
26 | } catch (e) {
27 | WarningAggregator.addWarningIOS(
28 | "react-native-radar",
29 | "There was a problem configuring react-native-radar in your native iOS project: " +
30 | e
31 | );
32 | }
33 |
34 | return config;
35 | };
36 |
37 | const withRadar = createRunOncePlugin(withRadarPlugin, pkg.name, pkg.version);
38 |
39 | export { withRadar };
40 |
--------------------------------------------------------------------------------
/plugin/src/withRadarAndroid.ts:
--------------------------------------------------------------------------------
1 | import { ExpoConfig } from "expo/config";
2 |
3 | import {
4 | withAppBuildGradle,
5 | AndroidConfig,
6 | withDangerousMod,
7 | } from "expo/config-plugins";
8 | import fs from "fs";
9 | import path from "path";
10 |
11 | import { RadarPluginProps } from "./types";
12 |
13 | export const withRadarAndroid = (
14 | config: ExpoConfig,
15 | args: RadarPluginProps
16 | ) => {
17 | config = withAndroidPermissions(config, args);
18 |
19 | config = withDangerousMod(config, [
20 | "android",
21 | async (config) => {
22 | if (!args.androidFraud) {
23 | return config;
24 | }
25 | // Get the path to the Android folder
26 | const androidPath = path.join(
27 | config.modRequest.projectRoot,
28 | "android",
29 | "app",
30 | "src",
31 | "main",
32 | "res",
33 | "xml"
34 | );
35 |
36 | // Check if the directory exists, if not, create it
37 | if (!fs.existsSync(androidPath)) {
38 | fs.mkdirSync(androidPath, { recursive: true });
39 | }
40 |
41 | // Create the path to the new file
42 | const newFilePath = path.join(androidPath, "network_security_config.xml");
43 |
44 | // Define xml content
45 |
46 | const xml = `
47 |
48 |
49 |
50 | localhost
51 |
52 |
53 |
54 |
55 | api-verified.radar.io
56 |
57 | 15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=
58 | 15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=
59 |
60 |
61 | `;
62 |
63 | // Write to the new file
64 | fs.writeFileSync(newFilePath, xml);
65 |
66 | return config;
67 | },
68 | ]);
69 |
70 | return withAppBuildGradle(config, (config) => {
71 | if (config.modResults.language === "groovy") {
72 | config.modResults.contents = modifyAppBuildGradle(
73 | config.modResults.contents,
74 | args.androidFraud ?? false
75 | );
76 | } else {
77 | throw new Error(
78 | "Cannot configure Sentry in the app gradle because the build.gradle is not groovy"
79 | );
80 | }
81 | return config;
82 | });
83 | };
84 |
85 | function withAndroidPermissions(
86 | config: any,
87 | args: RadarPluginProps
88 | ): ExpoConfig {
89 | const isAndroidBackgroundLocationEnabled = !!args.androidBackgroundPermission;
90 | const enableAndroidForegroundService = !!args.androidForegroundService;
91 | const enableAndroidActivityRecognition = !!args.androidActivityRecognition;
92 | return AndroidConfig.Permissions.withPermissions(
93 | config,
94 | [
95 | isAndroidBackgroundLocationEnabled &&
96 | "android.permission.ACCESS_BACKGROUND_LOCATION",
97 | enableAndroidForegroundService && "android.permission.FOREGROUND_SERVICE",
98 | enableAndroidForegroundService &&
99 | "android.permission.FOREGROUND_SERVICE_LOCATION",
100 | enableAndroidActivityRecognition &&
101 | "android.permission.ACTIVITY_RECOGNITION",
102 | ].filter(Boolean) as string[]
103 | );
104 | }
105 |
106 | function modifyAppBuildGradle(buildGradle: string, androidFraud: boolean) {
107 | let hasLocationService = false;
108 | let hasPlayIntegrity = false;
109 | if (
110 | buildGradle.includes(
111 | 'com.google.android.gms:play-services-location:21.0.1"'
112 | )
113 | ) {
114 | hasLocationService = true;
115 | }
116 |
117 | if (buildGradle.includes('com.google.android.play:integrity:1.2.0"')) {
118 | hasPlayIntegrity = true;
119 | }
120 |
121 | const pattern = /^dependencies {/m;
122 |
123 | if (!buildGradle.match(pattern)) {
124 | throw new Error(
125 | `Failed to find react.gradle script in android/app/build.gradle.
126 | This is required for react-native-radar to function properly.
127 | Please ensure your android/app/build.gradle includes the react.gradle script.
128 | Current build.gradle content: ${buildGradle}`
129 | );
130 | }
131 |
132 | let replacementString =
133 | "\n\n" +
134 | (!hasLocationService
135 | ? ' implementation "com.google.android.gms:play-services-location:21.0.1"'
136 | : "");
137 |
138 | if (androidFraud && !hasPlayIntegrity) {
139 | replacementString +=
140 | "\n\n" + ' implementation "com.google.android.play:integrity:1.2.0"';
141 | }
142 |
143 | return buildGradle.replace(
144 | pattern,
145 | (match: string) => match + replacementString
146 | );
147 | }
148 |
--------------------------------------------------------------------------------
/plugin/src/withRadarIOS.ts:
--------------------------------------------------------------------------------
1 | import { ConfigPlugin, withInfoPlist, withDangerousMod } from "expo/config-plugins";
2 | import type { RadarPluginProps } from "./types";
3 | import fs from 'fs/promises';
4 | import path from 'path';
5 |
6 | export const withRadarIOS: ConfigPlugin = (config, args) => {
7 | config = withInfoPlist(config, (config) => {
8 | config.modResults.NSLocationWhenInUseUsageDescription =
9 | args.iosNSLocationWhenInUseUsageDescription ??
10 | "This app uses the location service to provide location-based services.";
11 | if (args.iosNSLocationAlwaysAndWhenInUseUsageDescription) {
12 | config.modResults.NSLocationAlwaysAndWhenInUseUsageDescription =
13 | args.iosNSLocationAlwaysAndWhenInUseUsageDescription;
14 | }
15 | if (args.iosBackgroundMode) {
16 | config.modResults.UIBackgroundModes = ["location", "fetch"];
17 | }
18 | if (args.iosFraud) {
19 | config.modResults.NSAppTransportSecurity = {
20 | NSAllowsArbitraryLoads: false,
21 | NSPinnedDomains: {
22 | "api-verified.radar.io": {
23 | NSIncludesSubdomains: true,
24 | NSPinnedLeafIdentities: [
25 | {
26 | "SPKI-SHA256-BASE64":
27 | "15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=",
28 | },
29 | {
30 | "SPKI-SHA256-BASE64":
31 | "15ktYXSSU2llpy7YyCgeqUKDBkjcimK/weUcec960sI=",
32 | },
33 | ],
34 | },
35 | },
36 | };
37 | }
38 | if (args.addRadarSDKMotion) {
39 | config.modResults.NSMotionUsageDescription =
40 | args.iosNSMotionUsageDescription ??
41 | "This app uses the motion service to provide motion-based services.";
42 | }
43 |
44 | return config;
45 | });
46 |
47 | if (args.addRadarSDKMotion) {
48 | config = withDangerousMod(config, [
49 | 'ios',
50 | async config => {
51 | const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
52 | const contents = await fs.readFile(filePath, 'utf-8');
53 |
54 | // Check if the pod declaration already exists
55 | if (contents.indexOf("pod 'RadarSDKMotion', '3.20.1'") === -1) {
56 | // Find the target block
57 | const targetRegex = /target '(\w+)' do/g;
58 | const match = targetRegex.exec(contents);
59 | if (match) {
60 | const targetStartIndex = match.index;
61 | const targetEndIndex = contents.indexOf('end', targetStartIndex) + 3;
62 |
63 | // Insert the pod declaration within the target block
64 | const targetBlock = contents.substring(targetStartIndex, targetEndIndex);
65 | // Just for this version of the SDK, we will be using 3.21.1 of the SDKMotion pod. There is no difference between the source code of 3.21.2 and 3.21.1 for RadarSDKMotion.
66 | const updatedTargetBlock = targetBlock.replace(/(target '(\w+)' do)/, `$1\n pod 'RadarSDKMotion', '3.20.1'`);
67 | const newContents = contents.replace(targetBlock, updatedTargetBlock);
68 |
69 | // Write the updated contents back to the Podfile
70 | await fs.writeFile(filePath, newContents);
71 | }
72 | }
73 |
74 | return config;
75 | },
76 | ]);
77 | }
78 |
79 | return config;
80 | };
--------------------------------------------------------------------------------
/plugin/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "expo-module-scripts/tsconfig.plugin",
3 | "compilerOptions": {
4 | "outDir": "build",
5 | "rootDir": "src"
6 | },
7 | "include": ["./src"],
8 | "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9 | }
--------------------------------------------------------------------------------
/react-native-radar.podspec:
--------------------------------------------------------------------------------
1 | require "json"
2 |
3 | json = File.read(File.join(__dir__, "package.json"))
4 | package = JSON.parse(json).deep_symbolize_keys
5 |
6 | Pod::Spec.new do |s|
7 | s.name = package[:name]
8 | s.version = package[:version]
9 | s.license = { type: "Apache-2.0" }
10 | s.homepage = "https://github.com/radarlabs/react-native-radar"
11 | s.authors = package[:author] || "radarlabs"
12 | s.summary = package[:description]
13 | s.source = { git: package[:repository][:url] }
14 | s.source_files = "ios/*.{h,m}"
15 | s.platform = :ios, "10.0"
16 |
17 | s.dependency "React"
18 | s.dependency "RadarSDK", "~> 3.21.3"
19 | end
20 |
--------------------------------------------------------------------------------
/react-native-radar.podspec.template:
--------------------------------------------------------------------------------
1 | require "json"
2 |
3 | json = File.read(File.join(__dir__, "package.json"))
4 | package = JSON.parse(json).deep_symbolize_keys
5 |
6 | Pod::Spec.new do |s|
7 | s.name = package[:name]
8 | s.version = package[:version]
9 | s.license = { type: "Apache-2.0" }
10 | s.homepage = "https://github.com/radarlabs/react-native-radar"
11 | s.authors = package[:author] || "radarlabs"
12 | s.summary = package[:description]
13 | s.source = { git: package[:repository][:url] }
14 | s.source_files = "ios/*.{h,m}"
15 | s.platform = :ios, "10.0"
16 |
17 | s.dependency "React"
18 | s.dependency "RadarSDK", "~> {{ version }}"
19 | end
20 |
--------------------------------------------------------------------------------
/react-native.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | project:{
3 | android: {
4 | unstable_reactLegacyComponentNames: [ "Map", "Autocomplete" ]
5 | },
6 | ios: {
7 | unstable_reactLegacyComponentNames: [ "Map", "Autocomplete" ]
8 | }
9 | },
10 | };
--------------------------------------------------------------------------------
/scripts/check-beta-tag.cjs:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const packageJSON = require('../package.json');
3 | const packageLockJSON = require('../package-lock.json');
4 |
5 | let tagVersion = process.env.GITHUB_REF_NAME || '';
6 | console.log('Checking tag:', tagVersion);
7 |
8 |
9 | if (!tagVersion.includes('-beta')) {
10 | console.error('Prelease version should contain a "-beta" suffix');
11 | process.exit(1);
12 | }
13 |
14 | if (tagVersion !== packageJSON.version) {
15 | console.error('VERSION MISMATCH - version does not match package.json.');
16 | process.exit(1);
17 | }
18 | if (tagVersion !== packageLockJSON.version) {
19 | console.error('VERSION MISMATCH - version does not match package-lock.json.');
20 | process.exit(1);
21 | }
22 | console.log('Tag OK.', tagVersion);
23 |
--------------------------------------------------------------------------------
/scripts/check-latest-tag.cjs:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const packageJSON = require('../package.json');
3 | const packageLockJSON = require('../package-lock.json');
4 |
5 | let tagVersion = process.env.GITHUB_REF_NAME || '';
6 | console.log('Checking tag:', tagVersion);
7 |
8 |
9 | if (tagVersion.includes('-')) {
10 | console.error('Latest tag should not include any suffix:', `-${tagVersion.split('-')[1]}`);
11 | process.exit(1);
12 | }
13 |
14 | if (tagVersion !== packageJSON.version) {
15 | console.error('VERSION MISMATCH - version does not match package.json.');
16 | process.exit(1);
17 | }
18 | if (tagVersion !== packageLockJSON.version) {
19 | console.error('VERSION MISMATCH - version does not match package-lock.json.');
20 | process.exit(1);
21 | }
22 | console.log('Tag OK.', tagVersion);
23 |
--------------------------------------------------------------------------------
/src/@types/RadarNativeInterface.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Location,
3 | RadarAddress,
4 | RadarAddressCallback,
5 | RadarAutocompleteOptions,
6 | RadarContextCallback,
7 | RadarEventChannel,
8 | RadarGeocodeOptions,
9 | RadarGetDistanceOptions,
10 | RadarGetMatrixOptions,
11 | RadarIPGeocodeCallback,
12 | RadarListenerCallback,
13 | RadarLocationCallback,
14 | RadarLogConversionCallback,
15 | RadarLogConversionOptions,
16 | RadarLogLevel,
17 | RadarMetadata,
18 | RadarMockTrackingOptions,
19 | RadarNotificationOptions,
20 | RadarPermissionsStatus,
21 | RadarReverseGeocodeOptions,
22 | RadarRouteCallback,
23 | RadarRouteMatrix,
24 | RadarSearchGeofencesCallback,
25 | RadarSearchGeofencesOptions,
26 | RadarSearchPlacesCallback,
27 | RadarSearchPlacesOptions,
28 | RadarStartTripOptions,
29 | RadarTrackCallback,
30 | RadarTrackingOptions,
31 | RadarTrackingOptionsDesiredAccuracy,
32 | RadarTrackingOptionsForegroundService,
33 | RadarTrackOnceOptions,
34 | RadarTrackVerifiedCallback,
35 | RadarTrackVerifiedOptions,
36 | RadarTripCallback,
37 | RadarTripOptions,
38 | RadarUpdateTripOptions,
39 | RadarValidateAddressCallback,
40 | RadarVerifiedTrackingOptions,
41 | } from "./types";
42 |
43 | export interface RadarNativeInterface {
44 | initialize: (publishableKey: string, fraud?: boolean) => void;
45 | setLogLevel: (level: RadarLogLevel) => void;
46 | setUserId: (userId: string) => void;
47 | getUserId: () => Promise;
48 | setDescription: (description: string) => void;
49 | getDescription: () => Promise;
50 | setMetadata: (metadata: RadarMetadata) => void;
51 | getMetadata: () => Promise;
52 | setAnonymousTrackingEnabled: (enabled: boolean) => void;
53 | getPermissionsStatus: () => Promise;
54 | requestPermissions: (background: boolean) => Promise;
55 | getLocation: (
56 | desiredAccuracy?: RadarTrackingOptionsDesiredAccuracy
57 | ) => Promise;
58 | trackOnce: (
59 | options?: RadarTrackOnceOptions | Location
60 | ) => Promise;
61 | trackVerified: (options?: RadarTrackVerifiedOptions) => Promise;
62 | getVerifiedLocationToken: () => Promise;
63 | clearVerifiedLocationToken: () => void;
64 | startTrackingEfficient: () => void;
65 | startTrackingResponsive: () => void;
66 | startTrackingContinuous: () => void;
67 | startTrackingCustom: (options: RadarTrackingOptions) => void;
68 | startTrackingVerified: (options?: RadarVerifiedTrackingOptions) => void;
69 | isTrackingVerified: () => Promise;
70 | setProduct(product: string): void;
71 | mockTracking: (options: RadarMockTrackingOptions) => void;
72 | stopTracking: () => void;
73 | stopTrackingVerified: () => void;
74 | getTrackingOptions: () => Promise;
75 | isUsingRemoteTrackingOptions: () => Promise;
76 | isTracking: () => Promise;
77 | setForegroundServiceOptions: (
78 | options: RadarTrackingOptionsForegroundService
79 | ) => void;
80 | setNotificationOptions: (options: RadarNotificationOptions) => void;
81 | getTripOptions: () => Promise;
82 | startTrip: (options: RadarStartTripOptions) => Promise;
83 | completeTrip: () => Promise;
84 | cancelTrip: () => Promise;
85 | updateTrip: (options: RadarUpdateTripOptions) => Promise;
86 | acceptEvent: (eventId: string, verifiedPlaceId: string) => void;
87 | rejectEvent: (eventId: string) => void;
88 | getContext: (location?: Location) => Promise;
89 | searchPlaces: (
90 | options: RadarSearchPlacesOptions
91 | ) => Promise;
92 | searchGeofences: (
93 | options: RadarSearchGeofencesOptions
94 | ) => Promise;
95 | autocomplete: (
96 | options: RadarAutocompleteOptions
97 | ) => Promise;
98 | geocode: (options: RadarGeocodeOptions) => Promise;
99 | reverseGeocode: (options?: RadarReverseGeocodeOptions) => Promise;
100 | ipGeocode: () => Promise;
101 | validateAddress: (address: RadarAddress) => Promise;
102 | getDistance: (option: RadarGetDistanceOptions) => Promise;
103 | getMatrix: (option: RadarGetMatrixOptions) => Promise;
104 | logConversion: (
105 | options: RadarLogConversionOptions
106 | ) => Promise;
107 | sendEvent: (name: string, metadata: RadarMetadata) => void;
108 | on: (channel: RadarEventChannel, callback: RadarListenerCallback) => void;
109 | off: (channel: RadarEventChannel, callback?: Function | undefined) => void;
110 | nativeSdkVersion: () => Promise;
111 | rnSdkVersion: () => string;
112 | }
113 |
--------------------------------------------------------------------------------
/src/@types/types.ts:
--------------------------------------------------------------------------------
1 | import { Platform } from 'react-native';
2 | const platform = Platform.OS;
3 |
4 | export type RadarMetadata = Record;
5 |
6 | export interface RadarTrackOnceOptions {
7 | location?: Location;
8 | desiredAccuracy?: RadarTrackingOptionsDesiredAccuracy;
9 | beacons?: boolean;
10 | }
11 |
12 | export interface RadarTrackVerifiedOptions {
13 | beacons?: boolean;
14 | desiredAccuracy?: RadarTrackingOptionsDesiredAccuracy;
15 | }
16 |
17 | /**
18 | * Options for tracking the user's location.
19 | * @see {@link https://radar.com/documentation/sdk/tracking}
20 | */
21 | export interface RadarTrackingOptions {
22 | desiredStoppedUpdateInterval: number;
23 | fastestStoppedUpdateInterval?: number;
24 | desiredMovingUpdateInterval: number;
25 | fastestMovingUpdateInterval?: number;
26 | desiredSyncInterval: number;
27 | desiredAccuracy: RadarTrackingOptionsDesiredAccuracy;
28 | stopDuration: number;
29 | stopDistance: number;
30 | sync: "all" | "stopsAndExits" | "none";
31 | replay: "all" | "stops" | "none";
32 | useStoppedGeofence: boolean;
33 | showBlueBar?: boolean;
34 | startTrackingAfter?: number;
35 | stopTrackingAfter?: number;
36 | stoppedGeofenceRadius: number;
37 | useMovingGeofence: boolean;
38 | movingGeofenceRadius: number;
39 | syncGeofences: boolean;
40 | useVisits?: boolean;
41 | useSignificantLocationChanges?: boolean;
42 | beacons: boolean;
43 | syncGeofencesLimit?: number;
44 | foregroundServiceEnabled?: boolean;
45 | }
46 |
47 |
48 |
49 | export const presetContinuousIOS: RadarTrackingOptions = {
50 | desiredStoppedUpdateInterval: 30,
51 | desiredMovingUpdateInterval: 30,
52 | desiredSyncInterval: 20,
53 | desiredAccuracy:'high',
54 | stopDuration: 140,
55 | stopDistance: 70,
56 | replay: 'none',
57 | useStoppedGeofence: false,
58 | showBlueBar: true,
59 | startTrackingAfter: undefined,
60 | stopTrackingAfter: undefined,
61 | stoppedGeofenceRadius: 0,
62 | useMovingGeofence: false,
63 | movingGeofenceRadius: 0,
64 | syncGeofences: true,
65 | useVisits: false,
66 | useSignificantLocationChanges: false,
67 | beacons: false,
68 | sync: 'all',
69 | };
70 |
71 | export const presetContinuousAndroid: RadarTrackingOptions = {
72 | desiredStoppedUpdateInterval: 30,
73 | fastestStoppedUpdateInterval: 30,
74 | desiredMovingUpdateInterval: 30,
75 | fastestMovingUpdateInterval: 30,
76 | desiredSyncInterval: 20,
77 | desiredAccuracy: 'high',
78 | stopDuration: 140,
79 | stopDistance: 70,
80 | replay: 'none',
81 | sync: 'all',
82 | useStoppedGeofence: false,
83 | stoppedGeofenceRadius: 0,
84 | useMovingGeofence: false,
85 | movingGeofenceRadius: 0,
86 | syncGeofences: true,
87 | syncGeofencesLimit: 0,
88 | foregroundServiceEnabled: true,
89 | beacons: false,
90 | startTrackingAfter: undefined,
91 | stopTrackingAfter: undefined,
92 | };
93 |
94 | export const presetContinuous: RadarTrackingOptions = platform === 'ios' ? presetContinuousIOS : presetContinuousAndroid;
95 |
96 | export const presetResponsiveIOS: RadarTrackingOptions = {
97 | desiredStoppedUpdateInterval: 0,
98 | desiredMovingUpdateInterval: 150,
99 | desiredSyncInterval: 20,
100 | desiredAccuracy:'medium',
101 | stopDuration: 140,
102 | stopDistance: 70,
103 | replay: 'stops',
104 | useStoppedGeofence: true,
105 | showBlueBar: false,
106 | startTrackingAfter: undefined,
107 | stopTrackingAfter: undefined,
108 | stoppedGeofenceRadius: 100,
109 | useMovingGeofence: true,
110 | movingGeofenceRadius: 100,
111 | syncGeofences: true,
112 | useVisits: true,
113 | useSignificantLocationChanges: true,
114 | beacons: false,
115 | sync: 'all',
116 | };
117 |
118 | export const presetResponsiveAndroid: RadarTrackingOptions = {
119 | desiredStoppedUpdateInterval: 0,
120 | fastestStoppedUpdateInterval: 0,
121 | desiredMovingUpdateInterval: 150,
122 | fastestMovingUpdateInterval: 30,
123 | desiredSyncInterval: 20,
124 | desiredAccuracy:"medium",
125 | stopDuration: 140,
126 | stopDistance: 70,
127 | replay: 'stops',
128 | sync: 'all',
129 | useStoppedGeofence: true,
130 | stoppedGeofenceRadius: 100,
131 | useMovingGeofence: true,
132 | movingGeofenceRadius: 100,
133 | syncGeofences: true,
134 | syncGeofencesLimit: 10,
135 | foregroundServiceEnabled: false,
136 | beacons: false,
137 | startTrackingAfter: undefined,
138 | stopTrackingAfter: undefined,
139 | };
140 |
141 | export const presetResponsive: RadarTrackingOptions = platform === 'ios' ? presetResponsiveIOS : presetResponsiveAndroid;
142 |
143 | export const presetEfficientIOS: RadarTrackingOptions = {
144 | desiredStoppedUpdateInterval: 0,
145 | desiredMovingUpdateInterval: 0,
146 | desiredSyncInterval: 0,
147 | desiredAccuracy: "medium",
148 | stopDuration: 0,
149 | stopDistance: 0,
150 | replay: 'stops',
151 | useStoppedGeofence: false,
152 | showBlueBar: false,
153 | startTrackingAfter: undefined,
154 | stopTrackingAfter: undefined,
155 | stoppedGeofenceRadius: 0,
156 | useMovingGeofence: false,
157 | movingGeofenceRadius: 0,
158 | syncGeofences: true,
159 | useVisits: true,
160 | useSignificantLocationChanges: false,
161 | beacons: false,
162 | sync: 'all',
163 | };
164 |
165 | export const presetEfficientAndroid: RadarTrackingOptions = {
166 | desiredStoppedUpdateInterval: 3600,
167 | fastestStoppedUpdateInterval: 1200,
168 | desiredMovingUpdateInterval: 1200,
169 | fastestMovingUpdateInterval: 360,
170 | desiredSyncInterval: 140,
171 | desiredAccuracy: 'medium',
172 | stopDuration: 140,
173 | stopDistance: 70,
174 | replay: 'stops',
175 | sync: 'all',
176 | useStoppedGeofence: false,
177 | stoppedGeofenceRadius: 0,
178 | useMovingGeofence: false,
179 | movingGeofenceRadius: 0,
180 | syncGeofences: true,
181 | syncGeofencesLimit: 10,
182 | foregroundServiceEnabled: false,
183 | beacons: false,
184 | startTrackingAfter: undefined,
185 | stopTrackingAfter: undefined,
186 | };
187 |
188 | export const presetEfficient: RadarTrackingOptions = platform === 'ios' ? presetEfficientIOS : presetEfficientAndroid;
189 |
190 |
191 | export interface RadarMockTrackingOptions {
192 | origin: Location;
193 | destination: Location;
194 | mode: RadarRouteMode;
195 | steps: number;
196 | interval: number;
197 | }
198 |
199 | export interface RadarVerifiedTrackingOptions {
200 | interval?: number;
201 | beacons?: boolean;
202 | }
203 |
204 | export interface RadarVerifiedLocationToken {
205 | user: RadarUser;
206 | events: RadarEvent[];
207 | token: string;
208 | expiresAt: Date;
209 | expiresIn: number;
210 | passed: boolean;
211 | }
212 |
213 | export interface RadarGetDistanceOptions {
214 | origin?: Location;
215 | destination?: Location;
216 | modes?: RadarRouteMode[];
217 | units?: "metric" | "imperial";
218 | }
219 |
220 | export interface RadarGetMatrixOptions {
221 | origins?: Location[];
222 | destinations?: Location[];
223 | mode?: RadarRouteMode;
224 | units?: "metric" | "imperial";
225 | }
226 |
227 | export interface RadarUpdateTripOptions {
228 | options: RadarTripOptions;
229 | status: RadarTripStatus;
230 | }
231 |
232 | export interface RadarStartTripOptions {
233 | tripOptions: RadarTripOptions;
234 | trackingOptions?: RadarTrackingOptions;
235 | }
236 |
237 | export interface RadarSearchGeofencesOptions {
238 | near?: Location;
239 | radius?: number;
240 | metadata?: RadarMetadata;
241 | tags?: string[];
242 | limit?: number;
243 | includeGeometry: boolean;
244 | }
245 |
246 | export interface RadarTrackingOptionsForegroundServiceOptions {
247 | text?: string;
248 | title?: string;
249 | updatesOnly: boolean;
250 | activity?: string;
251 | importance?: number;
252 | id?: number;
253 | channelName?: string;
254 | iconString?: string;
255 | iconColor?: string;
256 | }
257 |
258 | export interface RadarSearchPlacesOptions {
259 | near?: Location;
260 | radius?: number;
261 | chains?: string[];
262 | chainMetadata?: RadarMetadata;
263 | categories?: string[];
264 | groups?: string[];
265 | countryCodes?: string[];
266 | limit?: number;
267 | }
268 |
269 | export interface RadarAutocompleteOptions {
270 | query: string;
271 | near?: Location;
272 | layers?: string[];
273 | limit: number;
274 | country?: string;
275 | /** @deprecated this is always true, regardless of the value passed here */
276 | expandUnits?: boolean;
277 | mailable?: boolean;
278 | }
279 |
280 | export interface RadarGeocodeOptions {
281 | address: string;
282 | layers?: string[];
283 | countries?: string[];
284 | }
285 |
286 | export interface RadarReverseGeocodeOptions {
287 | location?: Location;
288 | layers?: string[];
289 | }
290 |
291 | export interface RadarNotificationOptions {
292 | iconString?: string;
293 | iconColor?: string;
294 | foregroundServiceIconString?: string;
295 | foregroundServiceIconColor?: string;
296 | eventIconString?: string;
297 | eventIconColor?: string;
298 | }
299 |
300 | export interface RadarLogConversionOptions {
301 | name: string;
302 | revenue?: number;
303 | metadata?: RadarMetadata;
304 | }
305 |
306 | export interface RadarTripOptions {
307 | externalId: string;
308 | metadata?: RadarMetadata;
309 | destinationGeofenceTag?: string;
310 | destinationGeofenceExternalId?: string;
311 | mode?: RadarRouteMode;
312 | scheduledArrivalAt?: number;
313 | approachingThreshold?: number;
314 | startTracking?: boolean; // defaults to true
315 | }
316 |
317 | export interface RadarTrackCallback {
318 | status: string;
319 | location?: Location;
320 | user?: RadarUser;
321 | events?: RadarEvent[];
322 | }
323 |
324 | export interface RadarLocationCallback {
325 | status: string;
326 | location?: Location;
327 | stopped: boolean;
328 | }
329 |
330 | export interface RadarTripCallback {
331 | status: string;
332 | trip?: RadarTrip;
333 | events?: RadarEvent[];
334 | }
335 |
336 | export interface RadarContextCallback {
337 | status: string;
338 | location?: Location;
339 | context?: RadarContext;
340 | }
341 |
342 | export interface RadarSearchPlacesCallback {
343 | status: string;
344 | location?: Location;
345 | places?: RadarPlace[];
346 | }
347 |
348 | export interface RadarSearchGeofencesCallback {
349 | status: string;
350 | location?: Location;
351 | geofences?: RadarGeofence[];
352 | }
353 |
354 | export interface RadarAddressCallback {
355 | status: string;
356 | addresses?: RadarAddress[];
357 | }
358 |
359 | export interface RadarIPGeocodeCallback {
360 | status: string;
361 | address?: RadarAddress;
362 | proxy?: boolean;
363 | }
364 |
365 | export interface RadarValidateAddressCallback {
366 | status: string;
367 | address?: RadarAddress;
368 | verificationStatus?: RadarVerificationStatus;
369 | }
370 |
371 | export interface RadarIPGeocodeCallback {
372 | status: string;
373 | address?: RadarAddress;
374 | proxy?: boolean;
375 | }
376 |
377 | export interface RadarRouteCallback {
378 | status: string;
379 | routes?: RadarRoutes;
380 | }
381 |
382 | export interface RadarLogConversionCallback {
383 | status: string;
384 | event?: RadarEvent;
385 | }
386 |
387 | export interface RadarTrackVerifiedCallback {
388 | status: string;
389 | token?: RadarVerifiedLocationToken;
390 | }
391 |
392 | export interface RadarEventUpdate {
393 | user?: RadarUser;
394 | events: RadarEvent[];
395 | }
396 |
397 | export interface RadarEventUpdateCallback {
398 | (args: RadarEventUpdate): void;
399 | }
400 |
401 | export interface RadarLocationUpdate {
402 | location: Location;
403 | user: RadarUser;
404 | }
405 |
406 | export interface RadarLocationUpdateCallback {
407 | (args: RadarLocationUpdate): void;
408 | }
409 |
410 | export interface RadarClientLocationUpdate {
411 | location: Location;
412 | stopped: boolean;
413 | source: RadarLocationSource;
414 | }
415 |
416 | export interface RadarClientLocationUpdateCallback {
417 | (args: RadarClientLocationUpdate): void;
418 | }
419 |
420 | export interface RadarErrorCallback {
421 | (status: string): void;
422 | }
423 |
424 | export interface RadarLogUpdateCallback {
425 | (status: string): void;
426 | }
427 |
428 |
429 | export type RadarListenerCallback =
430 | | RadarEventUpdateCallback
431 | | RadarLocationUpdateCallback
432 | | RadarClientLocationUpdateCallback
433 | | RadarErrorCallback
434 | | RadarLogUpdateCallback
435 |
436 | export type RadarPermissionsStatus =
437 | | "GRANTED_FOREGROUND"
438 | | "GRANTED_BACKGROUND"
439 | | "DENIED"
440 | | "NOT_DETERMINED"
441 | | "UNKNOWN";
442 |
443 | export type RadarLocationSource =
444 | | "FOREGROUND_LOCATION"
445 | | "BACKGROUND_LOCATION"
446 | | "MANUAL_LOCATION"
447 | | "VISIT_ARRIVAL"
448 | | "VISIT_DEPARTURE"
449 | | "GEOFENCE_ENTER"
450 | | "GEOFENCE_DWELL"
451 | | "GEOFENCE_EXIT"
452 | | "MOCK_LOCATION"
453 | | "BEACON_ENTER"
454 | | "BEACON_EXIT"
455 | | "UNKNOWN";
456 |
457 | export type RadarEventChannel = "clientLocation" | "location" | "error" | "events" | "log" | "token" ;
458 |
459 | export type RadarLogLevel = "info" | "debug" | "warning" | "error" | "none";
460 |
461 | export interface RadarRouteMatrix {
462 | status: string;
463 | matrix?: RadarRoute[][];
464 | }
465 |
466 | export interface Location {
467 | latitude: number;
468 | longitude: number;
469 | accuracy?: number;
470 | speed?: number;
471 | altitude?: number;
472 | course?: number;
473 | verticalAccuracy?: number;
474 | speedAccuracy?: number;
475 | courseAccuracy?: number;
476 | mocked?: boolean;
477 | }
478 |
479 | export interface RadarUser {
480 | _id: string;
481 | userId?: string;
482 | deviceId?: string;
483 | description?: string;
484 | metadata?: RadarMetadata;
485 | location?: RadarCoordinate;
486 | geofences?: RadarGeofence[];
487 | place?: RadarPlace;
488 | beacons?: RadarBeacon[];
489 | stopped?: boolean;
490 | foreground?: boolean;
491 | country?: RadarRegion;
492 | state?: RadarRegion;
493 | dma?: RadarRegion;
494 | postalCode?: RadarRegion;
495 | nearbyPlaceChains?: RadarChain[];
496 | segments?: RadarSegment[];
497 | topChains?: RadarChain[];
498 | source?: LocationSource;
499 | trip?: RadarTrip;
500 | debug?: boolean;
501 | fraud?: RadarFraud;
502 | }
503 |
504 | export interface RadarCoordinate {
505 | type: string;
506 | coordinates: [number, number];
507 | }
508 |
509 | export type LocationSource =
510 | | "FOREGROUND_LOCATION"
511 | | "BACKGROUND_LOCATION"
512 | | "MANUAL_LOCATION"
513 | | "VISIT_ARRIVAL"
514 | | "VISIT_DEPARTURE"
515 | | "GEOFENCE_ENTER"
516 | | "GEOFENCE_EXIT"
517 | | "MOCK_LOCATION"
518 | | "BEACON_ENTER"
519 | | "BEACON_EXIT"
520 | | "UNKNOWN";
521 |
522 | export interface RadarTrip {
523 | _id: string;
524 | externalId: string;
525 | metadata?: RadarMetadata;
526 | destinationGeofenceTag?: string;
527 | destinationGeofenceExternalId?: string;
528 | mode?: RadarRouteMode;
529 | eta?: RadarTripEta;
530 | status: RadarTripStatus;
531 | scheduledArrivalAt?: Date;
532 | destinationLocation: Location;
533 | delay:RadarDelay;
534 | }
535 |
536 | export interface RadarDelay {
537 | delayed:boolean;
538 | scheduledArrivalTimeDelay:number;
539 | }
540 |
541 | export interface RadarSegment {
542 | description: string;
543 | externalId: string;
544 | }
545 |
546 | export interface RadarContext {
547 | geofences?: RadarGeofence[];
548 | place?: RadarPlace;
549 | country?: RadarRegion;
550 | state?: RadarRegion;
551 | dma?: RadarRegion;
552 | postalCode?: RadarRegion;
553 | }
554 |
555 | export interface RadarEvent {
556 | _id: string;
557 | live: boolean;
558 | type: RadarEventType;
559 | geofence?: RadarGeofence;
560 | place?: RadarPlace;
561 | region?: RadarRegion;
562 | confidence: RadarEventConfidence;
563 | duration?: number;
564 | beacon?: RadarBeacon;
565 | trip?: RadarTrip;
566 | alternatePlaces?: RadarPlace[];
567 | location?: RadarCoordinate;
568 | metadata?: RadarMetadata;
569 | replayed?: boolean;
570 | createdAt: string;
571 | actualCreatedAt: string;
572 | fraud?: RadarFraud;
573 | }
574 |
575 | export enum RadarEventConfidence {
576 | none = 0,
577 | low = 1,
578 | medium = 2,
579 | high = 3,
580 | }
581 |
582 | export type RadarEventType =
583 | | "unknown"
584 | | "user.entered_geofence"
585 | | "user.entered_beacon"
586 | | "user.dwelled_in_geofence"
587 | | "user.entered_place"
588 | | "user.entered_region_country"
589 | | "user.entered_region_dma"
590 | | "user.entered_region_state"
591 | | "user.entered_region_postal_code"
592 | | "user.exited_geofence"
593 | | "user.exited_beacon"
594 | | "user.exited_place"
595 | | "user.exited_region_country"
596 | | "user.exited_region_dma"
597 | | "user.exited_region_state"
598 | | "user.exited_region_postal_code"
599 | | "user.nearby_place_chain"
600 | | "user.started_trip"
601 | | "user.updated_trip"
602 | | "user.approaching_trip_destination"
603 | | "user.arrived_at_trip_destination"
604 | | "user.stopped_trip"
605 | | "user.arrived_at_wrong_trip_destination"
606 | | "user.delayed_during_trip"
607 | | "user.failed_fraud";
608 |
609 | export type RadarTrackingOptionsDesiredAccuracy =
610 | | "high"
611 | | "medium"
612 | | "low"
613 | | "none";
614 |
615 | export enum RadarEventVerification {
616 | accept = 1,
617 | unverify = 0,
618 | reject = -1,
619 | }
620 |
621 | export type RadarBeaconType = "eddystone" | "ibeacon";
622 |
623 | export interface RadarGeofence {
624 | _id: string;
625 | description: string;
626 | tag?: string;
627 | externalId?: string;
628 | metadata?: RadarMetadata;
629 | type?: "Circle" | "Polygon";
630 | geometryRadius?: number;
631 | geometryCenter?: RadarCoordinate;
632 | // only available for geofences of type "Polygon"
633 | coordinates?: number[][];
634 | operatingHours?: RadarOperatingHours;
635 | }
636 |
637 | export interface RadarOperatingHours {
638 | [day: string]: string[][];
639 | }
640 |
641 | export interface RadarBeacon {
642 | _id: string;
643 | metadata?: RadarMetadata;
644 | type: RadarBeaconType;
645 | uuid?: string;
646 | instance?: string;
647 | major?: string;
648 | minor?: string;
649 | geometry?: RadarCoordinate;
650 | rss?: number;
651 | }
652 |
653 | export interface RadarPlace {
654 | _id: string;
655 | name: string;
656 | categories: string[];
657 | chain?: RadarChain;
658 | location: Location;
659 | metadata?: RadarMetadata;
660 | group?: string;
661 | address?: RadarAddress;
662 | }
663 |
664 | export interface RadarChain {
665 | name: string;
666 | slug: string;
667 | externalId?: string;
668 | metadata?: RadarMetadata;
669 | }
670 |
671 | export interface RadarRegion {
672 | _id: string;
673 | type: string;
674 | code: string;
675 | name: string;
676 | allowed?: boolean;
677 | flag?: string;
678 | passed?: boolean;
679 | inExclusionZone?: boolean;
680 | inBufferZone?: boolean;
681 | distanceToBorder?: number;
682 | }
683 |
684 | export interface RadarAddress {
685 | addressLabel?: string;
686 | borough?: string;
687 | city?: string;
688 | confidence?: string;
689 | country?: string;
690 | countryCode?: string;
691 | countryFlag?: string;
692 | county?: string;
693 | distance?: number;
694 | dma?: string;
695 | dmaCode?: string;
696 | formattedAddress?: string;
697 | latitude: number;
698 | layer?: string;
699 | longitude: number;
700 | metadata?: RadarMetadata;
701 | neighborhood?: string;
702 | number?: string;
703 | placeLabel?: string;
704 | plus4?: string;
705 | postalCode?: string;
706 | state?: string;
707 | stateCode?: string;
708 | street?: string;
709 | unit?: string;
710 | timeZone?: RadarTimeZone;
711 | }
712 |
713 | export interface RadarTimeZone {
714 | id: string;
715 | name: string;
716 | code: string;
717 | currentTime: string;
718 | utcOffset: number;
719 | dstOffset: number;
720 | }
721 |
722 | export type RadarVerificationStatus =
723 | | "verified"
724 | | "partially verified"
725 | | "ambiguous"
726 | | "unverified";
727 |
728 | export interface RadarRoutes {
729 | geodesic?: RadarRouteDistance;
730 | foot?: RadarRoute;
731 | bike?: RadarRoute;
732 | car?: RadarRoute;
733 | truck?: RadarRoute;
734 | motorbike?: RadarRoute;
735 | }
736 |
737 | export interface RadarRouteGeometry {
738 | type: string;
739 | coordinates: number[][];
740 | }
741 |
742 | export interface RadarRoute {
743 | distance?: RadarRouteDistance;
744 | duration?: RadarRouteDuration;
745 | geometry?: RadarRouteGeometry;
746 | }
747 |
748 | export interface RadarRouteDistance {
749 | value: number;
750 | text: string;
751 | }
752 |
753 | export interface RadarRouteDuration {
754 | value: number;
755 | text: string;
756 | }
757 |
758 | export interface RadarTripEta {
759 | distance?: number;
760 | duration?: number;
761 | }
762 |
763 | export interface RadarFraud {
764 | passed: boolean;
765 | bypassed: boolean;
766 | verified: boolean;
767 | proxy: boolean;
768 | mocked: boolean;
769 | compromised: boolean;
770 | jumped: boolean;
771 | inaccurate: boolean;
772 | blocked: boolean;
773 | sharing: boolean;
774 | }
775 |
776 | export type RadarTrackingOptionsReplay = "all" | "stops" | "none";
777 |
778 | export type RadarTrackingOptionsSync = "none" | "stopsAndExits" | "all";
779 |
780 | export type RadarRouteMode = "foot" | "bike" | "car" | "truck" | "motorbike";
781 |
782 | export interface RadarTrackingOptionsForegroundService {
783 | text?: string;
784 | title?: string;
785 | icon?: number;
786 | updatesOnly?: boolean;
787 | activity?: string;
788 | importance?: number;
789 | id?: number;
790 | channelName?: string;
791 | iconString?: string;
792 | iconColor?: string;
793 | }
794 |
795 | export type RadarTripStatus =
796 | | "unknown"
797 | | "started"
798 | | "approaching"
799 | | "arrived"
800 | | "expired"
801 | | "completed"
802 | | "canceled";
803 |
804 |
--------------------------------------------------------------------------------
/src/helpers.js:
--------------------------------------------------------------------------------
1 | import { NativeModules, Platform } from 'react-native';
2 |
3 | if (!NativeModules.RNRadar && (Platform.OS === 'ios' || Platform.OS === 'android')) {
4 | throw new Error('NativeModules.RNRadar is undefined');
5 | }
6 |
7 | const getHost = () => (
8 | NativeModules.RNRadar.getHost()
9 | );
10 |
11 | const getPublishableKey = () => (
12 | NativeModules.RNRadar.getPublishableKey()
13 | );
14 |
15 | export { getHost, getPublishableKey };
16 |
--------------------------------------------------------------------------------
/src/index.native.ts:
--------------------------------------------------------------------------------
1 | import { EmitterSubscription, NativeEventEmitter, NativeModules, Platform } from "react-native";
2 | import { version } from "../package.json";
3 | import { RadarNativeInterface } from "./@types/RadarNativeInterface";
4 | import {
5 | Location,
6 | RadarAutocompleteOptions,
7 | RadarContextCallback,
8 | RadarAddressCallback,
9 | RadarEventChannel,
10 | RadarGeocodeOptions,
11 | RadarGetDistanceOptions,
12 | RadarLocationCallback,
13 | RadarLogConversionCallback,
14 | RadarLogConversionOptions,
15 | RadarLogLevel,
16 | RadarMockTrackingOptions,
17 | RadarNotificationOptions,
18 | RadarPermissionsStatus,
19 | RadarReverseGeocodeOptions,
20 | RadarRouteCallback,
21 | RadarRouteMatrix,
22 | RadarSearchGeofencesCallback,
23 | RadarSearchGeofencesOptions,
24 | RadarSearchPlacesCallback,
25 | RadarSearchPlacesOptions,
26 | RadarStartTripOptions,
27 | RadarTrackCallback,
28 | RadarTrackOnceOptions,
29 | RadarTrackingOptions,
30 | RadarTrackingOptionsDesiredAccuracy,
31 | RadarTrackingOptionsForegroundService,
32 | RadarTripCallback,
33 | RadarTripOptions,
34 | RadarUpdateTripOptions,
35 | RadarVerifiedTrackingOptions,
36 | RadarListenerCallback,
37 | RadarGetMatrixOptions,
38 | RadarMetadata,
39 | RadarIPGeocodeCallback,
40 | RadarTrackVerifiedOptions,
41 | RadarTrackVerifiedCallback,
42 | RadarValidateAddressCallback,
43 | RadarAddress,
44 | } from "./@types/types";
45 |
46 | if (
47 | !NativeModules.RNRadar &&
48 | (Platform.OS === "ios" || Platform.OS === "android")
49 | ) {
50 | throw new Error("NativeModules.RNRadar is undefined");
51 | }
52 |
53 | const eventEmitter = new NativeEventEmitter(NativeModules.RNRadar);
54 |
55 | const initialize = (publishableKey: string, fraud: boolean = false): void => {
56 | NativeModules.RNRadar.initialize(publishableKey, fraud);
57 | };
58 |
59 | const setLogLevel = (level: RadarLogLevel): void => {
60 | NativeModules.RNRadar.setLogLevel(level);
61 | };
62 |
63 | const setUserId = (userId: string): void => {
64 | NativeModules.RNRadar.setUserId(userId);
65 | };
66 |
67 | const getUserId = (): Promise => NativeModules.RNRadar.getUserId();
68 |
69 | const setDescription = (description: string): void => {
70 | NativeModules.RNRadar.setDescription(description);
71 | };
72 |
73 | const getDescription = (): Promise =>
74 | NativeModules.RNRadar.getDescription();
75 |
76 | const setMetadata = (metadata: RadarMetadata): void => {
77 | NativeModules.RNRadar.setMetadata(metadata);
78 | };
79 |
80 | const getMetadata = (): Promise =>
81 | NativeModules.RNRadar.getMetadata();
82 |
83 | const setAnonymousTrackingEnabled = (enabled: boolean): void =>
84 | NativeModules.RNRadar.setAnonymousTrackingEnabled(enabled);
85 |
86 | const getPermissionsStatus = (): Promise =>
87 | NativeModules.RNRadar.getPermissionsStatus();
88 |
89 | const requestPermissions = (
90 | background: boolean
91 | ): Promise =>
92 | NativeModules.RNRadar.requestPermissions(background);
93 |
94 | const getLocation = (
95 | desiredAccuracy?: RadarTrackingOptionsDesiredAccuracy
96 | ): Promise =>
97 | NativeModules.RNRadar.getLocation(desiredAccuracy);
98 |
99 | const trackOnce = (
100 | options?: RadarTrackOnceOptions | Location
101 | ): Promise => {
102 | let backCompatibleOptions = options;
103 | if (options && "latitude" in options) {
104 | backCompatibleOptions = {
105 | location: {
106 | ...options,
107 | },
108 | };
109 | }
110 | return NativeModules.RNRadar.trackOnce(backCompatibleOptions);
111 | };
112 |
113 | const trackVerified = (
114 | options?: RadarTrackVerifiedOptions
115 | ): Promise =>
116 | NativeModules.RNRadar.trackVerified(options);
117 |
118 | const getVerifiedLocationToken = (): Promise =>
119 | NativeModules.RNRadar.getVerifiedLocationToken();
120 |
121 | const clearVerifiedLocationToken = (): void =>
122 | NativeModules.RNRadar.clearVerifiedLocationToken();
123 |
124 | const startTrackingEfficient = (): void =>
125 | NativeModules.RNRadar.startTrackingEfficient();
126 |
127 | const startTrackingResponsive = (): void =>
128 | NativeModules.RNRadar.startTrackingResponsive();
129 |
130 | const startTrackingContinuous = (): void =>
131 | NativeModules.RNRadar.startTrackingContinuous();
132 |
133 | const startTrackingCustom = (options: RadarTrackingOptions): void =>
134 | NativeModules.RNRadar.startTrackingCustom(options);
135 |
136 | const startTrackingVerified = (options?: RadarVerifiedTrackingOptions): void =>
137 | NativeModules.RNRadar.startTrackingVerified(options);
138 |
139 | const mockTracking = (options: RadarMockTrackingOptions): void =>
140 | NativeModules.RNRadar.mockTracking(options);
141 |
142 | const stopTracking = (): void => NativeModules.RNRadar.stopTracking();
143 |
144 | const stopTrackingVerified = (): void =>
145 | NativeModules.RNRadar.stopTrackingVerified();
146 |
147 | const isTracking = (): Promise => NativeModules.RNRadar.isTracking();
148 |
149 | const isTrackingVerified = (): Promise =>
150 | NativeModules.RNRadar.isTrackingVerified();
151 |
152 | const setProduct = (product: string): void =>
153 | NativeModules.RNRadar.setProduct(product);
154 |
155 | const getTrackingOptions = (): Promise =>
156 | NativeModules.RNRadar.getTrackingOptions();
157 |
158 | const isUsingRemoteTrackingOptions = (): Promise =>
159 | NativeModules.RNRadar.isUsingRemoteTrackingOptions();
160 |
161 | const setForegroundServiceOptions = (
162 | options: RadarTrackingOptionsForegroundService
163 | ): void => NativeModules.RNRadar.setForegroundServiceOptions(options);
164 |
165 | const setNotificationOptions = (options: RadarNotificationOptions): void =>
166 | NativeModules.RNRadar.setNotificationOptions(options);
167 |
168 | const getTripOptions = (): Promise =>
169 | NativeModules.RNRadar.getTripOptions();
170 |
171 | const startTrip = (
172 | options: RadarStartTripOptions
173 | ): Promise => NativeModules.RNRadar.startTrip(options);
174 |
175 | const completeTrip = (): Promise =>
176 | NativeModules.RNRadar.completeTrip();
177 |
178 | const cancelTrip = (): Promise =>
179 | NativeModules.RNRadar.cancelTrip();
180 |
181 | const updateTrip = (
182 | options: RadarUpdateTripOptions
183 | ): Promise => NativeModules.RNRadar.updateTrip(options);
184 |
185 | const acceptEvent = (eventId: string, verifiedPlaceId: string): void =>
186 | NativeModules.RNRadar.acceptEvent(eventId, verifiedPlaceId);
187 |
188 | const rejectEvent = (eventId: string): void =>
189 | NativeModules.RNRadar.rejectEvent(eventId);
190 |
191 | const getContext = (location?: Location): Promise =>
192 | NativeModules.RNRadar.getContext(location);
193 |
194 | const searchPlaces = (
195 | options: RadarSearchPlacesOptions
196 | ): Promise =>
197 | NativeModules.RNRadar.searchPlaces(options);
198 |
199 | const searchGeofences = (
200 | options: RadarSearchGeofencesOptions
201 | ): Promise =>
202 | NativeModules.RNRadar.searchGeofences(options);
203 |
204 | const autocomplete = (
205 | options: RadarAutocompleteOptions
206 | ): Promise => NativeModules.RNRadar.autocomplete(options);
207 |
208 | const geocode = (options: RadarGeocodeOptions): Promise =>
209 | NativeModules.RNRadar.geocode(options);
210 |
211 | const reverseGeocode = (
212 | options?: RadarReverseGeocodeOptions
213 | ): Promise =>
214 | NativeModules.RNRadar.reverseGeocode(options);
215 |
216 | const ipGeocode = (): Promise =>
217 | NativeModules.RNRadar.ipGeocode();
218 |
219 | const validateAddress = (address: RadarAddress): Promise =>
220 | NativeModules.RNRadar.validateAddress(address);
221 |
222 | const getDistance = (
223 | options: RadarGetDistanceOptions
224 | ): Promise => NativeModules.RNRadar.getDistance(options);
225 |
226 | const getMatrix = (options: RadarGetMatrixOptions): Promise =>
227 | NativeModules.RNRadar.getMatrix(options);
228 |
229 | const logConversion = (
230 | options: RadarLogConversionOptions
231 | ): Promise =>
232 | NativeModules.RNRadar.logConversion(options);
233 |
234 | const sendEvent = (name: string, metadata: RadarMetadata): void =>
235 | NativeModules.RNRadar.sendEvent(name, metadata);
236 |
237 | const on = (
238 | channel: RadarEventChannel,
239 | callback: RadarListenerCallback
240 | ): EmitterSubscription => eventEmitter.addListener(channel, callback);
241 |
242 | const off = (
243 | channel: RadarEventChannel,
244 | callback?: Function | undefined
245 | ): void => {
246 | if (callback) {
247 | // @ts-ignore
248 | eventEmitter.removeListener(channel, callback);
249 | } else {
250 | eventEmitter.removeAllListeners(channel);
251 | }
252 | };
253 |
254 | const nativeSdkVersion = (): Promise =>
255 | NativeModules.RNRadar.nativeSdkVersion();
256 |
257 | const rnSdkVersion = (): string => version;
258 |
259 | const Radar: RadarNativeInterface = {
260 | initialize,
261 | setLogLevel,
262 | setUserId,
263 | getUserId,
264 | setDescription,
265 | getDescription,
266 | setMetadata,
267 | getMetadata,
268 | setAnonymousTrackingEnabled,
269 | getPermissionsStatus,
270 | requestPermissions,
271 | getLocation,
272 | trackOnce,
273 | trackVerified,
274 | isTrackingVerified,
275 | setProduct,
276 | getVerifiedLocationToken,
277 | clearVerifiedLocationToken,
278 | startTrackingEfficient,
279 | startTrackingResponsive,
280 | startTrackingContinuous,
281 | startTrackingCustom,
282 | startTrackingVerified,
283 | mockTracking,
284 | stopTracking,
285 | stopTrackingVerified,
286 | isTracking,
287 | getTrackingOptions,
288 | isUsingRemoteTrackingOptions,
289 | setForegroundServiceOptions,
290 | setNotificationOptions,
291 | getTripOptions,
292 | startTrip,
293 | completeTrip,
294 | cancelTrip,
295 | updateTrip,
296 | acceptEvent,
297 | rejectEvent,
298 | getContext,
299 | searchPlaces,
300 | searchGeofences,
301 | autocomplete,
302 | geocode,
303 | reverseGeocode,
304 | ipGeocode,
305 | validateAddress,
306 | getDistance,
307 | getMatrix,
308 | logConversion,
309 | sendEvent,
310 | on,
311 | off,
312 | nativeSdkVersion,
313 | rnSdkVersion,
314 | };
315 |
316 | export default Radar;
317 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import { RadarNativeInterface } from "./@types/RadarNativeInterface";
2 | import { Platform } from "react-native";
3 |
4 | let nativeModule: RadarNativeInterface;
5 |
6 | nativeModule = Platform.OS === "web" ? require("./index.web").default : require("./index.native").default;
7 |
8 | export default nativeModule;
9 |
10 | let RadarRNWeb = Platform.OS === "web" ? require("./index.web").default : {};
11 |
12 | export { RadarRNWeb };
13 |
14 | let Autocomplete =
15 | Platform.OS !== "web" ? require("./ui/autocomplete").default : {};
16 | export { Autocomplete };
17 |
18 | let Map = Platform.OS !== "web" ? require("./ui/map").default : {};
19 | export { Map };
20 |
21 | export * from "./@types/types";
22 | export * from "./@types/RadarNativeInterface";
23 |
--------------------------------------------------------------------------------
/src/index.web.js:
--------------------------------------------------------------------------------
1 | import RadarJS from 'radar-sdk-js';
2 | import { version } from "../package.json";
3 |
4 | let throws = false;
5 | const throwOnUnimplemented = (value) => {
6 | throws = value
7 | }
8 |
9 | const initialize = (publishableKey) => {
10 | RadarJS.initialize(publishableKey);
11 | }
12 |
13 | const setLogLevel = (level) => {
14 | if (throws) throw new Error("setLogLevel() is not implemented on web");
15 | };
16 |
17 | const setUserId = (userId) => {
18 | RadarJS.setUserId(userId);
19 | };
20 |
21 | const getUserId = () => {
22 | if (throws) throw new Error("getUserId() is not implemented on web");
23 | return new Promise((resolve, reject) => { reject("getUserId() is not implemented on web") });
24 | }
25 |
26 | const setDeviceId = (deviceId, installId) => {
27 | RadarJS.setDeviceId(deviceId, installId);
28 | }
29 | const setDeviceType = (deviceType) => {
30 | RadarJS.setDeviceType(deviceType);
31 | }
32 |
33 | const setRequestHeaders = (headers) => {
34 | RadarJS.setRequestHeaders(headers);
35 | }
36 |
37 | const setDescription = (description) => {
38 | RadarJS.setDescription(description);
39 | };
40 |
41 | const getDescription = () => {
42 | if (throws) throw new Error("getDescription() is not implemented on web");
43 | return new Promise((resolve, reject) => { reject("getDescription() is not implemented on web") });
44 | }
45 |
46 | const setMetadata = (metadata) => {
47 | RadarJS.setMetadata(metadata);
48 | };
49 |
50 | const getMetadata = () => {
51 | if (throws) throw new Error("getMetadata() is not implemented on web");
52 | return new Promise((resolve, reject) => { reject("getMetadata() is not implemented on web") });
53 | }
54 |
55 | const setAnonymousTrackingEnabled = () => {
56 | if (throws) throw new Error("setAnonymousTrackingEnabled() is not implemented on web");
57 | }
58 |
59 | const getPermissionsStatus = () => {
60 | return new Promise(resolve => {
61 | const navigator = window.navigator;
62 |
63 | if (!navigator.permissions) {
64 | resolve({
65 | status: 'UNKNOWN'
66 | });
67 | } else {
68 | navigator.permissions.query({ name: 'geolocation' }).then((result) => {
69 | resolve({
70 | status: result.state === 'granted' ? 'GRANTED_FOREGROUND' : 'DENIED',
71 | });
72 | });
73 | }
74 | });
75 | };
76 |
77 | const requestPermissions = (background) => {
78 | if (throws) throw new Error("requestPermissions() is not implemented on web");
79 | return new Promise((resolve, reject) => { reject("requestPermissions() is not implemented on web") });
80 | };
81 |
82 | const getLocation = () => {
83 | return new Promise((resolve, reject) => {
84 | RadarJS.getLocation((err, result) => {
85 | if (err)
86 | reject(err);
87 | else
88 | resolve(result);
89 | })
90 | });
91 | };
92 |
93 | const trackOnce = (options) => {
94 | return new Promise((resolve, reject) => {
95 | const callback = (err, { status, location, user, events }) => {
96 | if (err) {
97 | reject(err);
98 | } else {
99 | resolve({
100 | status,
101 | location,
102 | user,
103 | events,
104 | });
105 | }
106 | };
107 |
108 | if (options) {
109 | RadarJS.trackOnce(options.location ? options.location : options, callback);
110 | } else {
111 | RadarJS.trackOnce(callback);
112 | }
113 | });
114 | };
115 |
116 | const trackVerified = () => {
117 | if (throws) throw new Error("trackVerified() is not implemented on web");
118 | return new Promise((resolve, reject) => { reject("trackVerified() is not implemented on web") });
119 | };
120 |
121 | const getVerifiedLocationToken = () => {
122 | if (throws) throw new Error("getVerifiedLocationToken() is not implemented on web");
123 | return new Promise((resolve, reject) => { reject("getVerifiedLocationToken() is not implemented on web") });
124 | };
125 |
126 | const startTrackingEfficient = () => {
127 | if (throws) throw new Error("startTrackingEfficient() is not implemented on web");
128 | };
129 |
130 | const startTrackingResponsive = () => {
131 | if (throws) throw new Error("startTrackingResponsive() is not implemented on web");
132 | };
133 |
134 | const startTrackingContinuous = () => {
135 | if (throws) throw new Error("startTrackingContinuous() is not implemented on web");
136 | };
137 |
138 | const startTrackingCustom = (options) => {
139 | if (throws) throw new Error("startTrackingCustom() is not implemented on web");
140 | };
141 |
142 | const startTrackingVerified = (options) => {
143 | if (throws) throw new Error("startTrackingVerified() is not implemented on web");
144 | }
145 |
146 | const mockTracking = (options) => {
147 | if (throws) throw new Error("mockTracking() is not implemented on web");
148 | };
149 |
150 | const stopTracking = () => {
151 | if (throws) throw new Error("stopTracking() is not implemented on web");
152 | };
153 |
154 | const stopTrackingVerified = () => {
155 | if (throws) throw new Error("stopTrackingVerified() is not implemented on web");
156 | }
157 |
158 | const isTracking = () => {
159 | if (throws) throw new Error("isTracking() is not implemented on web");
160 | return new Promise((resolve, reject) => { reject("isTracking() is not implemented on web") });
161 | }
162 |
163 | const getTrackingOptions = () => {
164 | if (throws) throw new Error("getTrackingOptions() is not implemented on web");
165 | return new Promise((resolve, reject) => { reject("getTrackingOptions() is not implemented on web") });
166 | }
167 |
168 | const isUsingRemoteTrackingOptions = () => {
169 | if (throws) throw new Error("isUsingRemoteTrackingOptions() is not implemented on web");
170 | return new Promise((resolve, reject) => { reject("isUsingRemoteTrackingOptions() is not implemented on web") });
171 | }
172 |
173 | const setForegroundServiceOptions = (options) => {
174 | if (throws) throw new Error("setForegroundServiceOptions() is not implemented on web");
175 | };
176 |
177 | const setNotificationOptions = (options) => {
178 | if (throws) throw new Error("setNotificationOptions() is not implemented on web");
179 | }
180 |
181 | const getTripOptions = () => {
182 | if (throws) throw new Error("getTripOptions() is not implemented on web");
183 | return new Promise((resolve, reject) => { reject("getTripOptions() is not implemented on web") });
184 | }
185 |
186 | const startTrip = (options) => {
187 | if (options.tripOptions) {
188 | options = options.tripOptions;
189 | }
190 | console.log(options)
191 | return new Promise((resolve, reject) => {
192 | const callback = (err, { trip, events, status }) => {
193 | if (err) {
194 | reject(err);
195 | } else {
196 | resolve({
197 | trip,
198 | events,
199 | status
200 | });
201 | }
202 | };
203 |
204 | RadarJS.startTrip(options, callback);
205 | });
206 | };
207 |
208 | const completeTrip = () => {
209 | return new Promise((resolve, reject) => {
210 | const callback = (err, { trip, events, status }) => {
211 | if (err) {
212 | reject(err);
213 | } else {
214 | resolve({
215 | trip,
216 | events,
217 | status
218 | });
219 | }
220 | };
221 |
222 | RadarJS.completeTrip(callback);
223 | });
224 | };
225 |
226 | const cancelTrip = () => {
227 | return new Promise((resolve, reject) => {
228 | const callback = (err, { trip, events, status }) => {
229 | if (err) {
230 | reject(err);
231 | } else {
232 | resolve({
233 | trip,
234 | events,
235 | status
236 | });
237 | }
238 | };
239 |
240 | RadarJS.cancelTrip(callback);
241 | });
242 | };
243 |
244 | const updateTrip = (tripOptions) => {
245 | return new Promise((resolve, reject) => {
246 | const callback = (err, { trip, events, status }) => {
247 | if (err) {
248 | reject(err);
249 | } else {
250 | resolve({
251 | trip,
252 | events,
253 | status
254 | });
255 | }
256 | };
257 |
258 | RadarJS.updateTrip(tripOptions.options, tripOptions.status, callback);
259 | });
260 | };
261 |
262 | const acceptEvent = (eventId, verifiedPlaceId) => {
263 | if (throws) throw new Error("acceptEvent() is not implemented on web");
264 | };
265 |
266 | const rejectEvent = (eventId) => {
267 | if (throws) throw new Error("rejectEvent() is not implemented on web");
268 | };
269 |
270 | const getContext = (options) => {
271 | return new Promise((resolve, reject) => {
272 | const callback = (err, { status, location, context }) => {
273 | if (err) {
274 | reject(err);
275 | } else {
276 | resolve({
277 | status,
278 | location,
279 | context,
280 | });
281 | }
282 | };
283 |
284 | if (options) {
285 | RadarJS.getContext(options, callback);
286 | } else {
287 | RadarJS.getContext(callback);
288 | }
289 | });
290 | };
291 |
292 | const searchPlaces = (options) => {
293 | return new Promise((resolve, reject) => {
294 | RadarJS.searchPlaces(options, (err, { status, location, places }) => {
295 | if (err) {
296 | reject(err);
297 | } else {
298 | resolve({
299 | status,
300 | location,
301 | places,
302 | });
303 | }
304 | });
305 | });
306 | };
307 |
308 | const searchGeofences = (options) => {
309 | return new Promise((resolve, reject) => {
310 | RadarJS.searchGeofences(options, (err, { status, location, geofences }) => {
311 | if (err) {
312 | reject(err);
313 | } else {
314 | resolve({
315 | status,
316 | location,
317 | geofences,
318 | });
319 | }
320 | });
321 | });
322 | };
323 |
324 | const autocomplete = (options) => {
325 | return new Promise((resolve, reject) => {
326 | RadarJS.autocomplete(options, (err, { status, addresses }) => {
327 | if (err) {
328 | reject(err);
329 | } else {
330 | resolve({
331 | status,
332 | addresses,
333 | });
334 | }
335 | });
336 | });
337 | };
338 |
339 | const geocode = (options) => {
340 | return new Promise((resolve, reject) => {
341 | let newOptions = options;
342 | if (typeof options === 'string') {
343 | newOptions = {
344 | query: options
345 | };
346 | } else if (options.address) {
347 | newOptions.query = options.address;
348 | }
349 | RadarJS.geocode(newOptions, (err, { status, addresses }) => {
350 | if (err) {
351 | reject(err);
352 | } else {
353 | resolve({
354 | status,
355 | addresses,
356 | });
357 | }
358 | });
359 | });
360 | };
361 |
362 | const reverseGeocode = (options) => {
363 | return new Promise((resolve, reject) => {
364 | const callback = (err, { status, addresses }) => {
365 | if (err) {
366 | reject(err);
367 | } else {
368 | resolve({
369 | status,
370 | addresses,
371 | });
372 | }
373 | };
374 |
375 | if (options) {
376 | RadarJS.reverseGeocode(options, callback);
377 | } else {
378 | RadarJS.reverseGeocode(callback);
379 | }
380 | });
381 | };
382 |
383 | const ipGeocode = () => {
384 | return new Promise((resolve, reject) => {
385 | RadarJS.ipGeocode((err, { status, address }) => {
386 | if (err) {
387 | reject(err);
388 | } else {
389 | resolve({
390 | status,
391 | address,
392 | });
393 | }
394 | });
395 | });
396 | };
397 |
398 | const validateAddress = (options) => {
399 | return new Promise((resolve, reject) => {
400 | RadarJS.validateAddress(options, (err, { status, address }) => {
401 | if (err) {
402 | reject(err);
403 | } else {
404 | resolve({
405 | status,
406 | address
407 | })
408 | }
409 | });
410 | })
411 | };
412 |
413 | const getDistance = (options) => {
414 | return new Promise((resolve, reject) => {
415 | RadarJS.getDistance(options, (err, { status, routes }) => {
416 | if (err) {
417 | reject(err);
418 | } else {
419 | resolve({
420 | status,
421 | routes,
422 | });
423 | }
424 | });
425 | });
426 | };
427 |
428 | const getMatrix = (options) => {
429 | return new Promise((resolve, reject) => {
430 | RadarJS.getMatrix(options, (err, { origins, destinations, matrix, status }) => {
431 | if (err) {
432 | reject(err);
433 | } else {
434 | resolve({
435 | origins,
436 | destinations,
437 | matrix,
438 | status,
439 | });
440 | }
441 | });
442 | });
443 | };
444 |
445 | const logConversion = (options) => {
446 | if (throws) throw new Error("logConversion() is not implemented on web");
447 | return new Promise((resolve, reject) => { reject("logConversion() is not implemented on web") });
448 | }
449 |
450 | const sendEvent = (name, metadata) => {
451 | if (throws) throw new Error("sendEvent() is not implemented on web");
452 | }
453 |
454 | const on = (event, callback) => {
455 | if (throws) throw new Error("on() is not implemented on web");
456 | };
457 |
458 | const off = (event, callback) => {
459 | if (throws) throw new Error("off() is not implemented on web");
460 | };
461 |
462 | const nativeSdkVersion = () => {
463 | return new Promise((resolve, reject) => { resolve(RadarJS.VERSION) });
464 | }
465 |
466 | const rnSdkVersion = () => version;
467 |
468 | const Radar = {
469 | initialize,
470 | setLogLevel,
471 | setUserId,
472 | getUserId,
473 | setDescription,
474 | getDescription,
475 | setMetadata,
476 | getMetadata,
477 | setAnonymousTrackingEnabled,
478 | getPermissionsStatus,
479 | requestPermissions,
480 | getLocation,
481 | trackOnce,
482 | trackVerified,
483 | getVerifiedLocationToken,
484 | startTrackingEfficient,
485 | startTrackingResponsive,
486 | startTrackingContinuous,
487 | startTrackingCustom,
488 | startTrackingVerified,
489 | mockTracking,
490 | stopTracking,
491 | stopTrackingVerified,
492 | isTracking,
493 | getTrackingOptions,
494 | isUsingRemoteTrackingOptions,
495 | setForegroundServiceOptions,
496 | setNotificationOptions,
497 | getTripOptions,
498 | startTrip,
499 | completeTrip,
500 | cancelTrip,
501 | updateTrip,
502 | acceptEvent,
503 | rejectEvent,
504 | getContext,
505 | searchPlaces,
506 | searchGeofences,
507 | autocomplete,
508 | geocode,
509 | reverseGeocode,
510 | ipGeocode,
511 | validateAddress,
512 | getDistance,
513 | getMatrix,
514 | logConversion,
515 | sendEvent,
516 | on,
517 | off,
518 | nativeSdkVersion,
519 | rnSdkVersion,
520 |
521 | // only for web, these should be called via RadarRNWeb instead of Radar for typing
522 | throwOnUnimplemented,
523 | setDeviceId,
524 | setDeviceType,
525 | setRequestHeaders,
526 | };
527 |
528 | export default Radar;
--------------------------------------------------------------------------------
/src/ui/autocomplete.jsx:
--------------------------------------------------------------------------------
1 | // Autocomplete.js
2 | import React, { useState, useCallback, useRef, useEffect } from 'react';
3 | import {
4 | View,
5 | TextInput,
6 | FlatList,
7 | TouchableOpacity,
8 | Text,
9 | StyleSheet,
10 | Image,
11 | Modal,
12 | KeyboardAvoidingView,
13 | Animated,
14 | Dimensions,
15 | Easing,
16 | Keyboard,
17 | SafeAreaView,
18 | Pressable,
19 | Platform,
20 | } from 'react-native';
21 | import Radar from '../index.native';
22 | import {
23 | BACK_ICON,
24 | SEARCH_ICON,
25 | RADAR_LOGO,
26 | MARKER_ICON,
27 | CLOSE_ICON,
28 | } from "./images";
29 | import { default as defaultStyles } from './styles';
30 |
31 | const defaultAutocompleteOptions = {
32 | debounceMS: 200, // Debounce time in milliseconds
33 | minCharacters: 3, // Minimum number of characters to trigger autocomplete
34 | limit: 8, // Maximum number of results to return
35 | placeholder: "Search address", // Placeholder text for the input field
36 | showMarkers: true,
37 | disabled: false,
38 | };
39 |
40 | const autocompleteUI = ({ options = {} }) => {
41 | const [query, setQuery] = useState("");
42 | const [results, setResults] = useState([]);
43 | const [isOpen, setIsOpen] = useState(false);
44 | const animationValue = useRef(new Animated.Value(0)).current; // animation value
45 | const timerRef = useRef(null);
46 | const textInputRef = useRef(null);
47 |
48 |
49 | const config = { ...defaultAutocompleteOptions, ...options };
50 | const style = config.style || {};
51 |
52 | const fetchResults = useCallback(
53 | async (searchQuery) => {
54 | if (searchQuery.length < config.minCharacters) return;
55 |
56 | const { limit, layers, countryCode } = config;
57 | const params = { query: searchQuery, limit, layers, countryCode };
58 |
59 | if (config.near && config.near.latitude && config.near.longitude) {
60 | params.near = config.near;
61 | }
62 |
63 | try {
64 | const result = await Radar.autocomplete(params);
65 |
66 | if (config.onResults && typeof config.onResults === "function") {
67 | config.onResults(result.addresses);
68 | }
69 |
70 | setResults(result.addresses);
71 | setIsOpen(true);
72 | } catch (error) {
73 | if (config.onError && typeof config.onError === "function") {
74 | config.onError(error);
75 | }
76 | }
77 | },
78 | [config]
79 | );
80 |
81 | const handleInput = useCallback(
82 | (text) => {
83 | setQuery(text);
84 |
85 | // Clear the existing timer
86 | if (timerRef.current) {
87 | clearTimeout(timerRef.current);
88 | }
89 |
90 | if (text.length < config.minCharacters) {
91 | return;
92 | }
93 |
94 | // Set the new timer
95 | timerRef.current = setTimeout(() => {
96 | fetchResults(text);
97 | }, config.debounceMS);
98 | },
99 | [config, fetchResults]
100 | );
101 |
102 | const handleSelect = (item) => {
103 | setQuery(item.formattedAddress);
104 | setIsOpen(false);
105 |
106 | if (typeof config.onSelection === "function") {
107 | config.onSelection(item);
108 | }
109 | };
110 |
111 | const renderFooter = () => {
112 | if (results.length === 0) return null;
113 |
114 | return (
115 |
116 |
117 | Powered by
118 |
123 |
124 |
125 | );
126 | };
127 |
128 | const renderItem = ({ item }) => (
129 | [
131 | {
132 | ...styles.resultItem,
133 | backgroundColor: pressed
134 | ? styles.resultItem.pressedBackgroundColor
135 | : styles.resultItem.backgroundColor,
136 | },
137 | ]}
138 | onPress={() => handleSelect(item)}
139 | >
140 |
141 |
142 | {config.showMarkers ? (
143 |
144 | ) : null}
145 |
146 |
147 |
148 | {item.addressLabel || item?.placeLabel}
149 |
150 | {item?.formattedAddress.length > 0 && (
151 |
152 | {item?.formattedAddress?.replace(
153 | `${item?.addressLabel || item?.placeLabel}, `,
154 | ""
155 | )}
156 |
157 | )}
158 |
159 |
160 |
161 | );
162 |
163 | const styles = {
164 | ...defaultStyles,
165 | container: StyleSheet.compose(defaultStyles.container, style.container),
166 | input: StyleSheet.compose(defaultStyles.input, style.input),
167 | inputContainer: StyleSheet.compose(
168 | defaultStyles.inputContainer,
169 | style.inputContainer
170 | ),
171 | modalInputContainer: StyleSheet.compose(
172 | defaultStyles.modalInputContainer,
173 | style.modalInputContainer
174 | ),
175 | resultList: StyleSheet.compose(defaultStyles.resultList, style.resultList),
176 | resultItem: StyleSheet.compose({...defaultStyles.resultItem, pressedBackgroundColor: '#F6FAFC'}, style.resultItem),
177 | addressContainer: StyleSheet.compose(
178 | defaultStyles.addressContainer,
179 | style.addressContainer
180 | ),
181 | pinIconContainer: StyleSheet.compose(
182 | defaultStyles.pinIconContainer,
183 | style.pinIconContainer
184 | ),
185 | pinIcon: StyleSheet.compose(defaultStyles.pinIcon, style.pinIcon),
186 | addressTextContainer: StyleSheet.compose(
187 | defaultStyles.addressTextContainer,
188 | style.addressTextContainer
189 | ),
190 | addressText: StyleSheet.compose(
191 | defaultStyles.addressText,
192 | style.addressText
193 | ),
194 | addressSubtext: StyleSheet.compose(
195 | defaultStyles.addressSubtext,
196 | style.addressSubtext
197 | ),
198 | footerContainer: StyleSheet.compose(
199 | defaultStyles.footerContainer,
200 | style.footerContainer
201 | ),
202 | footerText: StyleSheet.compose(defaultStyles.footerText, style.footerText),
203 | };
204 |
205 | useEffect(() => {
206 | Animated.timing(animationValue, {
207 | toValue: isOpen ? 1 : 0,
208 | duration: 300,
209 | easing: Easing.inOut(Easing.ease),
210 | useNativeDriver: false,
211 | }).start();
212 | }, [isOpen]);
213 |
214 | const screenHeight = Dimensions.get("window").height;
215 |
216 | const inputHeight = animationValue.interpolate({
217 | inputRange: [0, 1],
218 | outputRange: [40, screenHeight],
219 | });
220 |
221 | const modalOpacity = animationValue.interpolate({
222 | inputRange: [0, 0.5, 1],
223 | outputRange: [0, 0, 1],
224 | });
225 |
226 | return (
227 |
228 |
229 | {
232 | if (config.disabled) return;
233 |
234 | setIsOpen(true);
235 | // Set the focus on the other textinput after it opens
236 | setTimeout(() => {
237 | textInputRef.current.focus();
238 | }, 100);
239 | }}
240 | >
241 |
242 | {
245 | setIsOpen(true);
246 | setTimeout(() => {
247 | textInputRef.current.focus();
248 | }, 100);
249 | }}
250 | value={query}
251 | returnKeyType="done"
252 | placeholder={config.placeholder}
253 | placeholderTextColor="#acbdc8"
254 | />
255 |
256 |
257 | setIsOpen(false)}
262 | >
263 |
264 |
265 |
270 |
271 | {
273 | setIsOpen(false);
274 | }}
275 | >
276 |
277 |
278 | {
286 | setIsOpen(false);
287 | }}
288 | placeholderTextColor="#acbdc8"
289 | />
290 | {
292 | setQuery("");
293 | }}
294 | >
295 |
296 |
297 |
298 | {results.length > 0 && (
299 |
300 | {
304 | textInputRef.current.blur();
305 | Keyboard.dismiss();
306 | }}
307 | keyboardShouldPersistTaps="handled"
308 | renderItem={renderItem}
309 | keyExtractor={(item) =>
310 | item.formattedAddress + item.postalCode
311 | }
312 | />
313 | {renderFooter()}
314 |
315 | )}
316 |
317 |
318 |
319 |
320 |
321 | );
322 | };
323 |
324 | export default autocompleteUI;
325 |
--------------------------------------------------------------------------------
/src/ui/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/src/ui/back.png
--------------------------------------------------------------------------------
/src/ui/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/src/ui/close.png
--------------------------------------------------------------------------------
/src/ui/images.js:
--------------------------------------------------------------------------------
1 | export const BACK_ICON = require('./back.png');
2 | export const SEARCH_ICON = require('./search.png');
3 | export const RADAR_LOGO = require('./radar-logo.png');
4 | export const MARKER_ICON = require('./marker.png');
5 | export const CLOSE_ICON = require('./close.png');
6 |
--------------------------------------------------------------------------------
/src/ui/map-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/src/ui/map-logo.png
--------------------------------------------------------------------------------
/src/ui/map.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react';
2 | import { View, Image } from 'react-native';
3 | import Radar from '../index.native';
4 | import { getHost, getPublishableKey } from '../helpers';
5 | import styles from './styles';
6 |
7 | let MapLibreGL;
8 | try {
9 | MapLibreGL = require('@maplibre/maplibre-react-native');
10 | } catch (e) {
11 | MapLibreGL = null;
12 | }
13 |
14 | const DEFAULT_STYLE = 'radar-default-v1';
15 |
16 | const createStyleURL = async (style = DEFAULT_STYLE) => {
17 | const host = await getHost();
18 | const publishableKey = await getPublishableKey();
19 | return `${host}/maps/styles/${style}?publishableKey=${publishableKey}`;
20 | };
21 |
22 | const RadarMap = ({ mapOptions, children }) => {
23 | const [styleURL, setStyleURL] = useState(null);
24 | const [userLocation, setUserLocation] = useState(null);
25 |
26 | useEffect(() => {
27 | createStyleURL(mapOptions?.mapStyle || DEFAULT_STYLE).then((result) => {
28 | setStyleURL(result);
29 | });
30 | }, [mapOptions]);
31 |
32 | useEffect(() => {
33 | Radar.getLocation().then((result) => {
34 | if (result?.location?.latitude && result?.location?.longitude) {
35 | setUserLocation({
36 | latitude: result.location.latitude,
37 | longitude: result.location.longitude,
38 | });
39 | }
40 | }).catch((err) => {
41 | // eslint-disable-next-line no-console
42 | console.warn(`Radar SDK: Failed to get location: ${err}`);
43 | });
44 | }, [mapOptions]);
45 |
46 | if (!styleURL) {
47 | return null;
48 | }
49 |
50 | if (!MapLibreGL) {
51 | return null;
52 | }
53 |
54 | const geoJSONUserLocation = {
55 | type: 'FeatureCollection',
56 | features: userLocation?.longitude !== undefined ? [
57 | {
58 | type: 'Feature',
59 | geometry: {
60 | type: 'Point',
61 | coordinates: [userLocation.longitude, userLocation.latitude],
62 | },
63 | },
64 | ] : [],
65 | };
66 |
67 | const userLocationMapIndicator = (
68 |
72 |
81 |
89 |
97 |
98 | );
99 |
100 | return (
101 |
102 |
111 | {userLocationMapIndicator}
112 | {children}
113 |
114 |
118 |
119 | );
120 | };
121 |
122 | export default RadarMap;
123 |
--------------------------------------------------------------------------------
/src/ui/marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/src/ui/marker.png
--------------------------------------------------------------------------------
/src/ui/radar-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/src/ui/radar-logo.png
--------------------------------------------------------------------------------
/src/ui/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radarlabs/react-native-radar/cda65630b4b834233dda40c768c470325c171463/src/ui/search.png
--------------------------------------------------------------------------------
/src/ui/styles.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet } from 'react-native';
2 |
3 | const styles = StyleSheet.create({
4 | container: {
5 | width: '100%',
6 | height: '100%',
7 | alignItems: 'center',
8 | paddingTop: 8,
9 | },
10 | inputContainer: {
11 | flexDirection: 'row',
12 | alignItems: 'center',
13 | marginHorizontal: 16,
14 | backgroundColor: 'white',
15 | borderRadius: 5,
16 | borderColor: '#DBE5EB',
17 | borderWidth: 1,
18 | width: '95%', // only difference between this and the modalInputContainer
19 | },
20 | modalInputContainer: {
21 | flexDirection: 'row',
22 | alignItems: 'center',
23 | marginHorizontal: 16,
24 | backgroundColor: 'white',
25 | borderRadius: 5,
26 | borderColor: '#DBE5EB',
27 | borderWidth: 1,
28 | },
29 | inputIcon: {
30 | marginLeft: 10,
31 | height: 18,
32 | width: 18,
33 | backgroundColor: 'white',
34 | },
35 | closeIcon: {
36 | marginRight: 10,
37 | height: 18,
38 | width: 18,
39 | backgroundColor: 'white',
40 | },
41 | input: {
42 | flex: 1,
43 | backgroundColor: 'white',
44 | height: 40,
45 | fontSize: 14,
46 | paddingHorizontal: 8,
47 | borderRadius: 5,
48 | },
49 | resultListWrapper: {
50 | width: '100%',
51 | marginBottom: 30,
52 | backgroundColor: 'white',
53 | borderRadius: 5,
54 | paddingVertical: 8,
55 | },
56 | resultList: {
57 | width: '100%',
58 | },
59 | resultItem: {
60 | paddingRight: 16,
61 | paddingVertical: 8,
62 | paddingHorizontal: 16,
63 | fontSize: 12,
64 | backgroundColor: 'white',
65 | },
66 | addressContainer: {
67 | flexDirection: 'row',
68 | alignItems: 'center',
69 | },
70 | pinIconContainer: {
71 | width: 28,
72 | marginRight: 8,
73 | },
74 | pinIcon: {
75 | height: 26,
76 | width: 26,
77 | },
78 | addressTextContainer: {
79 | flex: 1,
80 | },
81 | addressText: {
82 | fontSize: 14,
83 | lineHeight: 24,
84 | color: '#000',
85 | fontWeight: '600',
86 | },
87 | addressSubtext: {
88 | fontSize: 14,
89 | color: '#5A6872',
90 | },
91 | footerContainer: {
92 | flexDirection: 'row',
93 | alignItems: 'center',
94 | paddingVertical: 10,
95 | marginRight: 16,
96 | alignSelf: 'flex-end',
97 | },
98 | footerText: {
99 | marginTop: 2,
100 | marginRight: 4,
101 | fontSize: 10,
102 | color: '#5A6872',
103 | },
104 | logo: {
105 | width: 50,
106 | height: 15,
107 | resizeMode: 'contain',
108 | },
109 | mapContainer: {
110 | flex: 1,
111 | },
112 | map: {
113 | flex: 1,
114 | },
115 | mapLogo: {
116 | position: 'absolute',
117 | bottom: -10,
118 | left: 5,
119 | width: 50,
120 | height: 50,
121 | resizeMode: 'contain',
122 | },
123 | });
124 |
125 | export default styles;
126 |
--------------------------------------------------------------------------------
/test/index.test.js:
--------------------------------------------------------------------------------
1 | // import { NativeEventEmitter, NativeModules } from 'react-native';
2 |
3 | // import Radar from '../src/index.native.ts';
4 |
5 | const NativeEventEmitter = require('react-native').NativeEventEmitter;
6 |
7 | const NativeModules = require('react-native').NativeModules;
8 |
9 | import Radar from '../src/index.native.ts';
10 |
11 | const mockModule = NativeModules.RNRadar;
12 | const mockEmitter = NativeEventEmitter.mock.results[0].value;
13 |
14 | describe('calls native implementation', () => {
15 | test('setLogLevel', () => {
16 | const level = 'debug';
17 | Radar.setLogLevel(level);
18 |
19 | expect(mockModule.setLogLevel).toHaveBeenCalledTimes(1);
20 | expect(mockModule.setLogLevel).toBeCalledWith(level);
21 | });
22 |
23 | test('setUserId', () => {
24 | const userId = 'userId';
25 | Radar.setUserId(userId);
26 |
27 | expect(mockModule.setUserId).toHaveBeenCalledTimes(1);
28 | expect(mockModule.setUserId).toBeCalledWith(userId);
29 | });
30 |
31 | test('setDescription', () => {
32 | const description = 'some user description';
33 | Radar.setDescription(description);
34 |
35 | expect(mockModule.setDescription).toHaveBeenCalledTimes(1);
36 | expect(mockModule.setDescription).toBeCalledWith(description);
37 | });
38 |
39 | test('setMetadata', () => {
40 | const metadata = {
41 | foo: 'bar',
42 | baz: true,
43 | qux: 1,
44 | };
45 | Radar.setMetadata(metadata);
46 |
47 | expect(mockModule.setMetadata).toHaveBeenCalledTimes(1);
48 | expect(mockModule.setMetadata).toBeCalledWith(metadata);
49 | });
50 |
51 | test('getPermissionsStatus', () => {
52 | Radar.getPermissionsStatus();
53 |
54 | expect(mockModule.getPermissionsStatus).toHaveBeenCalledTimes(1);
55 | });
56 |
57 | test('requestPermissions', () => {
58 | const background = true;
59 | Radar.requestPermissions(background);
60 |
61 | expect(mockModule.requestPermissions).toHaveBeenCalledTimes(1);
62 | expect(mockModule.requestPermissions).toBeCalledWith(background);
63 | });
64 |
65 | test('getLocation', () => {
66 | const desiredAccuracy = 'medium';
67 | Radar.getLocation(desiredAccuracy);
68 |
69 | expect(mockModule.getLocation).toHaveBeenCalledTimes(1);
70 | expect(mockModule.getLocation).toBeCalledWith(desiredAccuracy);
71 | });
72 |
73 | test('trackOnce', () => {
74 | Radar.trackOnce();
75 |
76 | expect(mockModule.trackOnce).toHaveBeenCalledTimes(1);
77 | });
78 |
79 | test('updateLocation', () => {
80 | const location = {
81 | location: {
82 | latitude: 40.783826,
83 | longitude: -73.975363,
84 | accuracy: 65,
85 | }
86 | };
87 | Radar.trackOnce(location);
88 |
89 | expect(mockModule.trackOnce).toHaveBeenCalledTimes(1);
90 | expect(mockModule.trackOnce).toBeCalledWith(location);
91 | });
92 |
93 | test('updateLocation with old format parameters', () => {
94 | const location = {
95 | latitude: 40.783826,
96 | longitude: -73.975363,
97 | accuracy: 65,
98 | };
99 | const expectedLocation = {
100 | location: {
101 | latitude: 40.783826,
102 | longitude: -73.975363,
103 | accuracy: 65,
104 | }
105 | }
106 | Radar.trackOnce(location);
107 |
108 | expect(mockModule.trackOnce).toHaveBeenCalledTimes(1);
109 | expect(mockModule.trackOnce).toBeCalledWith(expectedLocation);
110 | });
111 |
112 | test('startTrackingEfficient', () => {
113 | Radar.startTrackingEfficient();
114 |
115 | expect(mockModule.startTrackingEfficient).toHaveBeenCalledTimes(1);
116 | });
117 |
118 | test('startTrackingResponsive', () => {
119 | Radar.startTrackingResponsive();
120 |
121 | expect(mockModule.startTrackingResponsive).toHaveBeenCalledTimes(1);
122 | });
123 |
124 | test('startTrackingContinuous', () => {
125 | Radar.startTrackingContinuous();
126 |
127 | expect(mockModule.startTrackingContinuous).toHaveBeenCalledTimes(1);
128 | });
129 |
130 | test('startTrackingCustom', () => {
131 | const options = {
132 | desiredStoppedUpdateInterval: 0,
133 | desiredMovingUpdateInterval: 150,
134 | desiredSyncInterval: 140,
135 | desiredAccuracy: 'medium',
136 | stopDuration: 140,
137 | stopDistance: 70,
138 | sync: 'stopsAndExits',
139 | replay: 'stops',
140 | showBlueBar: false,
141 | useStoppedGeofence: true,
142 | stoppedGeofenceRadius: 200,
143 | useMovingGeofence: false,
144 | movingGeofenceRadius: 0,
145 | useVisits: true,
146 | useSignificantLocationChanges: true,
147 | };
148 | Radar.startTrackingCustom(options);
149 |
150 | expect(mockModule.startTrackingCustom).toHaveBeenCalledTimes(1);
151 | expect(mockModule.startTrackingCustom).toBeCalledWith(options);
152 | });
153 |
154 | test('mockTracking', () => {
155 | const options = {
156 | origin: {
157 | latitude: 40.78382,
158 | longitude: -73.97536,
159 | },
160 | destination: {
161 | latitude: 40.70390,
162 | longitude: -73.98670,
163 | },
164 | mode: 'car',
165 | steps: 10,
166 | interval: 1,
167 | };
168 | Radar.mockTracking(options);
169 |
170 | expect(mockModule.mockTracking).toHaveBeenCalledTimes(1);
171 | expect(mockModule.mockTracking).toBeCalledWith(options);
172 | });
173 |
174 | test('stopTracking', () => {
175 | Radar.stopTracking();
176 |
177 | expect(mockModule.stopTracking).toHaveBeenCalledTimes(1);
178 | });
179 |
180 | test('acceptEvent', () => {
181 | const eventId = 'eventId';
182 | const verifiedPlaceId = 'verifiedPlaceId';
183 | Radar.acceptEvent(eventId, verifiedPlaceId);
184 |
185 | expect(mockModule.acceptEvent).toHaveBeenCalledTimes(1);
186 | expect(mockModule.acceptEvent).toBeCalledWith(eventId, verifiedPlaceId);
187 | });
188 |
189 | test('rejectEvent', () => {
190 | const eventId = 'eventId';
191 | Radar.rejectEvent(eventId);
192 |
193 | expect(mockModule.rejectEvent).toHaveBeenCalledTimes(1);
194 | expect(mockModule.rejectEvent).toBeCalledWith(eventId);
195 | });
196 |
197 | test('startTrip legacy', () => {
198 | const options = {
199 | externalId: '299',
200 | destinationGeofenceTag: 'store',
201 | destinationGeofenceExternalId: '123',
202 | mode: 'car',
203 | scheduledArrivalAt: new Date('2022-10-10T12:20:30Z').getTime()
204 | };
205 | Radar.startTrip(options);
206 |
207 | expect(mockModule.startTrip).toHaveBeenCalledTimes(1);
208 | expect(mockModule.startTrip).toBeCalledWith(options);
209 | });
210 |
211 | test('startTrip with tripOptions', () => {
212 | const options = {
213 | tripOptions: {
214 | externalId: '299',
215 | destinationGeofenceTag: 'store',
216 | destinationGeofenceExternalId: '123',
217 | mode: 'car',
218 | scheduledArrivalAt: new Date('2022-10-10T12:20:30Z').getTime()
219 | }
220 | };
221 | Radar.startTrip(options);
222 |
223 | expect(mockModule.startTrip).toHaveBeenCalledTimes(1);
224 | expect(mockModule.startTrip).toBeCalledWith(options);
225 | });
226 |
227 | test('startTrip with trackingOptions', () => {
228 | const options = {
229 | tripOptions: {
230 | externalId: '299',
231 | destinationGeofenceTag: 'store',
232 | destinationGeofenceExternalId: '123',
233 | mode: 'car',
234 | scheduledArrivalAt: new Date('2022-10-10T12:20:30Z').getTime()
235 | },
236 | trackingOptions: {
237 | desiredStoppedUpdateInterval: 30,
238 | fastestStoppedUpdateInterval: 30,
239 | desiredMovingUpdateInterval: 30,
240 | fastestMovingUpdateInterval: 30,
241 | desiredSyncInterval: 20,
242 | desiredAccuracy: "high",
243 | stopDuration: 0,
244 | stopDistance: 0,
245 | replay: "none",
246 | sync: "all",
247 | showBlueBar: true,
248 | useStoppedGeofence: false,
249 | stoppedGeofenceRadius: 0,
250 | useMovingGeofence: false,
251 | movingGeofenceRadius: 0,
252 | syncGeofences: false,
253 | syncGeofencesLimit: 0,
254 | beacons: false,
255 | foregroundServiceEnabled: false
256 | }
257 | };
258 | Radar.startTrip(options);
259 |
260 | expect(mockModule.startTrip).toHaveBeenCalledTimes(1);
261 | expect(mockModule.startTrip).toBeCalledWith(options);
262 | });
263 |
264 | test('completeTrip', () => {
265 | Radar.completeTrip();
266 |
267 | expect(mockModule.completeTrip).toHaveBeenCalledTimes(1);
268 | });
269 |
270 | test('cancelTrip', () => {
271 | Radar.cancelTrip();
272 |
273 | expect(mockModule.cancelTrip).toHaveBeenCalledTimes(1);
274 | });
275 |
276 | test('getContext', () => {
277 | const location = {
278 | latitude: 40.783826,
279 | longitude: -73.975363,
280 | accuracy: 65,
281 | };
282 | Radar.getContext(location);
283 |
284 | expect(mockModule.getContext).toHaveBeenCalledTimes(1);
285 | expect(mockModule.getContext).toBeCalledWith(location);
286 | });
287 |
288 | test('searchPlaces', () => {
289 | const options = {
290 | near: {
291 | latitude: 40.783826,
292 | longitude: -73.975363,
293 | },
294 | radius: 1000,
295 | chains: ['mcdonalds'],
296 | chainMetadata: {
297 | "customFlag": "true"
298 | },
299 | limit: 10,
300 | };
301 | Radar.searchPlaces(options);
302 |
303 | expect(mockModule.searchPlaces).toHaveBeenCalledTimes(1);
304 | expect(mockModule.searchPlaces).toBeCalledWith(options);
305 | });
306 |
307 | test('searchGeofences', () => {
308 | const options = {
309 | near: {
310 | latitude: 40.783826,
311 | longitude: -73.975363,
312 | },
313 | radius: 1000,
314 | tags: ['store'],
315 | limit: 10,
316 | };
317 | Radar.searchGeofences(options);
318 |
319 | expect(mockModule.searchGeofences).toHaveBeenCalledTimes(1);
320 | expect(mockModule.searchGeofences).toBeCalledWith(options);
321 | });
322 |
323 | test('autocomplete', () => {
324 | const options = {
325 | query: 'brooklyn roasting',
326 | layers: ['address'],
327 | near: {
328 | latitude: 40.783826,
329 | longitude: -73.975363,
330 | },
331 | limit: 10,
332 | countryCode: "US",
333 | mailable: true
334 | };
335 | Radar.autocomplete(options);
336 |
337 | expect(mockModule.autocomplete).toHaveBeenCalledTimes(1);
338 | expect(mockModule.autocomplete).toBeCalledWith(options);
339 | });
340 |
341 | test('geocode', () => {
342 | const query = {
343 | address: '20 jay st brooklyn'
344 | };
345 | Radar.geocode(query);
346 |
347 | expect(mockModule.geocode).toHaveBeenCalledTimes(1);
348 | expect(mockModule.geocode).toBeCalledWith(query);
349 | });
350 |
351 | test('reverseGeocode', () => {
352 | const query = {
353 | location: {
354 | latitude: 40.783826,
355 | longitude: -73.975363,
356 | }
357 | };
358 | Radar.reverseGeocode(query);
359 |
360 | expect(mockModule.reverseGeocode).toHaveBeenCalledTimes(1);
361 | expect(mockModule.reverseGeocode).toBeCalledWith(query);
362 | });
363 |
364 | test('ipGeocode', () => {
365 | Radar.ipGeocode();
366 |
367 | expect(mockModule.ipGeocode).toHaveBeenCalledTimes(1);
368 | });
369 |
370 | test('getDistance', () => {
371 | const options = {
372 | origin: {
373 | latitude: 40.78382,
374 | longitude: -73.97536,
375 | },
376 | destination: {
377 | latitude: 40.70390,
378 | longitude: -73.98670,
379 | },
380 | modes: [
381 | 'foot',
382 | 'car',
383 | ],
384 | units: 'imperial',
385 | };
386 | Radar.getDistance(options);
387 |
388 | expect(mockModule.getDistance).toHaveBeenCalledTimes(1);
389 | expect(mockModule.getDistance).toBeCalledWith(options);
390 | });
391 |
392 | test('getMatrix', () => {
393 | const options = {
394 | origins: [
395 | {
396 | latitude: 40.78382,
397 | longitude: -73.97536,
398 | },
399 | {
400 | latitude: 40.70390,
401 | longitude: -73.98670,
402 | },
403 | ],
404 | destinations: [
405 | {
406 | latitude: 40.64189,
407 | longitude: -73.78779,
408 | },
409 | {
410 | latitude: 35.99801,
411 | longitude: -78.94294,
412 | },
413 | ],
414 | mode: 'car',
415 | units: 'imperial',
416 | };
417 | Radar.getMatrix(options);
418 |
419 | expect(mockModule.getMatrix).toHaveBeenCalledTimes(1);
420 | expect(mockModule.getMatrix).toBeCalledWith(options);
421 | });
422 |
423 | test('on', () => {
424 | const event = 'events';
425 | const callback = () => {};
426 | Radar.on(event, callback);
427 |
428 | expect(mockEmitter.addListener).toHaveBeenCalledTimes(1);
429 | expect(mockEmitter.addListener).toHaveBeenCalledWith(event, callback);
430 | });
431 |
432 | test('off', () => {
433 | const event = 'locations';
434 | Radar.off(event);
435 |
436 | expect(mockEmitter.removeAllListeners).toHaveBeenCalledTimes(1);
437 | expect(mockEmitter.removeAllListeners).toHaveBeenCalledWith(event);
438 | });
439 |
440 | test('sendEvent', () => {
441 | const eventId = 'in_app_purchase';
442 | const metadata = {"price": "$150"};
443 | Radar.sendEvent(eventId, metadata);
444 |
445 | expect(mockModule.sendEvent).toHaveBeenCalledTimes(1);
446 | expect(mockModule.sendEvent).toBeCalledWith(eventId, metadata);
447 | });
448 |
449 | test('getUserId', () => {
450 | Radar.getUserId();
451 |
452 | expect(mockModule.getUserId).toHaveBeenCalledTimes(1);
453 | });
454 |
455 | test('getDescription', () => {
456 | Radar.getDescription();
457 |
458 | expect(mockModule.getDescription).toHaveBeenCalledTimes(1);
459 | });
460 |
461 | test('getMetadata', () => {
462 | Radar.getMetadata();
463 |
464 | expect(mockModule.getMetadata).toHaveBeenCalledTimes(1);
465 | });
466 |
467 | test('setAnonymousTrackingEnabled', () => {
468 | const enabled = true;
469 | Radar.setAnonymousTrackingEnabled(enabled);
470 |
471 | expect(mockModule.setAnonymousTrackingEnabled).toHaveBeenCalledTimes(1);
472 | expect(mockModule.setAnonymousTrackingEnabled).toBeCalledWith(enabled);
473 | });
474 |
475 | test('isTracking', () => {
476 | Radar.isTracking();
477 |
478 | expect(mockModule.isTracking).toHaveBeenCalledTimes(1);
479 | });
480 |
481 | test('getTrackingOptions', () => {
482 | Radar.getTrackingOptions();
483 |
484 | expect(mockModule.getTrackingOptions).toHaveBeenCalledTimes(1);
485 | });
486 |
487 | test('getTripOptions', () => {
488 | Radar.getTripOptions();
489 |
490 | expect(mockModule.getTripOptions).toHaveBeenCalledTimes(1);
491 | });
492 |
493 | test('logConversions', () => {
494 | const options = { name: 'name' };
495 | Radar.logConversion(options);
496 |
497 | expect(mockModule.logConversion).toHaveBeenCalledTimes(1);
498 | });
499 | });
500 |
--------------------------------------------------------------------------------
/test/jest.setup.js:
--------------------------------------------------------------------------------
1 | jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter', () => {
2 | return {
3 | default: jest.fn().mockImplementation(() => ({
4 | addListener: jest.fn(),
5 | removeListeners: jest.fn(),
6 | removeAllListeners: jest.fn(),
7 | })),
8 | }
9 | // return jest.fn().mockImplementation((nativeModule) => {
10 | // return {
11 | // addListener: jest.fn(),
12 | // removeListener: jest.fn(),
13 | // removeAllListeners: jest.fn(),
14 | // };
15 | // });
16 | });
17 |
18 | jest.mock('react-native/Libraries/BatchedBridge/NativeModules', () => ({
19 | RNRadar: {
20 | setLogLevel: jest.fn(),
21 | setUserId: jest.fn(),
22 | setDescription: jest.fn(),
23 | setMetadata: jest.fn(),
24 | getPermissionsStatus: jest.fn(),
25 | requestPermissions: jest.fn(),
26 | getLocation: jest.fn(),
27 | trackOnce: jest.fn(),
28 | startTracking: jest.fn(),
29 | startTrackingEfficient: jest.fn(),
30 | startTrackingResponsive: jest.fn(),
31 | startTrackingContinuous: jest.fn(),
32 | startTrackingCustom: jest.fn(),
33 | mockTracking: jest.fn(),
34 | stopTracking: jest.fn(),
35 | acceptEvent: jest.fn(),
36 | rejectEvent: jest.fn(),
37 | startTrip: jest.fn(),
38 | completeTrip: jest.fn(),
39 | cancelTrip: jest.fn(),
40 | getContext: jest.fn(),
41 | searchPlaces: jest.fn(),
42 | searchGeofences: jest.fn(),
43 | autocomplete: jest.fn(),
44 | geocode: jest.fn(),
45 | reverseGeocode: jest.fn(),
46 | ipGeocode: jest.fn(),
47 | getDistance: jest.fn(),
48 | getMatrix: jest.fn(),
49 | sendEvent: jest.fn(),
50 | getUserId: jest.fn(),
51 | getDescription: jest.fn(),
52 | getMetadata: jest.fn(),
53 | setAnonymousTrackingEnabled: jest.fn(),
54 | isTracking: jest.fn(),
55 | getTrackingOptions: jest.fn(),
56 | getTripOptions: jest.fn(),
57 | logConversion: jest.fn(),
58 | getLocationPermissionStatus: jest.fn(),
59 | openAppSettings: jest.fn(),
60 | },
61 | }));
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "display": "React Native",
4 | "_version": "3.0.2",
5 | "compilerOptions": {
6 | "target": "es2015",
7 | "module": "commonjs",
8 | "types": ["node"],
9 | "typeRoots": [ "./node_modules/@types", "./src/@types"],
10 | "allowJs": true,
11 | "declaration": true,
12 | "jsx": "react-native",
13 | "outDir": "./dist",
14 | "rootDir": "./src",
15 | "isolatedModules": true,
16 | "strict": true,
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "allowSyntheticDefaultImports": true,
20 | "forceConsistentCasingInFileNames": false,
21 | "esModuleInterop": true,
22 | "skipLibCheck": true,
23 | "noImplicitAny": false,
24 | },
25 | "include": [
26 | "src/index.ts",
27 | "src/index.web.js",
28 | "src/ui"
29 | ],
30 | "exclude": [
31 | "node_modules",
32 | "babel.config.js",
33 | "metro.config.js",
34 | "jest.config.js",
35 | "example",
36 | "dist"
37 | ]
38 | }
39 |
--------------------------------------------------------------------------------