├── .github
└── stale.yml
├── .gitignore
├── .npmignore
├── CHANGELOG.md
├── NativeModule.js
├── README.md
├── RNBackgroundGeolocationFirebase.podspec
├── android
├── android.iml
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── libs
│ └── com
│ │ └── transistorsoft
│ │ └── tsfirebaseproxy
│ │ ├── 0.1.1
│ │ ├── tsfirebaseproxy-0.1.1.aar
│ │ ├── tsfirebaseproxy-0.1.1.aar.md5
│ │ ├── tsfirebaseproxy-0.1.1.aar.sha1
│ │ ├── tsfirebaseproxy-0.1.1.aar.sha256
│ │ ├── tsfirebaseproxy-0.1.1.aar.sha512
│ │ ├── tsfirebaseproxy-0.1.1.pom
│ │ ├── tsfirebaseproxy-0.1.1.pom.md5
│ │ ├── tsfirebaseproxy-0.1.1.pom.sha1
│ │ ├── tsfirebaseproxy-0.1.1.pom.sha256
│ │ └── tsfirebaseproxy-0.1.1.pom.sha512
│ │ └── maven-metadata.xml
├── local.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── transistorsoft
│ └── rnbackgroundgeolocation
│ └── firebase
│ ├── RNBackgroundGeolocationFirebase.java
│ └── RNBackgroundGeolocationFirebaseModule.java
├── docs
├── INSTALL-ANDROID-AUTO.md
└── INSTALL-IOS-AUTO.md
├── index.d.ts
├── index.js
├── ios
├── RNBackgroundGeolocationFirebase.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── RNBackgroundGeolocationFirebase
│ ├── RNBackgroundGeolocationFirebase.h
│ ├── RNBackgroundGeolocationFirebase.m
│ └── RNBackgroundGeolocationFirebase.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── package.json
└── react-native.config.js
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # Configuration for probot-stale based on: https://github.com/facebook/react-native/blob/master/.github/stale.yml
2 |
3 | # Number of days of inactivity before an Issue or Pull Request becomes stale
4 | daysUntilStale: 60
5 |
6 | # Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7 | daysUntilClose: 7
8 |
9 | # Issues or Pull Requests.
10 | exemptLabels:
11 | - pinned
12 | - security
13 | - discussion
14 |
15 | # Set to true to ignore issues in a project (defaults to false)
16 | exemptProjects: false
17 |
18 | # Set to true to ignore issues in a milestone (defaults to false)
19 | exemptMilestones: false
20 |
21 | # Set to true to ignore issues with an assignee (defaults to false)
22 | exemptAssignees: false
23 |
24 | # Label to use when marking as stale
25 | staleLabel: stale
26 |
27 | # Comment to post when marking as stale. Set to `false` to disable
28 | markComment: >
29 | This issue has been automatically marked as stale because it has not had
30 | recent activity. It will be closed if no further activity occurs. Thank you
31 | for your contributions. You may also mark this issue as a "discussion" and I
32 | will leave this open.
33 | # Comment to post when closing a stale Issue or Pull Request.
34 | closeComment: >
35 | Closing this issue after a prolonged period of inactivity. Fell free to reopen
36 | this issue, if this still affecting you.
37 | # Limit the number of actions per hour, from 1-30. Default is 30
38 | limitPerRun: 30
39 |
40 | # Limit to only `issues` or `pulls`
41 | only: issues
42 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/**/*
3 | package-lock.json
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 |
24 | # CocoaPods
25 | #
26 | # We recommend against adding the Pods directory to your .gitignore. However
27 | # you should judge for yourself, the pros and cons are mentioned at:
28 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
29 | #
30 | #Pods/
31 | npm-debug.log
32 |
33 | node_modules/**/*
34 |
35 | .idea
36 | android/.idea
37 | android/.gradle
38 | android/build
39 |
40 | android/local.properties
41 | android/*.iml
42 |
43 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 | *.DS_Store
4 | .github
5 | # Xcode
6 | *.pbxuser
7 | *.mode1v3
8 | *.mode2v3
9 | *.perspectivev3
10 | *.xcuserstate
11 | project.xcworkspace/
12 | xcuserdata/
13 |
14 | # Config files
15 | # .babelrc
16 | .editorconfig
17 | .eslintrc
18 | .flowconfig
19 | .watchmanconfig
20 | buddybuild_postclone.sh
21 | jsconfig.json
22 |
23 | # Built application files
24 | android/*/build/
25 |
26 | # Local configuration file (sdk path, etc)
27 | android/local.properties
28 |
29 | # Gradle generated files
30 | android/.gradle/
31 |
32 | # Signing files
33 | android/.signing/
34 |
35 | # User-specific configurations
36 | android/.idea/gradle.xml
37 | android/.idea/libraries/
38 | android/.idea/workspace.xml
39 | android/.idea/tasks.xml
40 | android/.idea/.name
41 | android/.idea/compiler.xml
42 | android/.idea/copyright/profiles_settings.xml
43 | android/.idea/encodings.xml
44 | android/.idea/misc.xml
45 | android/.idea/modules.xml
46 | android/.idea/scopes/scope_settings.xml
47 | android/.idea/vcs.xml
48 | android/*.iml
49 | ios/RNBackgroundGeolocationFirebase.xcodeproj/xcuserdata
50 |
51 | # OS-specific files
52 | .DS_Store
53 | .DS_Store?
54 | ._*
55 | .Spotlight-V100
56 | .Trashes
57 | ehthumbs.db
58 | Thumbs.dbandroid/gradle
59 | android/gradlew
60 | android/build
61 | android/gradlew.bat
62 | android/gradle/
63 | docs
64 | .idea
65 | coverage
66 | yarn.lock
67 | .github
68 | tests
69 | example
70 | android/.settings
71 | README.md
72 |
73 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | ## [0.5.0] -- 2024-10-17
4 | * Upgrade iOS / Android dependencies. Modify Setup Instructions.
5 |
6 | ## [0.4.1] -- 2023-10-06
7 | * [iOS] Remove `settings.timestampsInSnapshotsEnabled = YES;`
8 | * [Android] Update default `firebaseCoreVersion`, `firebaseCoreVersion`
9 |
10 | ## [0.4.0] -- 2020-06-19
11 | * [Fixed][Android] `com.android.tools.build:gradle:4.0.0` no longer allows "*direct local aar dependencies*". The Android Setup now requires a custom __`maven url`__ to be added to your app's root __`android/build.gradle`__:
12 |
13 | ```diff
14 | allprojects {
15 | repositories {
16 | google()
17 | jcenter()
18 | + maven {
19 | + // [required] background-geolocation Firebase adapter.
20 | + url "${project(':react-native-background-geolocation-firebase').projectDir}/libs"
21 | + }
22 | }
23 | }
24 | ```
25 |
26 | ## [0.3.0] -- 2019-08-18
27 | - [Changed] Updated for `react-native >= 0.60.0`
28 |
29 | -------------------------------------------------------------
30 |
31 | :warning: If you have a previous version of **`react-native-background-geolocation-firebase < 0.3.0`** installed into **`react-native >= 0.60`**, you should first `unlink` your previous version as `react-native link` is no longer required.
32 |
33 | ```bash
34 | $ react-native unlink react-native-background-geolocation-firebase
35 | ```
36 |
37 | -------------------------------------------------------------
38 |
39 | ## [0.2.0] -- 2019-05-30
40 | - [Fixed] Android bug in using `geofencesCollection`.
41 | - [Fixed] Update Android Gradle config to use `implementation` instead of `compile`.
42 | - [Changed] Changed Android `ext` defaults to latest values.
43 | ```
44 | def DEFAULT_COMPILE_SDK_VERSION = 28
45 | def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
46 | def DEFAULT_TARGET_SDK_VERSION = 28
47 |
48 | def DEFAULT_FIREBASE_CORE_VERSION = "16.0.9"
49 | def DEFAULT_FIREBASE_FIRESTORE_VERSION = "19.0.0"
50 | ```
51 |
52 | ## [0.1.0] -- 2019-01-15
53 | - Update setup docs with Gradle config vars firebaseCoreVersion, firebaseFirestoreVersion
54 | - Add Typescript definitions
55 |
56 | ## [0.0.1]
57 | - Initial version
58 |
59 |
--------------------------------------------------------------------------------
/NativeModule.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import {
4 | NativeEventEmitter,
5 | NativeModules
6 | } from "react-native"
7 |
8 | const { RNBackgroundGeolocationFirebase, RNBackgroundGeolocation } = NativeModules;
9 |
10 | const EventEmitter = new NativeEventEmitter(RNBackgroundGeolocationFirebase);
11 |
12 | const TAG = "TSLocationManager";
13 | const PLATFORM_ANDROID = "android";
14 | const PLATFORM_IOS = "ios";
15 |
16 | const EVENTS = [
17 |
18 | ];
19 |
20 | /**
21 | * Native API
22 | */
23 | export default class NativeModule {
24 | static get EVENTS() { return EVENTS; }
25 | /**
26 | * Core API Methods
27 | */
28 | static configure(config) {
29 | return new Promise((resolve, reject) => {
30 | let success = (state) => { resolve(state) }
31 | let failure = (error) => { reject(error) }
32 |
33 | RNBackgroundGeolocationFirebase.configure(config, success, failure);
34 | RNBackgroundGeolocation.registerPlugin('firebaseproxy');
35 | });
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | react-native-background-geolocation-firebase · []() []()
2 | ============================================================================
3 |
4 | [](https://www.transistorsoft.com)
5 |
6 | -------------------------------------------------------------------------------
7 |
8 | Firebase Proxy for [React Native Background Geolocation](https://github.com/transistorsoft/react-native-background-geolocation). The plugin will automatically post locations to your own Firebase database, overriding the `react-native-background-geolocation` plugin's SQLite / HTTP services.
9 |
10 | 
11 |
12 | ----------------------------------------------------------------------------
13 |
14 | The **[Android module](https://shop.transistorsoft.com/collections/frontpage/products/background-geolocation-firebase)** requires [purchasing a license](https://shop.transistorsoft.com/collections/frontpage/products/background-geolocation-firebase). However, it *will* work for **DEBUG** builds. It will **not** work with **RELEASE** builds [without purchasing a license](https://shop.transistorsoft.com/collections/frontpage/products/background-geolocation-firebase).
15 |
16 | ----------------------------------------------------------------------------
17 |
18 | ## :large_blue_diamond: Installing the Plugin
19 |
20 | -------------------------------------------------------------
21 |
22 | :warning: If you have a previous version of **`react-native-background-geolocation-firebase < 0.3.0`** installed into **`react-native >= 0.60`**, you should first `unlink` your previous version as `react-native link` is no longer required.
23 |
24 | ```bash
25 | $ react-native unlink react-native-background-geolocation-firebase
26 | ```
27 |
28 | -------------------------------------------------------------
29 |
30 | ### From yarn
31 |
32 | ```bash
33 | $ yarn add react-native-background-geolocation-firebase
34 | ```
35 |
36 | ### From npm
37 |
38 | ```
39 | $ npm install react-native-background-geolocation-firebase --save
40 | ```
41 |
42 | ### Latest from Github
43 |
44 | ```
45 | $ npm install git+https://git@github.com:transistorsoft/react-native-background-geolocation-firebase.git --save
46 | ```
47 |
48 | ## :large_blue_diamond: Setup Guides
49 |
50 | ## iOS
51 |
52 | - [Auto-linking Setup](docs/INSTALL-IOS-AUTO.md)
53 |
54 | ## Android
55 |
56 | - [Auto-linking Setup](docs/INSTALL-ANDROID-AUTO.md)
57 |
58 | ## :large_blue_diamond: Configure your license
59 |
60 | 1. Login to Customer Dashboard to generate an application key:
61 | [www.transistorsoft.com/shop/customers](http://www.transistorsoft.com/shop/customers)
62 | 
63 |
64 | 2. Add your license-key to `android/app/src/main/AndroidManifest.xml`:
65 |
66 | ```diff
67 |
69 |
70 |
76 |
77 |
78 | +
79 | .
80 | .
81 | .
82 |
83 |
84 | ```
85 |
86 | ## :large_blue_diamond: Using the plugin ##
87 |
88 | ```javascript
89 | import BackgroundGeolocationFirebase from "react-native-background-geolocation-firebase";
90 | ```
91 |
92 | ## :large_blue_diamond: Example
93 |
94 | ```javascript
95 |
96 | import BackgroundGeolocation from "react-native-background-geolocation";
97 | import BackgroundGeolocationFirebase from "react-native-background-geolocation-firebase";
98 | .
99 | .
100 | .
101 | function App(): React.JSX.Element {
102 |
103 | React.useEffect(() => {
104 | // Configure BackgroundGeolocation Firebase adapter.
105 | BackgroundGeolocationFirebase.configure({
106 | locationsCollection: "locations",
107 | geofencesCollection: "geofences"
108 | });
109 |
110 | // Configure BackgroundGeolocation
111 | const onLocation = BackgroundGeolocation.onLocation((location) => {
112 | console.log('[onLocation] ', location);
113 | });
114 |
115 | BackgroundGeolocation.ready({
116 | debug: true,
117 | logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE
118 | }).then((state) => {
119 | console.log('- ready: ', state.enablede);
120 | if (!state.enabled) {
121 | BackgroundGeolocation.start();
122 | }
123 | })
124 | return () => {
125 | // Remove event-listeners.
126 | onLocation.remove();
127 | }
128 | });
129 | }
130 |
131 | ```
132 |
133 | ## :large_blue_diamond: Firebase Functions
134 |
135 | `BackgroundGeolocation` will post its default "Location Data Schema" to your Firebase app.
136 |
137 | ```json
138 | {
139 | "location":{},
140 | "param1": "param 1",
141 | "param2": "param 2"
142 | }
143 | ```
144 |
145 | You should implement your own [Firebase Functions](https://firebase.google.com/docs/functions) to "*massage*" the incoming data in your collection as desired. For example:
146 |
147 | ```typescript
148 | import * as functions from 'firebase-functions';
149 |
150 | exports.createLocation = functions.firestore
151 | .document('locations/{locationId}')
152 | .onCreate((snap, context) => {
153 | const record = snap.data();
154 |
155 | const location = record.location;
156 |
157 | console.log('[data] - ', record);
158 |
159 | return snap.ref.set({
160 | uuid: location.uuid,
161 | timestamp: location.timestamp,
162 | is_moving: location.is_moving,
163 | latitude: location.coords.latitude,
164 | longitude: location.coords.longitude,
165 | speed: location.coords.speed,
166 | heading: location.coords.heading,
167 | altitude: location.coords.altitude,
168 | event: location.event,
169 | battery_is_charging: location.battery.is_charging,
170 | battery_level: location.battery.level,
171 | activity_type: location.activity.type,
172 | activity_confidence: location.activity.confidence,
173 | extras: location.extras
174 | });
175 | });
176 |
177 |
178 | exports.createGeofence = functions.firestore
179 | .document('geofences/{geofenceId}')
180 | .onCreate((snap, context) => {
181 | const record = snap.data();
182 |
183 | const location = record.location;
184 |
185 | console.log('[data] - ', record);
186 |
187 | return snap.ref.set({
188 | uuid: location.uuid,
189 | identifier: location.geofence.identifier,
190 | action: location.geofence.action,
191 | timestamp: location.timestamp,
192 | latitude: location.coords.latitude,
193 | longitude: location.coords.longitude,
194 | extras: location.extras,
195 | });
196 | });
197 |
198 | ```
199 |
200 | ## :large_blue_diamond: Configuration Options
201 |
202 | #### `@param {String} locationsCollection [locations]`
203 |
204 | The collection name to post `location` events to. Eg:
205 |
206 | ```javascript
207 | BackgroundGeolocationFirebase.configure({
208 | locationsCollection: '/locations'
209 | });
210 |
211 | BackgroundGeolocationFirebase.configure({
212 | locationsCollection: '/users/123/locations'
213 | });
214 |
215 | BackgroundGeolocationFirebase.configure({
216 | locationsCollection: '/users/123/routes/456/locations'
217 | });
218 |
219 | ```
220 |
221 | #### `@param {String} geofencesCollection [geofences]`
222 |
223 | The collection name to post `geofence` events to. Eg:
224 |
225 | ```javascript
226 | BackgroundGeolocationFirebase.configure({
227 | geofencesCollection: '/geofences'
228 | });
229 |
230 | BackgroundGeolocationFirebase.configure({
231 | geofencesCollection: '/users/123/geofences'
232 | });
233 |
234 | BackgroundGeolocationFirebase.configure({
235 | geofencesCollection: '/users/123/routes/456/geofences'
236 | });
237 |
238 | ```
239 |
240 |
241 | #### `@param {Boolean} updateSingleDocument [false]`
242 |
243 | If you prefer, you can instruct the plugin to update a *single document* in Firebase rather than creating a new document for *each* `location` / `geofence`. In this case, you would presumably implement a *Firebase Function* to deal with updates upon this single document and store the location in some other collection as desired. If this is your use-case, you'll also need to ensure you configure your `locationsCollection` / `geofencesCollection` accordingly with an even number of "parts", taking the form `/collection_name/document_id`, eg:
244 |
245 | ```javascript
246 | BackgroundGeolocationFirebase.configure({
247 | locationsCollection: '/locations/latest' // <-- 2 "parts": even
248 | });
249 |
250 | // or
251 | BackgroundGeolocationFirebase.configure({
252 | locationsCollection: '/users/123/routes/456/the_location' // <-- 4 "parts": even
253 | });
254 |
255 | // Don't use an odd number of "parts"
256 | BackgroundGeolocationFirebase.configure({
257 | locationsCollection: '/users/123/latest_location' // <-- 3 "parts": odd!! No!
258 | });
259 |
260 | ```
261 |
262 |
263 | # License
264 |
265 | The MIT License (MIT)
266 |
267 | Copyright (c) 2018 Chris Scott, Transistor Software
268 |
269 | Permission is hereby granted, free of charge, to any person obtaining a copy
270 | of this software and associated documentation files (the "Software"), to deal
271 | in the Software without restriction, including without limitation the rights
272 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
273 | copies of the Software, and to permit persons to whom the Software is
274 | furnished to do so, subject to the following conditions:
275 |
276 | The above copyright notice and this permission notice shall be included in all
277 | copies or substantial portions of the Software.
278 |
279 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
280 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
281 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
282 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
283 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
284 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
285 | SOFTWARE.
286 |
287 |
288 |
--------------------------------------------------------------------------------
/RNBackgroundGeolocationFirebase.podspec:
--------------------------------------------------------------------------------
1 | require 'json'
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4 |
5 | Pod::Spec.new do |s|
6 | s.cocoapods_version = '>= 1.10.0'
7 | s.name = 'RNBackgroundGeolocationFirebase'
8 | s.version = package['version']
9 | s.summary = package['description']
10 | s.description = <<-DESC
11 | Firebase adapter for react-native-background-geolocation
12 | DESC
13 | s.homepage = package['homepage']
14 | s.license = package['license']
15 | s.author = package['author']
16 | s.source = { :git => 'https://github.com/transistorsoft/react-native-background-geolocation-firebase.git', :tag => s.version }
17 | s.platform = :ios, '8.0'
18 | s.preserve_paths = 'docs', 'CHANGELOG.md', 'LICENSE', 'package.json', 'index.js', 'NativeModule.js'
19 |
20 | s.dependency 'React'
21 | s.dependency 'FirebaseFirestore'
22 |
23 | s.source_files = 'ios/RNBackgroundGeolocationFirebase/*.{h,m}'
24 | end
25 |
--------------------------------------------------------------------------------
/android/android.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | def DEFAULT_COMPILE_SDK_VERSION = 34
4 | def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
5 | def DEFAULT_TARGET_SDK_VERSION = 28
6 |
7 | def DEFAULT_FIREBASE_SDK_VERSION = "33.4.0"
8 |
9 | def safeExtGet(prop, fallback) {
10 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
11 | }
12 |
13 | android {
14 | if (project.android.hasProperty("namespace")) {
15 | namespace("com.transistorsoft.rnbackgroundgeolocation.firebase")
16 | }
17 | compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
18 |
19 | defaultConfig {
20 | minSdkVersion safeExtGet('minSdkVersion', 16)
21 | }
22 | lintOptions {
23 | disable 'InvalidPackage'
24 | }
25 | }
26 |
27 | rootProject.gradle.buildFinished { buildResult ->
28 | if (buildResult.getFailure() != null) {
29 | try {
30 | String message = buildResult.getFailure().properties.get("reportableCauses").toString()
31 |
32 | if (message.contains("DexArchiveMergerException") || message.contains("DexIndexOverflowException")) {
33 | logger.log(LogLevel.ERROR, "")
34 | logger.log(LogLevel.ERROR, " ----------------------------------------------------------- ")
35 | logger.log(LogLevel.ERROR, "| react-native-background-geolocation-firebase | ")
36 | logger.log(LogLevel.ERROR, " ----------------------------------------------------------- ")
37 | logger.log(LogLevel.ERROR, "| | ")
38 | logger.log(LogLevel.ERROR, "| In your app/build.gradle, enable multidex: | ")
39 | logger.log(LogLevel.ERROR, "| | ")
40 | logger.log(LogLevel.ERROR, "| android { | ")
41 | logger.log(LogLevel.ERROR, "| defaultConfig { | ")
42 | logger.log(LogLevel.ERROR, "| multiDexEnabled true // <-- Add this | ")
43 | logger.log(LogLevel.ERROR, "| } | ")
44 | logger.log(LogLevel.ERROR, "| } | ")
45 | logger.log(LogLevel.ERROR, " ----------------------------------------------------------- ")
46 |
47 | }
48 | } catch (Exception exception) {
49 |
50 | }
51 | }
52 | }
53 |
54 | repositories{
55 | maven {
56 | url './libs'
57 | }
58 | }
59 |
60 | dependencies {
61 | def FirebaseSDKVersion = safeExtGet("FirebaseSDKVersion", DEFAULT_FIREBASE_SDK_VERSION);
62 |
63 | implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
64 |
65 | // Import the Firebase BoM
66 | implementation(platform("com.google.firebase:firebase-bom:$FirebaseSDKVersion"))
67 | implementation "com.google.firebase:firebase-firestore"
68 |
69 | // tsfirebaseproxy.aar
70 | api(group: 'com.transistorsoft', name:"tsfirebaseproxy", version: '+')
71 | }
72 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/transistorsoft/react-native-background-geolocation-firebase/25380c8b168d9a7303635032350f588045dd5a93/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Aug 03 00:14:57 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-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/transistorsoft/react-native-background-geolocation-firebase/25380c8b168d9a7303635032350f588045dd5a93/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.aar
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.aar.md5:
--------------------------------------------------------------------------------
1 | 13eb6a7a513bc817320df02415f42932
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.aar.sha1:
--------------------------------------------------------------------------------
1 | 80cf9c0b0cf0b72ff80ae40f053ff72c3334d56a
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.aar.sha256:
--------------------------------------------------------------------------------
1 | 126c9c31cb34139808bc7716d10efdb866e122c48e3833d5b69c591b295abbd7
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.aar.sha512:
--------------------------------------------------------------------------------
1 | b2fa4e886e758632fc12fc459bb8f2f8a99a84b02689ab8be2c1ef18e44b62cb8da662981af054bb1ee11cc41aef0df3af46abed0ed02b35bb8a14ea0bc41e59
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.transistorsoft
6 | tsfirebaseproxy
7 | 0.1.1
8 | aar
9 |
10 |
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.pom.md5:
--------------------------------------------------------------------------------
1 | 7dd25773eecefd699b6a931b064f0203
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.pom.sha1:
--------------------------------------------------------------------------------
1 | 52054d582ae0883e5174ff6a7cd3d32eaa487155
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.pom.sha256:
--------------------------------------------------------------------------------
1 | 548baa0b6fcefc3c47626791f69c89b943842afe29475d8e53b1649789328063
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/0.1.1/tsfirebaseproxy-0.1.1.pom.sha512:
--------------------------------------------------------------------------------
1 | 814de6ab17b28531da7fad2540f3a1ce84edfdfa4a9c32af0912bbb063d716aa41dfcbe10c34487a8846a6201948610b4be02af6aa59ae8bb13bf78db5b2b17b
--------------------------------------------------------------------------------
/android/libs/com/transistorsoft/tsfirebaseproxy/maven-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | com.transistorsoft
4 | tsfirebaseproxy
5 |
6 | 0.1.1
7 | 0.1.1
8 |
9 | 0.1.1
10 |
11 | 20211108181843
12 |
13 |
14 |
--------------------------------------------------------------------------------
/android/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Tue Jul 31 12:22:59 EDT 2018
8 | sdk.dir=/Users/chris/Library/Android/sdk
9 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/firebase/RNBackgroundGeolocationFirebase.java:
--------------------------------------------------------------------------------
1 | package com.transistorsoft.rnbackgroundgeolocation.firebase;
2 |
3 | import java.util.ArrayList;
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 | /**
14 | * Created by chris on 2015-10-30.
15 | */
16 | public class RNBackgroundGeolocationFirebase implements ReactPackage {
17 | @Override public List createNativeModules (ReactApplicationContext reactContext) {
18 | List modules = new ArrayList<>();
19 | modules.add(new RNBackgroundGeolocationFirebaseModule(reactContext));
20 | return modules;
21 | }
22 |
23 | // Depreciated RN 0.47
24 | //@Override
25 | public List> createJSModules() {
26 | return Collections.emptyList();
27 | }
28 |
29 | @Override
30 | public List createViewManagers(ReactApplicationContext reactContext) {
31 | return Collections.emptyList();
32 | }
33 | }
--------------------------------------------------------------------------------
/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/firebase/RNBackgroundGeolocationFirebaseModule.java:
--------------------------------------------------------------------------------
1 | package com.transistorsoft.rnbackgroundgeolocation.firebase;
2 |
3 | import com.facebook.react.bridge.Callback;
4 | import com.facebook.react.bridge.ReactApplicationContext;
5 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
6 |
7 | import com.facebook.react.bridge.ReactMethod;
8 | import com.facebook.react.bridge.ReadableMap;
9 | import com.transistorsoft.tsfirebaseproxy.TSFirebaseProxy;
10 |
11 | /**
12 | * Created by chris on 2015-10-30.
13 | */
14 | public class RNBackgroundGeolocationFirebaseModule extends ReactContextBaseJavaModule {
15 |
16 | private static final String TAG = "TSLocationManager";
17 |
18 | private boolean isRegistered;
19 |
20 | public RNBackgroundGeolocationFirebaseModule(ReactApplicationContext reactContext) {
21 | super(reactContext);
22 | isRegistered = false;
23 | }
24 |
25 | @Override
26 | public void initialize() {
27 | // do nothing
28 | }
29 | @Override
30 | public String getName() {
31 | return "RNBackgroundGeolocationFirebase";
32 | }
33 |
34 | @ReactMethod
35 | public void configure(ReadableMap params, final Callback success, final Callback failure){
36 |
37 | TSFirebaseProxy proxy = TSFirebaseProxy.getInstance(getReactApplicationContext());
38 | if (params.hasKey("locationsCollection")) {
39 | proxy.setLocationsCollection(params.getString("locationsCollection"));
40 | }
41 | if (params.hasKey("geofencesCollection")) {
42 | proxy.setGeofencesCollection(params.getString("geofencesCollection"));
43 | }
44 | if (params.hasKey("updateSingleDocument")) {
45 | proxy.setUpdateSingleDocument(params.getBoolean("updateSingleDocument"));
46 | }
47 | proxy.save(getReactApplicationContext());
48 |
49 | if (!isRegistered) {
50 | isRegistered = true;
51 | proxy.register(getReactApplicationContext());
52 | }
53 | success.invoke();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/docs/INSTALL-ANDROID-AUTO.md:
--------------------------------------------------------------------------------
1 | # Android Auto-linking Installation
2 |
3 | ### With `yarn`
4 |
5 | ```shell
6 | $ yarn add react-native-background-geolocation-firebase
7 | ```
8 |
9 | ### With `npm`
10 |
11 | ```shell
12 | $ npm install --save react-native-background-geolocation-firebase
13 | ```
14 |
15 | ## Gradle Configuration
16 |
17 | ### :open_file_folder: **`android/build.gradle`**
18 |
19 | ```diff
20 | buildscript {
21 | ext {
22 | minSdkVersion = 16
23 | compileSdkVersion = 34
24 | targetSdkVersion = 34
25 | googlePlayServicesLocationVersion = "21.3.0"
26 | + FirebaseSDKVersion = "33.4.0" // or as desired.
27 |
28 | }
29 | }
30 |
31 | allprojects {
32 | repositories {
33 | // Required for react-native-background-geolocation
34 | maven { url("${project(':react-native-background-geolocation').projectDir}/libs") }
35 | maven { url 'https://developer.huawei.com/repo/' }
36 | // Required for react-native-background-fetch
37 | maven { url("${project(':react-native-background-fetch').projectDir}/libs") }
38 |
39 | + // Required react-native-background-geolocation-firebase
40 | + maven { url("${project(':react-native-background-geolocation-firebase').projectDir}/libs") }
41 | }
42 | }
43 | ```
44 |
45 | > [!NOTE]
46 | > the param __`ext.FirebaseSdkVersion`__ controls the imported version of the *Firebase SDK* (`com.google.firebase:firebase-bom`). Consult the [Firebase Release Notes](https://firebase.google.com/support/release-notes/android?_gl=1*viqpog*_up*MQ..*_ga*MTE1NjI2MDkuMTcyOTA4ODY0MQ..*_ga_CW55HF8NVT*MTcyOTA4ODY0MS4xLjAuMTcyOTA4ODY0MS4wLjAuMA..#latest_sdk_versions) to determine the latest version of the *Firebase* SDK
47 |
48 |
49 | ### :open_file_folder: **`android/settings.gradle`**
50 | - Add the `google-services` plugin (if you haven't already):
51 | - Add the following `repositories` to the `pluginManagement` block.
52 |
53 | ```diff
54 | pluginManagement {
55 | includeBuild("../node_modules/@react-native/gradle-plugin")
56 | + repositories {
57 | + google()
58 | + mavenCentral()
59 | + }
60 | }
61 |
62 | plugins {
63 | id("com.facebook.react.settings")
64 | + id 'com.google.gms.google-services' version '4.3.15' apply false // Or any desired version.
65 | }
66 | ```
67 |
68 | ### :open_file_folder: **`android/app/build.gradle`**
69 | - If you don't see a __`plugins`__ block, add it to the __top of the file__.
70 | - Add the `google-services` plugin (if you haven't already):
71 |
72 | ```diff
73 | plugins { // <-- Add plugins block if you don't have one.
74 | + id "com.google.gms.google-services"
75 | }
76 | ```
77 |
78 | ### :open_file_folder: **`google-services.json`**
79 |
80 | > [!NOTE]
81 | > If you've installed `react-native-firebase`, you should already have performed this step.
82 |
83 | Download your `google-services.json` from the *Firebase Console*. Copy the file to your `android/app` folder.
84 |
85 | ## AndroidManifest.xml
86 |
87 | :open_file_folder: **`android/app/src/main/AndroidManifest.xml`**
88 |
89 | ```diff
90 |
92 |
93 |
99 |
100 |
101 | +
102 | .
103 | .
104 | .
105 |
106 |
107 |
108 | ```
109 |
110 | :information_source: [Purchase a License](http://www.transistorsoft.com/shop/products/react-native-background-geolocation)
111 |
112 |
--------------------------------------------------------------------------------
/docs/INSTALL-IOS-AUTO.md:
--------------------------------------------------------------------------------
1 | # iOS Auto-linking Instructions
2 |
3 | ### With `yarn`
4 |
5 | ```shell
6 | $ yarn add react-native-background-geolocation-firebase
7 | ```
8 |
9 | ### With `npm`
10 |
11 | ```shell
12 | $ npm install --save react-native-background-geolocation-firebase
13 | ```
14 |
15 | To open your project in XCode, use the file `YourProject.xcworkspace` (**not** `YourProject.xcodeproj`)
16 |
17 | ### `pod install`
18 |
19 | ```bash
20 | $ cd ios
21 | $ pod install
22 | ```
23 |
24 | ### :open_file_folder: **`AppDelegate.mm`** (or __`AppDelegate.m`__):
25 |
26 | > [!NOTE]
27 | > If you've already installed `react-native-firebase`, this step will already have been performed.
28 |
29 | ```diff
30 | #import "AppDelegate.h"
31 | .
32 | .
33 | .
34 | +#import
35 |
36 | @implementation AppDelegate
37 |
38 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
39 | {
40 | self.moduleName = @"example";
41 | // You can add your custom initial props in the dictionary below.
42 | // They will be passed down to the ViewController used by React Native.
43 | self.initialProps = @{};
44 |
45 | + [FIRApp configure];
46 |
47 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
48 | }
49 |
50 | ```
51 |
52 | ### **`Google-Services-Info.plist`**
53 |
54 | From your **Firebase Console**, copy your downloaded `Google-Services-Info.plist` file into your application:
55 |
56 | 
57 |
58 |
--------------------------------------------------------------------------------
/index.d.ts:
--------------------------------------------------------------------------------
1 | export default class BackgroundGeolocationFirebase {
2 | static configure(config:any, success?:Function, failure?:Function):Promise;
3 | }
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | import {
4 | Platform,
5 | AppRegistry
6 | } from "react-native"
7 |
8 | import NativeModule from './NativeModule';
9 |
10 | const TAG = "BackgroundGeolocationFirebase";
11 |
12 | class BackgroundGeolocationFirebase {
13 | /**
14 | * Perform initial configuration of plugin. Reset config to default before applying supplied configuration
15 | */
16 | static configure(config, success, failure) {
17 | if (arguments.length == 1) {
18 | return NativeModule.configure(config);
19 | } else {
20 | NativeModule.configure(config).then(success).catch(failure);
21 | }
22 | }
23 | }
24 |
25 | export default BackgroundGeolocationFirebase;
26 |
27 |
28 |
--------------------------------------------------------------------------------
/ios/RNBackgroundGeolocationFirebase.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 83E6BA2E211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E6BA2D211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m */; };
11 | 83E6BA2F211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83E6BA2C211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 83E6BA27211499CA00D5C0BA /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = "include/$(PRODUCT_NAME)";
19 | dstSubfolderSpec = 16;
20 | files = (
21 | 83E6BA2F211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h in CopyFiles */,
22 | );
23 | runOnlyForDeploymentPostprocessing = 0;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 83E6BA29211499CA00D5C0BA /* libRNBackgroundGeolocationFirebase.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNBackgroundGeolocationFirebase.a; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 83E6BA2C211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNBackgroundGeolocationFirebase.h; sourceTree = ""; };
30 | 83E6BA2D211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNBackgroundGeolocationFirebase.m; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 83E6BA26211499CA00D5C0BA /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 83E6BA20211499CA00D5C0BA = {
45 | isa = PBXGroup;
46 | children = (
47 | 83E6BA2B211499CA00D5C0BA /* RNBackgroundGeolocationFirebase */,
48 | 83E6BA2A211499CA00D5C0BA /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 83E6BA2A211499CA00D5C0BA /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 83E6BA29211499CA00D5C0BA /* libRNBackgroundGeolocationFirebase.a */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 83E6BA2B211499CA00D5C0BA /* RNBackgroundGeolocationFirebase */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 83E6BA2C211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h */,
64 | 83E6BA2D211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m */,
65 | );
66 | path = RNBackgroundGeolocationFirebase;
67 | sourceTree = "";
68 | };
69 | /* End PBXGroup section */
70 |
71 | /* Begin PBXNativeTarget section */
72 | 83E6BA28211499CA00D5C0BA /* RNBackgroundGeolocationFirebase */ = {
73 | isa = PBXNativeTarget;
74 | buildConfigurationList = 83E6BA32211499CA00D5C0BA /* Build configuration list for PBXNativeTarget "RNBackgroundGeolocationFirebase" */;
75 | buildPhases = (
76 | 83E6BA25211499CA00D5C0BA /* Sources */,
77 | 83E6BA26211499CA00D5C0BA /* Frameworks */,
78 | 83E6BA27211499CA00D5C0BA /* CopyFiles */,
79 | );
80 | buildRules = (
81 | );
82 | dependencies = (
83 | );
84 | name = RNBackgroundGeolocationFirebase;
85 | productName = RNBackgroundGeolocationFirebase;
86 | productReference = 83E6BA29211499CA00D5C0BA /* libRNBackgroundGeolocationFirebase.a */;
87 | productType = "com.apple.product-type.library.static";
88 | };
89 | /* End PBXNativeTarget section */
90 |
91 | /* Begin PBXProject section */
92 | 83E6BA21211499CA00D5C0BA /* Project object */ = {
93 | isa = PBXProject;
94 | attributes = {
95 | LastUpgradeCheck = 0940;
96 | ORGANIZATIONNAME = "Christopher Scott";
97 | TargetAttributes = {
98 | 83E6BA28211499CA00D5C0BA = {
99 | CreatedOnToolsVersion = 9.4.1;
100 | };
101 | };
102 | };
103 | buildConfigurationList = 83E6BA24211499CA00D5C0BA /* Build configuration list for PBXProject "RNBackgroundGeolocationFirebase" */;
104 | compatibilityVersion = "Xcode 9.3";
105 | developmentRegion = en;
106 | hasScannedForEncodings = 0;
107 | knownRegions = (
108 | en,
109 | );
110 | mainGroup = 83E6BA20211499CA00D5C0BA;
111 | productRefGroup = 83E6BA2A211499CA00D5C0BA /* Products */;
112 | projectDirPath = "";
113 | projectRoot = "";
114 | targets = (
115 | 83E6BA28211499CA00D5C0BA /* RNBackgroundGeolocationFirebase */,
116 | );
117 | };
118 | /* End PBXProject section */
119 |
120 | /* Begin PBXSourcesBuildPhase section */
121 | 83E6BA25211499CA00D5C0BA /* Sources */ = {
122 | isa = PBXSourcesBuildPhase;
123 | buildActionMask = 2147483647;
124 | files = (
125 | 83E6BA2E211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m in Sources */,
126 | );
127 | runOnlyForDeploymentPostprocessing = 0;
128 | };
129 | /* End PBXSourcesBuildPhase section */
130 |
131 | /* Begin XCBuildConfiguration section */
132 | 83E6BA30211499CA00D5C0BA /* Debug */ = {
133 | isa = XCBuildConfiguration;
134 | buildSettings = {
135 | ALWAYS_SEARCH_USER_PATHS = NO;
136 | CLANG_ANALYZER_NONNULL = YES;
137 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
138 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
139 | CLANG_CXX_LIBRARY = "libc++";
140 | CLANG_ENABLE_MODULES = YES;
141 | CLANG_ENABLE_OBJC_ARC = YES;
142 | CLANG_ENABLE_OBJC_WEAK = YES;
143 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
144 | CLANG_WARN_BOOL_CONVERSION = YES;
145 | CLANG_WARN_COMMA = YES;
146 | CLANG_WARN_CONSTANT_CONVERSION = YES;
147 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
148 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
149 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
150 | CLANG_WARN_EMPTY_BODY = YES;
151 | CLANG_WARN_ENUM_CONVERSION = YES;
152 | CLANG_WARN_INFINITE_RECURSION = YES;
153 | CLANG_WARN_INT_CONVERSION = YES;
154 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
155 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
156 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
157 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
158 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
159 | CLANG_WARN_STRICT_PROTOTYPES = YES;
160 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
161 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
162 | CLANG_WARN_UNREACHABLE_CODE = YES;
163 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
164 | CODE_SIGN_IDENTITY = "iPhone Developer";
165 | COPY_PHASE_STRIP = NO;
166 | DEBUG_INFORMATION_FORMAT = dwarf;
167 | ENABLE_STRICT_OBJC_MSGSEND = YES;
168 | ENABLE_TESTABILITY = YES;
169 | GCC_C_LANGUAGE_STANDARD = gnu11;
170 | GCC_DYNAMIC_NO_PIC = NO;
171 | GCC_NO_COMMON_BLOCKS = YES;
172 | GCC_OPTIMIZATION_LEVEL = 0;
173 | GCC_PREPROCESSOR_DEFINITIONS = (
174 | "DEBUG=1",
175 | "$(inherited)",
176 | );
177 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
178 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
179 | GCC_WARN_UNDECLARED_SELECTOR = YES;
180 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
181 | GCC_WARN_UNUSED_FUNCTION = YES;
182 | GCC_WARN_UNUSED_VARIABLE = YES;
183 | IPHONEOS_DEPLOYMENT_TARGET = 11.4;
184 | MTL_ENABLE_DEBUG_INFO = YES;
185 | ONLY_ACTIVE_ARCH = YES;
186 | SDKROOT = iphoneos;
187 | };
188 | name = Debug;
189 | };
190 | 83E6BA31211499CA00D5C0BA /* Release */ = {
191 | isa = XCBuildConfiguration;
192 | buildSettings = {
193 | ALWAYS_SEARCH_USER_PATHS = NO;
194 | CLANG_ANALYZER_NONNULL = YES;
195 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
196 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
197 | CLANG_CXX_LIBRARY = "libc++";
198 | CLANG_ENABLE_MODULES = YES;
199 | CLANG_ENABLE_OBJC_ARC = YES;
200 | CLANG_ENABLE_OBJC_WEAK = YES;
201 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
202 | CLANG_WARN_BOOL_CONVERSION = YES;
203 | CLANG_WARN_COMMA = YES;
204 | CLANG_WARN_CONSTANT_CONVERSION = YES;
205 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
206 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
207 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
208 | CLANG_WARN_EMPTY_BODY = YES;
209 | CLANG_WARN_ENUM_CONVERSION = YES;
210 | CLANG_WARN_INFINITE_RECURSION = YES;
211 | CLANG_WARN_INT_CONVERSION = YES;
212 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
213 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
214 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
215 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
216 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
217 | CLANG_WARN_STRICT_PROTOTYPES = YES;
218 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
219 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
220 | CLANG_WARN_UNREACHABLE_CODE = YES;
221 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
222 | CODE_SIGN_IDENTITY = "iPhone Developer";
223 | COPY_PHASE_STRIP = NO;
224 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
225 | ENABLE_NS_ASSERTIONS = NO;
226 | ENABLE_STRICT_OBJC_MSGSEND = YES;
227 | GCC_C_LANGUAGE_STANDARD = gnu11;
228 | GCC_NO_COMMON_BLOCKS = YES;
229 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
230 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
231 | GCC_WARN_UNDECLARED_SELECTOR = YES;
232 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
233 | GCC_WARN_UNUSED_FUNCTION = YES;
234 | GCC_WARN_UNUSED_VARIABLE = YES;
235 | IPHONEOS_DEPLOYMENT_TARGET = 11.4;
236 | MTL_ENABLE_DEBUG_INFO = NO;
237 | SDKROOT = iphoneos;
238 | VALIDATE_PRODUCT = YES;
239 | };
240 | name = Release;
241 | };
242 | 83E6BA33211499CA00D5C0BA /* Debug */ = {
243 | isa = XCBuildConfiguration;
244 | buildSettings = {
245 | CODE_SIGN_STYLE = Automatic;
246 | DEVELOPMENT_TEAM = 32A636YFGZ;
247 | FRAMEWORK_SEARCH_PATHS = "";
248 | HEADER_SEARCH_PATHS = (
249 | "$(inherited)",
250 | "$(SRCROOT)/../../React/**",
251 | "$(SRCROOT)/../../react-native/React/**",
252 | "$(SRCROOT)/../node-modules/React/**",
253 | "$(SRCROOT)/../../react-native/Libraries/**",
254 | "$(SRCROOT)/../node-modules/react-native/Libraries/**",
255 | );
256 | OTHER_LDFLAGS = "-ObjC";
257 | PRODUCT_NAME = "$(TARGET_NAME)";
258 | SKIP_INSTALL = YES;
259 | TARGETED_DEVICE_FAMILY = "1,2";
260 | };
261 | name = Debug;
262 | };
263 | 83E6BA34211499CA00D5C0BA /* Release */ = {
264 | isa = XCBuildConfiguration;
265 | buildSettings = {
266 | CODE_SIGN_STYLE = Automatic;
267 | DEVELOPMENT_TEAM = 32A636YFGZ;
268 | FRAMEWORK_SEARCH_PATHS = "";
269 | HEADER_SEARCH_PATHS = (
270 | "$(inherited)",
271 | "$(SRCROOT)/../../React/**",
272 | "$(SRCROOT)/../../react-native/React/**",
273 | "$(SRCROOT)/../node-modules/React/**",
274 | "$(SRCROOT)/../../react-native/Libraries/**",
275 | "$(SRCROOT)/../node-modules/react-native/Libraries/**",
276 | );
277 | OTHER_LDFLAGS = "-ObjC";
278 | PRODUCT_NAME = "$(TARGET_NAME)";
279 | SKIP_INSTALL = YES;
280 | TARGETED_DEVICE_FAMILY = "1,2";
281 | };
282 | name = Release;
283 | };
284 | /* End XCBuildConfiguration section */
285 |
286 | /* Begin XCConfigurationList section */
287 | 83E6BA24211499CA00D5C0BA /* Build configuration list for PBXProject "RNBackgroundGeolocationFirebase" */ = {
288 | isa = XCConfigurationList;
289 | buildConfigurations = (
290 | 83E6BA30211499CA00D5C0BA /* Debug */,
291 | 83E6BA31211499CA00D5C0BA /* Release */,
292 | );
293 | defaultConfigurationIsVisible = 0;
294 | defaultConfigurationName = Release;
295 | };
296 | 83E6BA32211499CA00D5C0BA /* Build configuration list for PBXNativeTarget "RNBackgroundGeolocationFirebase" */ = {
297 | isa = XCConfigurationList;
298 | buildConfigurations = (
299 | 83E6BA33211499CA00D5C0BA /* Debug */,
300 | 83E6BA34211499CA00D5C0BA /* Release */,
301 | );
302 | defaultConfigurationIsVisible = 0;
303 | defaultConfigurationName = Release;
304 | };
305 | /* End XCConfigurationList section */
306 | };
307 | rootObject = 83E6BA21211499CA00D5C0BA /* Project object */;
308 | }
309 |
--------------------------------------------------------------------------------
/ios/RNBackgroundGeolocationFirebase.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/RNBackgroundGeolocationFirebase.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/RNBackgroundGeolocationFirebase/RNBackgroundGeolocationFirebase.h:
--------------------------------------------------------------------------------
1 | //
2 | // RNBackgroundGeolocationFirebase.h
3 | // RNBackgroundGeolocationFirebase
4 | //
5 | // Created by Christopher Scott on 2018-08-03.
6 | // Copyright © 2018 Christopher Scott. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import
12 | #import
13 |
14 | @interface RNBackgroundGeolocationFirebase : RCTEventEmitter
15 |
16 | @property (nonatomic) NSString* locationsCollection;
17 | @property (nonatomic) NSString* geofencesCollection;
18 | @property (nonatomic) BOOL updateSingleDocument;
19 | @end
20 |
--------------------------------------------------------------------------------
/ios/RNBackgroundGeolocationFirebase/RNBackgroundGeolocationFirebase.m:
--------------------------------------------------------------------------------
1 | //
2 | // RNBackgroundGeolocationFirebase.m
3 | // RNBackgroundGeolocationFirebase
4 | //
5 | // Created by Christopher Scott on 2018-08-03.
6 | // Copyright © 2018 Christopher Scott. All rights reserved.
7 | //
8 |
9 | #import "RNBackgroundGeolocationFirebase.h"
10 |
11 | #import
12 |
13 | #import
14 |
15 | static NSString *const PERSIST_EVENT = @"TSLocationManager:PersistEvent";
16 |
17 | static NSString *const FIELD_LOCATIONS_COLLECTION = @"locationsCollection";
18 | static NSString *const FIELD_GEOFENCES_COLLECTION = @"geofencesCollection";
19 | static NSString *const FIELD_UPDATE_SINGLE_DOCUMENT = @"updateSingleDocument";
20 |
21 | static NSString *const DEFAULT_LOCATIONS_COLLECTION = @"locations";
22 | static NSString *const DEFAULT_GEOFENCES_COLLECTION = @"geofences";
23 |
24 | @implementation RNBackgroundGeolocationFirebase {
25 | BOOL isRegistered;
26 | }
27 |
28 | RCT_EXPORT_MODULE();
29 |
30 | + (BOOL)requiresMainQueueSetup
31 | {
32 | return NO;
33 | }
34 |
35 | -(instancetype)init
36 | {
37 | self = [super init];
38 | if (self) {
39 | isRegistered = NO;
40 | _locationsCollection = DEFAULT_LOCATIONS_COLLECTION;
41 | _geofencesCollection = DEFAULT_GEOFENCES_COLLECTION;
42 | _updateSingleDocument = NO;
43 | }
44 | return self;
45 | }
46 |
47 | - (NSArray *)supportedEvents {
48 | return @[];
49 | }
50 |
51 |
52 | RCT_EXPORT_METHOD(configure:(NSDictionary*)config success:(RCTResponseSenderBlock)success failure:(RCTResponseSenderBlock)failure) {
53 | if (config[FIELD_LOCATIONS_COLLECTION]) {
54 | _locationsCollection = config[FIELD_LOCATIONS_COLLECTION];
55 | }
56 | if (config[FIELD_GEOFENCES_COLLECTION]) {
57 | _geofencesCollection = config[FIELD_GEOFENCES_COLLECTION];
58 | }
59 | if (config[FIELD_UPDATE_SINGLE_DOCUMENT]) {
60 | _updateSingleDocument = [config[FIELD_UPDATE_SINGLE_DOCUMENT] boolValue];
61 | }
62 | if (!isRegistered) {
63 | isRegistered = YES;
64 |
65 | // TODO make configurable.
66 | FIRFirestore *db = [FIRFirestore firestore];
67 | FIRFirestoreSettings *settings = [db settings];
68 | [db setSettings:settings];
69 |
70 | [[NSNotificationCenter defaultCenter] addObserver:self
71 | selector:@selector(onPersist:)
72 | name:PERSIST_EVENT
73 | object:nil];
74 | }
75 | success(@[]);
76 | }
77 |
78 | -(void) onPersist:(NSNotification*)notification {
79 | NSDictionary *data = notification.object;
80 | NSString *collectionName = (data[@"location"][@"geofence"]) ? _geofencesCollection : _locationsCollection;
81 |
82 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
83 | FIRFirestore *db = [FIRFirestore firestore];
84 | // Add a new document with a generated ID
85 | if (!self.updateSingleDocument) {
86 | __block FIRDocumentReference *ref = [[db collectionWithPath:collectionName] addDocumentWithData:notification.object completion:^(NSError * _Nullable error) {
87 | if (error != nil) {
88 | NSLog(@"Error adding document: %@", error);
89 | } else {
90 | NSLog(@"Document added with ID: %@", ref.documentID);
91 | }
92 | }];
93 | } else {
94 | [[db documentWithPath:collectionName] setData:notification.object completion:^(NSError * _Nullable error) {
95 | if (error != nil) {
96 | NSLog(@"Error writing document: %@", error);
97 | } else {
98 | NSLog(@"Document successfully written");
99 | }
100 | }];
101 | }
102 | });
103 | }
104 |
105 | -(void) dealloc {
106 | [[NSNotificationCenter defaultCenter] removeObserver:self];
107 | }
108 |
109 | @end
110 |
--------------------------------------------------------------------------------
/ios/RNBackgroundGeolocationFirebase/RNBackgroundGeolocationFirebase.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 83E6BA2E211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E6BA2D211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m */; };
11 | 83E6BA2F211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83E6BA2C211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 83E6BA27211499CA00D5C0BA /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = "include/$(PRODUCT_NAME)";
19 | dstSubfolderSpec = 16;
20 | files = (
21 | 83E6BA2F211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h in CopyFiles */,
22 | );
23 | runOnlyForDeploymentPostprocessing = 0;
24 | };
25 | /* End PBXCopyFilesBuildPhase section */
26 |
27 | /* Begin PBXFileReference section */
28 | 83E6BA29211499CA00D5C0BA /* libRNBackgroundGeolocationFirebase.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNBackgroundGeolocationFirebase.a; sourceTree = BUILT_PRODUCTS_DIR; };
29 | 83E6BA2C211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNBackgroundGeolocationFirebase.h; sourceTree = ""; };
30 | 83E6BA2D211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNBackgroundGeolocationFirebase.m; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 83E6BA26211499CA00D5C0BA /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 83E6BA20211499CA00D5C0BA = {
45 | isa = PBXGroup;
46 | children = (
47 | 83E6BA2B211499CA00D5C0BA /* RNBackgroundGeolocationFirebase */,
48 | 83E6BA2A211499CA00D5C0BA /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 83E6BA2A211499CA00D5C0BA /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 83E6BA29211499CA00D5C0BA /* libRNBackgroundGeolocationFirebase.a */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 83E6BA2B211499CA00D5C0BA /* RNBackgroundGeolocationFirebase */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 83E6BA2C211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.h */,
64 | 83E6BA2D211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m */,
65 | );
66 | path = RNBackgroundGeolocationFirebase;
67 | sourceTree = "";
68 | };
69 | /* End PBXGroup section */
70 |
71 | /* Begin PBXNativeTarget section */
72 | 83E6BA28211499CA00D5C0BA /* RNBackgroundGeolocationFirebase */ = {
73 | isa = PBXNativeTarget;
74 | buildConfigurationList = 83E6BA32211499CA00D5C0BA /* Build configuration list for PBXNativeTarget "RNBackgroundGeolocationFirebase" */;
75 | buildPhases = (
76 | 83E6BA25211499CA00D5C0BA /* Sources */,
77 | 83E6BA26211499CA00D5C0BA /* Frameworks */,
78 | 83E6BA27211499CA00D5C0BA /* CopyFiles */,
79 | );
80 | buildRules = (
81 | );
82 | dependencies = (
83 | );
84 | name = RNBackgroundGeolocationFirebase;
85 | productName = RNBackgroundGeolocationFirebase;
86 | productReference = 83E6BA29211499CA00D5C0BA /* libRNBackgroundGeolocationFirebase.a */;
87 | productType = "com.apple.product-type.library.static";
88 | };
89 | /* End PBXNativeTarget section */
90 |
91 | /* Begin PBXProject section */
92 | 83E6BA21211499CA00D5C0BA /* Project object */ = {
93 | isa = PBXProject;
94 | attributes = {
95 | LastUpgradeCheck = 0940;
96 | ORGANIZATIONNAME = "Christopher Scott";
97 | TargetAttributes = {
98 | 83E6BA28211499CA00D5C0BA = {
99 | CreatedOnToolsVersion = 9.4.1;
100 | };
101 | };
102 | };
103 | buildConfigurationList = 83E6BA24211499CA00D5C0BA /* Build configuration list for PBXProject "RNBackgroundGeolocationFirebase" */;
104 | compatibilityVersion = "Xcode 9.3";
105 | developmentRegion = en;
106 | hasScannedForEncodings = 0;
107 | knownRegions = (
108 | en,
109 | );
110 | mainGroup = 83E6BA20211499CA00D5C0BA;
111 | productRefGroup = 83E6BA2A211499CA00D5C0BA /* Products */;
112 | projectDirPath = "";
113 | projectRoot = "";
114 | targets = (
115 | 83E6BA28211499CA00D5C0BA /* RNBackgroundGeolocationFirebase */,
116 | );
117 | };
118 | /* End PBXProject section */
119 |
120 | /* Begin PBXSourcesBuildPhase section */
121 | 83E6BA25211499CA00D5C0BA /* Sources */ = {
122 | isa = PBXSourcesBuildPhase;
123 | buildActionMask = 2147483647;
124 | files = (
125 | 83E6BA2E211499CA00D5C0BA /* RNBackgroundGeolocationFirebase.m in Sources */,
126 | );
127 | runOnlyForDeploymentPostprocessing = 0;
128 | };
129 | /* End PBXSourcesBuildPhase section */
130 |
131 | /* Begin XCBuildConfiguration section */
132 | 83E6BA30211499CA00D5C0BA /* Debug */ = {
133 | isa = XCBuildConfiguration;
134 | buildSettings = {
135 | ALWAYS_SEARCH_USER_PATHS = NO;
136 | CLANG_ANALYZER_NONNULL = YES;
137 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
138 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
139 | CLANG_CXX_LIBRARY = "libc++";
140 | CLANG_ENABLE_MODULES = YES;
141 | CLANG_ENABLE_OBJC_ARC = YES;
142 | CLANG_ENABLE_OBJC_WEAK = YES;
143 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
144 | CLANG_WARN_BOOL_CONVERSION = YES;
145 | CLANG_WARN_COMMA = YES;
146 | CLANG_WARN_CONSTANT_CONVERSION = YES;
147 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
148 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
149 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
150 | CLANG_WARN_EMPTY_BODY = YES;
151 | CLANG_WARN_ENUM_CONVERSION = YES;
152 | CLANG_WARN_INFINITE_RECURSION = YES;
153 | CLANG_WARN_INT_CONVERSION = YES;
154 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
155 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
156 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
157 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
158 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
159 | CLANG_WARN_STRICT_PROTOTYPES = YES;
160 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
161 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
162 | CLANG_WARN_UNREACHABLE_CODE = YES;
163 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
164 | CODE_SIGN_IDENTITY = "iPhone Developer";
165 | COPY_PHASE_STRIP = NO;
166 | DEBUG_INFORMATION_FORMAT = dwarf;
167 | ENABLE_STRICT_OBJC_MSGSEND = YES;
168 | ENABLE_TESTABILITY = YES;
169 | GCC_C_LANGUAGE_STANDARD = gnu11;
170 | GCC_DYNAMIC_NO_PIC = NO;
171 | GCC_NO_COMMON_BLOCKS = YES;
172 | GCC_OPTIMIZATION_LEVEL = 0;
173 | GCC_PREPROCESSOR_DEFINITIONS = (
174 | "DEBUG=1",
175 | "$(inherited)",
176 | );
177 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
178 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
179 | GCC_WARN_UNDECLARED_SELECTOR = YES;
180 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
181 | GCC_WARN_UNUSED_FUNCTION = YES;
182 | GCC_WARN_UNUSED_VARIABLE = YES;
183 | IPHONEOS_DEPLOYMENT_TARGET = 11.4;
184 | MTL_ENABLE_DEBUG_INFO = YES;
185 | ONLY_ACTIVE_ARCH = YES;
186 | SDKROOT = iphoneos;
187 | };
188 | name = Debug;
189 | };
190 | 83E6BA31211499CA00D5C0BA /* Release */ = {
191 | isa = XCBuildConfiguration;
192 | buildSettings = {
193 | ALWAYS_SEARCH_USER_PATHS = NO;
194 | CLANG_ANALYZER_NONNULL = YES;
195 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
196 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
197 | CLANG_CXX_LIBRARY = "libc++";
198 | CLANG_ENABLE_MODULES = YES;
199 | CLANG_ENABLE_OBJC_ARC = YES;
200 | CLANG_ENABLE_OBJC_WEAK = YES;
201 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
202 | CLANG_WARN_BOOL_CONVERSION = YES;
203 | CLANG_WARN_COMMA = YES;
204 | CLANG_WARN_CONSTANT_CONVERSION = YES;
205 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
206 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
207 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
208 | CLANG_WARN_EMPTY_BODY = YES;
209 | CLANG_WARN_ENUM_CONVERSION = YES;
210 | CLANG_WARN_INFINITE_RECURSION = YES;
211 | CLANG_WARN_INT_CONVERSION = YES;
212 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
213 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
214 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
215 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
216 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
217 | CLANG_WARN_STRICT_PROTOTYPES = YES;
218 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
219 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
220 | CLANG_WARN_UNREACHABLE_CODE = YES;
221 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
222 | CODE_SIGN_IDENTITY = "iPhone Developer";
223 | COPY_PHASE_STRIP = NO;
224 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
225 | ENABLE_NS_ASSERTIONS = NO;
226 | ENABLE_STRICT_OBJC_MSGSEND = YES;
227 | GCC_C_LANGUAGE_STANDARD = gnu11;
228 | GCC_NO_COMMON_BLOCKS = YES;
229 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
230 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
231 | GCC_WARN_UNDECLARED_SELECTOR = YES;
232 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
233 | GCC_WARN_UNUSED_FUNCTION = YES;
234 | GCC_WARN_UNUSED_VARIABLE = YES;
235 | IPHONEOS_DEPLOYMENT_TARGET = 11.4;
236 | MTL_ENABLE_DEBUG_INFO = NO;
237 | SDKROOT = iphoneos;
238 | VALIDATE_PRODUCT = YES;
239 | };
240 | name = Release;
241 | };
242 | 83E6BA33211499CA00D5C0BA /* Debug */ = {
243 | isa = XCBuildConfiguration;
244 | buildSettings = {
245 | CODE_SIGN_STYLE = Automatic;
246 | DEVELOPMENT_TEAM = 32A636YFGZ;
247 | OTHER_LDFLAGS = "-ObjC";
248 | PRODUCT_NAME = "$(TARGET_NAME)";
249 | SKIP_INSTALL = YES;
250 | TARGETED_DEVICE_FAMILY = "1,2";
251 | };
252 | name = Debug;
253 | };
254 | 83E6BA34211499CA00D5C0BA /* Release */ = {
255 | isa = XCBuildConfiguration;
256 | buildSettings = {
257 | CODE_SIGN_STYLE = Automatic;
258 | DEVELOPMENT_TEAM = 32A636YFGZ;
259 | OTHER_LDFLAGS = "-ObjC";
260 | PRODUCT_NAME = "$(TARGET_NAME)";
261 | SKIP_INSTALL = YES;
262 | TARGETED_DEVICE_FAMILY = "1,2";
263 | };
264 | name = Release;
265 | };
266 | /* End XCBuildConfiguration section */
267 |
268 | /* Begin XCConfigurationList section */
269 | 83E6BA24211499CA00D5C0BA /* Build configuration list for PBXProject "RNBackgroundGeolocationFirebase" */ = {
270 | isa = XCConfigurationList;
271 | buildConfigurations = (
272 | 83E6BA30211499CA00D5C0BA /* Debug */,
273 | 83E6BA31211499CA00D5C0BA /* Release */,
274 | );
275 | defaultConfigurationIsVisible = 0;
276 | defaultConfigurationName = Release;
277 | };
278 | 83E6BA32211499CA00D5C0BA /* Build configuration list for PBXNativeTarget "RNBackgroundGeolocationFirebase" */ = {
279 | isa = XCConfigurationList;
280 | buildConfigurations = (
281 | 83E6BA33211499CA00D5C0BA /* Debug */,
282 | 83E6BA34211499CA00D5C0BA /* Release */,
283 | );
284 | defaultConfigurationIsVisible = 0;
285 | defaultConfigurationName = Release;
286 | };
287 | /* End XCConfigurationList section */
288 | };
289 | rootObject = 83E6BA21211499CA00D5C0BA /* Project object */;
290 | }
291 |
--------------------------------------------------------------------------------
/ios/RNBackgroundGeolocationFirebase/RNBackgroundGeolocationFirebase.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/RNBackgroundGeolocationFirebase/RNBackgroundGeolocationFirebase.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-background-geolocation-firebase",
3 | "version": "0.5.0",
4 | "description": "Firebase Adapter for react-native-background-geolocation",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "repository": {
9 | "type": "git",
10 | "url": "git+ssh://git@github.com/transistorsoft/react-native-background-geolocation-firebase.git"
11 | },
12 | "keywords": [
13 | "react-native",
14 | "react-component",
15 | "ios",
16 | "android",
17 | "background",
18 | "geolocation",
19 | "firebase",
20 | "firestore"
21 | ],
22 | "author": "Chris Scott ",
23 | "license": "MIT",
24 | "bugs": {
25 | "url": "https://github.com/transistorsoft/react-native-background-geolocation-firebase/issues"
26 | },
27 | "homepage": "https://github.com/transistorsoft/react-native-background-geolocation-firebase",
28 | "peerDependencies": {
29 | "react-native": ">=0.36.0"
30 | },
31 | "devDependencies": {
32 | "react": "16.4.1",
33 | "react-native": "0.56.0"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/react-native.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // config for a library is scoped under "dependency" key
3 | dependency: {
4 | platforms: {
5 | ios: {},
6 | android: {}, // projects are grouped into "platforms"
7 | },
8 | assets: [], // stays the same
9 | },
10 | };
11 |
--------------------------------------------------------------------------------