react-native-background-geolocation 5.0.0-beta.1 → 5.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/RNBackgroundGeolocation.podspec +24 -7
- package/android/.settings/org.eclipse.buildship.core.prefs +1 -1
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/RNBackgroundGeolocation.java +7 -8
- package/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/RNBackgroundGeolocationModule.java +26 -18
- package/expo/plugin/build/androidPlugin.js +5 -11
- package/expo/plugin/build/androidPlugin.js.map +1 -1
- package/ios/RNBackgroundGeolocation/RNBackgroundGeolocation.h +6 -0
- package/ios/RNBackgroundGeolocation/{RNBackgroundGeolocation.m → RNBackgroundGeolocation.mm} +89 -52
- package/package.json +16 -12
- package/src/Logger.js +16 -25
- package/src/NativeModule.js +61 -18
- package/src/index.js +10 -10
- package/src/specs/NativeRNBackgroundGeolocation.js +104 -0
package/README.md
CHANGED
|
@@ -47,18 +47,18 @@ Also available for [Flutter](https://github.com/transistorsoft/flutter_backgroun
|
|
|
47
47
|
### With *Expo*
|
|
48
48
|
|
|
49
49
|
```shell
|
|
50
|
-
npx expo install react-native-background-geolocation
|
|
50
|
+
npx expo install react-native-background-geolocation@beta
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
### With `yarn`
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
|
-
yarn add react-native-background-geolocation
|
|
56
|
+
yarn add react-native-background-geolocation@beta
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
### With `npm`
|
|
60
60
|
```
|
|
61
|
-
$ npm install react-native-background-geolocation --save
|
|
61
|
+
$ npm install react-native-background-geolocation@beta --save
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
## :large_blue_diamond: Setup Guides
|
|
@@ -14,15 +14,32 @@ Pod::Spec.new do |s|
|
|
|
14
14
|
s.homepage = package['homepage']
|
|
15
15
|
s.license = package['license']
|
|
16
16
|
s.author = package['author']
|
|
17
|
-
s.source = {
|
|
17
|
+
s.source = {
|
|
18
|
+
:git => 'https://github.com/transistorsoft/react-native-background-geolocation.git',
|
|
19
|
+
:tag => s.version
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
s.platform = :ios, '12.0'
|
|
23
|
+
s.requires_arc = true
|
|
24
|
+
s.static_framework = true
|
|
19
25
|
|
|
20
|
-
s.
|
|
21
|
-
s.static_framework = true
|
|
26
|
+
s.source_files = 'ios/RNBackgroundGeolocation/*.{h,m,mm}'
|
|
22
27
|
s.preserve_paths = 'docs', 'CHANGELOG.md', 'LICENSE', 'package.json', 'RNBackgroundGeolocation.ios.js'
|
|
28
|
+
|
|
23
29
|
s.dependency 'CocoaLumberjack', '~> 3.8.5'
|
|
24
30
|
s.dependency 'TSLocationManager', '~> 4.0.0-beta.5'
|
|
25
|
-
|
|
26
|
-
s.libraries = 'sqlite3', 'z', 'stdc++'
|
|
27
|
-
s.resource_bundles
|
|
28
|
-
|
|
31
|
+
|
|
32
|
+
s.libraries = 'sqlite3', 'z', 'stdc++'
|
|
33
|
+
s.resource_bundles = {
|
|
34
|
+
'TSLocationManagerPrivacy' => ['ios/Resources/PrivacyInfo.xcprivacy']
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# React Native dependencies:
|
|
38
|
+
# - For RN >= 0.71, use the helper which wires up React-Core, ReactCodegen, etc.
|
|
39
|
+
# - For older RN, fall back to React-Core manually.
|
|
40
|
+
if defined?(install_modules_dependencies)
|
|
41
|
+
install_modules_dependencies(s)
|
|
42
|
+
else
|
|
43
|
+
s.dependency 'React-Core'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -2,7 +2,7 @@ arguments=--init-script /var/folders/qk/r2r49k7527b6r81484vtk0g40000gn/T/db3b08f
|
|
|
2
2
|
auto.sync=false
|
|
3
3
|
build.scans.enabled=false
|
|
4
4
|
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(8.9))
|
|
5
|
-
connection.project.dir
|
|
5
|
+
connection.project.dir=
|
|
6
6
|
eclipse.preferences.version=1
|
|
7
7
|
gradle.user.home=
|
|
8
8
|
java.home=/opt/homebrew/Cellar/openjdk@17/17.0.15/libexec/openjdk.jdk/Contents/Home
|
package/android/build.gradle
CHANGED
|
@@ -8,25 +8,24 @@ import com.facebook.react.ReactPackage;
|
|
|
8
8
|
import com.facebook.react.bridge.NativeModule;
|
|
9
9
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
10
|
import com.facebook.react.uimanager.ViewManager;
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
+
* React Native package for RNBackgroundGeolocation.
|
|
15
|
+
* This is used by the old architecture and by autolinking.
|
|
16
|
+
* The new architecture / TurboModule path is driven by codegen + RNBackgroundGeolocationModule.
|
|
17
|
+
*
|
|
14
18
|
* Created by chris on 2015-10-30.
|
|
15
19
|
*/
|
|
16
20
|
public class RNBackgroundGeolocation implements ReactPackage {
|
|
17
21
|
|
|
18
|
-
@Override
|
|
22
|
+
@Override
|
|
23
|
+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
19
24
|
List<NativeModule> modules = new ArrayList<>();
|
|
20
25
|
modules.add(new RNBackgroundGeolocationModule(reactContext));
|
|
21
26
|
return modules;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
// Depreciated RN 0.47
|
|
25
|
-
//@Override
|
|
26
|
-
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
27
|
-
return Collections.emptyList();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
29
|
@Override
|
|
31
30
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
32
31
|
return Collections.emptyList();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.transistorsoft.rnbackgroundgeolocation;
|
|
2
2
|
|
|
3
|
+
import com.transistorsoft.rnbackgroundgeolocation.NativeRNBackgroundGeolocationSpec;
|
|
4
|
+
|
|
3
5
|
import android.Manifest;
|
|
4
6
|
import android.app.Activity;
|
|
5
7
|
import android.content.Context;
|
|
@@ -78,7 +80,7 @@ import java.util.Map;
|
|
|
78
80
|
*/
|
|
79
81
|
@ReactModule(name = "RNBackgroundGeolocation")
|
|
80
82
|
public class RNBackgroundGeolocationModule
|
|
81
|
-
extends
|
|
83
|
+
extends NativeRNBackgroundGeolocationSpec
|
|
82
84
|
implements ActivityEventListener, LifecycleEventListener {
|
|
83
85
|
|
|
84
86
|
private static final String TAG = "TSLocationManager";
|
|
@@ -467,7 +469,7 @@ public class RNBackgroundGeolocationModule
|
|
|
467
469
|
}
|
|
468
470
|
|
|
469
471
|
@ReactMethod
|
|
470
|
-
public void changePace(final
|
|
472
|
+
public void changePace(final boolean moving, final Promise response) {
|
|
471
473
|
getAdapter().changePace(moving, new TSCallback() {
|
|
472
474
|
@Override public void onSuccess() { response.resolve(moving); }
|
|
473
475
|
@Override public void onFailure(String error) { response.reject(error); }
|
|
@@ -616,10 +618,12 @@ public class RNBackgroundGeolocationModule
|
|
|
616
618
|
if (options.hasKey("desiredAccuracy")) { builder.setDesiredAccuracy(options.getInt("desiredAccuracy")); }
|
|
617
619
|
|
|
618
620
|
getAdapter().watchPosition(builder.build());
|
|
619
|
-
|
|
621
|
+
// TODO Implement watchId for android.
|
|
622
|
+
response.resolve(-1);
|
|
620
623
|
}
|
|
621
624
|
@ReactMethod
|
|
622
|
-
public void stopWatchPosition(final Promise response) {
|
|
625
|
+
public void stopWatchPosition(double watchId, final Promise response) {
|
|
626
|
+
// TODO Implement watchId for android.
|
|
623
627
|
getAdapter().stopWatchPosition(new TSCallback() {
|
|
624
628
|
@Override public void onSuccess() {
|
|
625
629
|
response.resolve(true);
|
|
@@ -634,7 +638,7 @@ public class RNBackgroundGeolocationModule
|
|
|
634
638
|
response.resolve(getAdapter().getOdometer());
|
|
635
639
|
}
|
|
636
640
|
@ReactMethod
|
|
637
|
-
public void setOdometer(
|
|
641
|
+
public void setOdometer(double value, final Promise response) {
|
|
638
642
|
getAdapter().setOdometer(value, new TSLocationCallback() {
|
|
639
643
|
@Override public void onLocation(LocationEvent event) {
|
|
640
644
|
response.resolve(mapToWritableMap(event.toMap()));
|
|
@@ -783,8 +787,8 @@ public class RNBackgroundGeolocationModule
|
|
|
783
787
|
|
|
784
788
|
// TODO Rename #finish -> #stopBackgroundTask
|
|
785
789
|
@ReactMethod
|
|
786
|
-
public void finish(
|
|
787
|
-
getAdapter().stopBackgroundTask(taskId);
|
|
790
|
+
public void finish(double taskId, Promise response) {
|
|
791
|
+
getAdapter().stopBackgroundTask((int) taskId);
|
|
788
792
|
response.resolve(taskId);
|
|
789
793
|
}
|
|
790
794
|
|
|
@@ -793,7 +797,7 @@ public class RNBackgroundGeolocationModule
|
|
|
793
797
|
* @param taskId*
|
|
794
798
|
*/
|
|
795
799
|
@ReactMethod
|
|
796
|
-
public void finishHeadlessTask(
|
|
800
|
+
public void finishHeadlessTask(double taskId, Promise response) {
|
|
797
801
|
EventBus eventBus = EventBus.getDefault();
|
|
798
802
|
if (!eventBus.hasSubscriberForEvent(HeadlessEvent.class)) {
|
|
799
803
|
// This shouldn't happen. In order for this method to even be called, it MUST have been executed from within the consumer's
|
|
@@ -803,7 +807,7 @@ public class RNBackgroundGeolocationModule
|
|
|
803
807
|
response.reject(message);
|
|
804
808
|
return;
|
|
805
809
|
}
|
|
806
|
-
FinishHeadlessTaskEvent event = new FinishHeadlessTaskEvent(getReactApplicationContext(), taskId);
|
|
810
|
+
FinishHeadlessTaskEvent event = new FinishHeadlessTaskEvent(getReactApplicationContext(), (int) taskId);
|
|
807
811
|
eventBus.post(event);
|
|
808
812
|
response.resolve(true);
|
|
809
813
|
}
|
|
@@ -885,7 +889,7 @@ public class RNBackgroundGeolocationModule
|
|
|
885
889
|
}
|
|
886
890
|
|
|
887
891
|
@ReactMethod
|
|
888
|
-
public void log(String level, String message, Promise response)
|
|
892
|
+
public void log(String level, String message, Promise response) {
|
|
889
893
|
TSLog.log(level, message);
|
|
890
894
|
response.resolve(true);
|
|
891
895
|
}
|
|
@@ -946,13 +950,17 @@ public class RNBackgroundGeolocationModule
|
|
|
946
950
|
}
|
|
947
951
|
|
|
948
952
|
@ReactMethod
|
|
949
|
-
public void requestSettings(ReadableMap args, Promise response)
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
953
|
+
public void requestSettings(ReadableMap args, Promise response) {
|
|
954
|
+
try {
|
|
955
|
+
String action = args.getString("action");
|
|
956
|
+
DeviceSettingsRequest request = getAdapter().requestSettings(action);
|
|
957
|
+
if (request != null) {
|
|
958
|
+
response.resolve(mapToWritableMap(request.toMap()));
|
|
959
|
+
} else {
|
|
960
|
+
response.reject("Failed to find " + action + " screen for device " + Build.MANUFACTURER + " " + Build.MODEL + "@" + Build.VERSION.RELEASE);
|
|
961
|
+
}
|
|
962
|
+
} catch (Exception e) {
|
|
963
|
+
response.reject(e.getMessage(), e);
|
|
956
964
|
}
|
|
957
965
|
}
|
|
958
966
|
|
|
@@ -1002,7 +1010,7 @@ public class RNBackgroundGeolocationModule
|
|
|
1002
1010
|
}
|
|
1003
1011
|
|
|
1004
1012
|
@ReactMethod
|
|
1005
|
-
public void removeListeners(
|
|
1013
|
+
public void removeListeners(double count) {
|
|
1006
1014
|
// Keep: Required for RN built-in NativeEventEmitter calls.
|
|
1007
1015
|
}
|
|
1008
1016
|
|
|
@@ -34,14 +34,6 @@ if (!MODULE_NAME) {
|
|
|
34
34
|
}
|
|
35
35
|
const { addMetaDataItemToMainApplication, removeMetaDataItemFromMainApplication, getMainApplicationOrThrow } = config_plugins_1.AndroidConfig.Manifest;
|
|
36
36
|
const androidPlugin = (config, props = {}) => {
|
|
37
|
-
config = (0, config_plugins_1.withProjectBuildGradle)(config, ({ modResults, ...subConfig }) => {
|
|
38
|
-
if (modResults.language !== 'groovy') {
|
|
39
|
-
config_plugins_1.WarningAggregator.addWarningAndroid('withBackgroundGeolocation', `Cannot automatically configure project build.gradle if it's not groovy`);
|
|
40
|
-
return { modResults, ...subConfig };
|
|
41
|
-
}
|
|
42
|
-
modResults.contents = applyMavenUrl(modResults.contents);
|
|
43
|
-
return { modResults, ...subConfig };
|
|
44
|
-
});
|
|
45
37
|
config = (0, config_plugins_1.withAppBuildGradle)(config, ({ modResults, ...subConfig }) => {
|
|
46
38
|
if (modResults.language !== 'groovy') {
|
|
47
39
|
config_plugins_1.WarningAggregator.addWarningAndroid('withBackgroundGeolocation', `Cannot automatically configure project build.gradle if it's not groovy`);
|
|
@@ -51,17 +43,19 @@ const androidPlugin = (config, props = {}) => {
|
|
|
51
43
|
return { modResults, ...subConfig };
|
|
52
44
|
});
|
|
53
45
|
config = (0, config_plugins_1.withAndroidManifest)(config, async (config) => {
|
|
54
|
-
console.log("[react-native-background-geolocation] Adding license-
|
|
46
|
+
console.log("[react-native-background-geolocation] Adding license-key to AndroidManifest:", props);
|
|
55
47
|
const mainApplication = getMainApplicationOrThrow(config.modResults);
|
|
56
48
|
addMetaDataItemToMainApplication(mainApplication, META_LICENSE_KEY, props.license || "UNDEFINED");
|
|
57
49
|
if (props.hmsLicense) {
|
|
58
|
-
|
|
50
|
+
console.log("[react-native-background-geolocation] ℹ️ hmsLicense is no longer required. The new TSLocationManager v4 license format applies HMS functionality as an entitlement within the BackgroundGeolocation license key. You can remove the 'hmsLicense' from your app.json. Removing from AndroidManifest.");
|
|
51
|
+
removeMetaDataItemFromMainApplication(mainApplication, META_HMS_LICENSE_KEY);
|
|
59
52
|
}
|
|
60
53
|
else {
|
|
61
54
|
removeMetaDataItemFromMainApplication(mainApplication, META_HMS_LICENSE_KEY);
|
|
62
55
|
}
|
|
63
56
|
if (props.polygonLicense) {
|
|
64
|
-
|
|
57
|
+
console.log("[react-native-background-geolocation] ℹ️ polygonLicense is no longer required. The new TSLocationManager v4 license format applies Polygon functionality as an entitlement within the BackgroundGeolocation license key. You can remove the 'polygonLicense' from your app.json. Removing from AndroidManifest.");
|
|
58
|
+
removeMetaDataItemFromMainApplication(mainApplication, META_POLYGON_LICENSE_KEY);
|
|
65
59
|
}
|
|
66
60
|
else {
|
|
67
61
|
removeMetaDataItemFromMainApplication(mainApplication, META_POLYGON_LICENSE_KEY);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"androidPlugin.js","sourceRoot":"","sources":["../src/androidPlugin.ts"],"names":[],"mappings":";;;;;AAAA,yDAQ8B;AAE9B,gFAGuD;AASvD,gDAAwB;AACxB,4CAAoB;AAEpB,MAAM,aAAa,GAAG,qCAAqC,CAAC;AAC5D,MAAM,cAAc,GAAG,aAAa,GAAG,UAAU,CAAC;AAElD,MAAM,gBAAgB,GAAG,4CAA4C,CAAC;AACtE,MAAM,oBAAoB,GAAG,gDAAgD,CAAC;AAC9E,MAAM,wBAAwB,GAAG,oDAAoD,CAAC;AAEtF,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAiB,EAAE;IAC3D,MAAM,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACtD,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC;QACzD,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;QAC1D,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,MAAM,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,2DAA2D;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC,CAAC;AACF,MAAM,WAAW,GAAG,qBAAqB,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;IACjB,OAAO,CAAC,KAAK,CAAC,2BAA2B,aAAa,SAAS,cAAc,mBAAmB,CAAC,CAAC;IAClG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,EACJ,gCAAgC,EAChC,qCAAqC,EACrC,yBAAyB,EAC1B,GAAG,8BAAa,CAAC,QAAQ,CAAC;AAG3B,MAAM,aAAa,GAAwB,CAAC,MAAM,EAAE,KAAK,GAAC,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"androidPlugin.js","sourceRoot":"","sources":["../src/androidPlugin.ts"],"names":[],"mappings":"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"}
|
package/ios/RNBackgroundGeolocation/{RNBackgroundGeolocation.m → RNBackgroundGeolocation.mm}
RENAMED
|
@@ -6,6 +6,18 @@
|
|
|
6
6
|
// Copyright (c) 2015 Transistor Software. All rights reserved.
|
|
7
7
|
//
|
|
8
8
|
#import "RNBackgroundGeolocation.h"
|
|
9
|
+
|
|
10
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
11
|
+
#import <ReactCodegen/RNBackgroundGeolocation/RNBackgroundGeolocation.h>
|
|
12
|
+
|
|
13
|
+
#import <React/RCTBridge+Private.h>
|
|
14
|
+
#import <React/RCTUtils.h>
|
|
15
|
+
|
|
16
|
+
using namespace facebook;
|
|
17
|
+
using namespace facebook::react;
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
|
|
9
21
|
#import <Foundation/Foundation.h>
|
|
10
22
|
#import <CoreLocation/CoreLocation.h>
|
|
11
23
|
#import <UIKit/UIKit.h>
|
|
@@ -140,8 +152,8 @@ RCT_EXPORT_METHOD(registerPlugin:(NSString*)pluginName)
|
|
|
140
152
|
}
|
|
141
153
|
|
|
142
154
|
RCT_EXPORT_METHOD(reset:(NSDictionary*)params
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
156
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
145
157
|
{
|
|
146
158
|
TSConfig *config = [TSConfig sharedInstance];
|
|
147
159
|
@try {
|
|
@@ -163,8 +175,8 @@ RCT_EXPORT_METHOD(reset:(NSDictionary*)params
|
|
|
163
175
|
* configure plugin
|
|
164
176
|
*/
|
|
165
177
|
RCT_EXPORT_METHOD(ready:(NSDictionary*)params
|
|
166
|
-
|
|
167
|
-
|
|
178
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
179
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
168
180
|
{
|
|
169
181
|
BOOL resetFlag = (params[@"reset"]) ? [params[@"reset"] boolValue] : YES;
|
|
170
182
|
|
|
@@ -210,14 +222,14 @@ RCT_EXPORT_METHOD(ready:(NSDictionary*)params
|
|
|
210
222
|
|
|
211
223
|
|
|
212
224
|
|
|
213
|
-
RCT_EXPORT_METHOD(removeAllListeners:(RCTPromiseResolveBlock)resolve
|
|
225
|
+
RCT_EXPORT_METHOD(removeAllListeners:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
214
226
|
{
|
|
215
227
|
[locationManager removeListeners];
|
|
216
228
|
resolve(@(YES));
|
|
217
229
|
}
|
|
218
230
|
|
|
219
231
|
|
|
220
|
-
RCT_EXPORT_METHOD(setConfig:(NSDictionary*)params
|
|
232
|
+
RCT_EXPORT_METHOD(setConfig:(NSDictionary*)params resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
221
233
|
{
|
|
222
234
|
TSConfig *config = [TSConfig sharedInstance];
|
|
223
235
|
[config updateWithDictionary:params];
|
|
@@ -229,7 +241,7 @@ RCT_EXPORT_METHOD(setConfig:(NSDictionary*)params resolver:(RCTPromiseResolveBlo
|
|
|
229
241
|
return [locationManager getState];
|
|
230
242
|
}
|
|
231
243
|
|
|
232
|
-
RCT_EXPORT_METHOD(getState:(RCTPromiseResolveBlock)resolve
|
|
244
|
+
RCT_EXPORT_METHOD(getState:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
233
245
|
{
|
|
234
246
|
NSDictionary *state = [locationManager getState];
|
|
235
247
|
resolve(state);
|
|
@@ -238,7 +250,7 @@ RCT_EXPORT_METHOD(getState:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseR
|
|
|
238
250
|
/**
|
|
239
251
|
* Turn on background geolocation
|
|
240
252
|
*/
|
|
241
|
-
RCT_EXPORT_METHOD(start:(RCTPromiseResolveBlock)resolve
|
|
253
|
+
RCT_EXPORT_METHOD(start:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
242
254
|
{
|
|
243
255
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
244
256
|
[self.locationManager start];
|
|
@@ -248,7 +260,7 @@ RCT_EXPORT_METHOD(start:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseReje
|
|
|
248
260
|
/**
|
|
249
261
|
* Turn it off
|
|
250
262
|
*/
|
|
251
|
-
RCT_EXPORT_METHOD(stop:(RCTPromiseResolveBlock)resolve
|
|
263
|
+
RCT_EXPORT_METHOD(stop:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
252
264
|
{
|
|
253
265
|
[locationManager stop];
|
|
254
266
|
resolve([locationManager getState]);
|
|
@@ -257,7 +269,7 @@ RCT_EXPORT_METHOD(stop:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejec
|
|
|
257
269
|
/**
|
|
258
270
|
* Start schedule
|
|
259
271
|
*/
|
|
260
|
-
RCT_EXPORT_METHOD(startSchedule:(RCTPromiseResolveBlock)resolve
|
|
272
|
+
RCT_EXPORT_METHOD(startSchedule:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
261
273
|
{
|
|
262
274
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
263
275
|
[self.locationManager startSchedule];
|
|
@@ -268,7 +280,7 @@ RCT_EXPORT_METHOD(startSchedule:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
|
|
268
280
|
/**
|
|
269
281
|
* Stop schedule
|
|
270
282
|
*/
|
|
271
|
-
RCT_EXPORT_METHOD(stopSchedule:(RCTPromiseResolveBlock)resolve
|
|
283
|
+
RCT_EXPORT_METHOD(stopSchedule:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
272
284
|
{
|
|
273
285
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
274
286
|
[self.locationManager stopSchedule];
|
|
@@ -279,7 +291,7 @@ RCT_EXPORT_METHOD(stopSchedule:(RCTPromiseResolveBlock)resolve rejecter:(RCTProm
|
|
|
279
291
|
/**
|
|
280
292
|
* Start schedule
|
|
281
293
|
*/
|
|
282
|
-
RCT_EXPORT_METHOD(startGeofences:(RCTPromiseResolveBlock)resolve
|
|
294
|
+
RCT_EXPORT_METHOD(startGeofences:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
283
295
|
{
|
|
284
296
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
285
297
|
TSConfig *config = [TSConfig sharedInstance];
|
|
@@ -292,26 +304,34 @@ RCT_EXPORT_METHOD(startGeofences:(RCTPromiseResolveBlock)resolve rejecter:(RCTPr
|
|
|
292
304
|
* Change pace to moving/stopped
|
|
293
305
|
* @param {Boolean} isMoving
|
|
294
306
|
*/
|
|
295
|
-
RCT_EXPORT_METHOD(changePace:(BOOL)moving
|
|
307
|
+
RCT_EXPORT_METHOD(changePace:(BOOL)moving resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
296
308
|
{
|
|
297
309
|
[locationManager changePace:moving];
|
|
298
310
|
resolve(@(YES));
|
|
299
311
|
}
|
|
300
312
|
|
|
301
|
-
RCT_EXPORT_METHOD(beginBackgroundTask:(RCTPromiseResolveBlock)resolve
|
|
313
|
+
RCT_EXPORT_METHOD(beginBackgroundTask:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
302
314
|
{
|
|
303
315
|
resolve(@([locationManager createBackgroundTask]));
|
|
304
316
|
}
|
|
305
317
|
/**
|
|
306
318
|
* Called by js to signify the end of a background-geolocation event
|
|
307
319
|
*/
|
|
308
|
-
RCT_EXPORT_METHOD(finish:(
|
|
320
|
+
RCT_EXPORT_METHOD(finish:(NSInteger)taskId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
309
321
|
{
|
|
310
322
|
[locationManager stopBackgroundTask:taskId];
|
|
311
323
|
resolve(@(taskId));
|
|
312
324
|
}
|
|
313
325
|
|
|
314
|
-
RCT_EXPORT_METHOD(
|
|
326
|
+
RCT_EXPORT_METHOD(finishHeadlessTask:(double)taskId
|
|
327
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
328
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
329
|
+
{
|
|
330
|
+
// iOS doesn't use RN Headless JS.
|
|
331
|
+
resolve(@(YES));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
RCT_EXPORT_METHOD(getCurrentPosition:(NSDictionary*)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
315
335
|
{
|
|
316
336
|
TSCurrentPositionRequest *request = [TSCurrentPositionRequest requestWithSuccess:^(TSLocationEvent *event) {
|
|
317
337
|
resolve([event toDictionary]);
|
|
@@ -340,7 +360,7 @@ RCT_EXPORT_METHOD(getCurrentPosition:(NSDictionary*)options resolver:(RCTPromise
|
|
|
340
360
|
[locationManager getCurrentPosition:request];
|
|
341
361
|
}
|
|
342
362
|
|
|
343
|
-
RCT_EXPORT_METHOD(watchPosition:(NSDictionary*)options
|
|
363
|
+
RCT_EXPORT_METHOD(watchPosition:(NSDictionary*)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
344
364
|
{
|
|
345
365
|
TSWatchPositionRequest *request = [TSWatchPositionRequest requestWithSuccess:^(TSLocationStreamEvent *event) {
|
|
346
366
|
[self sendEvent:EVENT_WATCHPOSITION body:[event toDictionary]];
|
|
@@ -354,17 +374,17 @@ RCT_EXPORT_METHOD(watchPosition:(NSDictionary*)options resolver:(RCTPromiseResol
|
|
|
354
374
|
if (options[@"extras"]) { request.extras = options[@"extras"]; }
|
|
355
375
|
if (options[@"timeout"]) { request.timeout = [options[@"timeout"] doubleValue]; }
|
|
356
376
|
|
|
357
|
-
|
|
377
|
+
NSInteger watchId = [locationManager watchPosition:request];
|
|
358
378
|
resolve(@(watchId));
|
|
359
379
|
}
|
|
360
380
|
|
|
361
|
-
RCT_EXPORT_METHOD(stopWatchPosition:(
|
|
381
|
+
RCT_EXPORT_METHOD(stopWatchPosition:(NSInteger)watchId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
362
382
|
{
|
|
363
383
|
[locationManager stopWatchPosition:watchId];
|
|
364
384
|
resolve(@(YES));
|
|
365
385
|
}
|
|
366
386
|
|
|
367
|
-
RCT_EXPORT_METHOD(getLocations:(RCTPromiseResolveBlock)resolve
|
|
387
|
+
RCT_EXPORT_METHOD(getLocations:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
368
388
|
{
|
|
369
389
|
[locationManager getLocations:^(NSArray* records) {
|
|
370
390
|
resolve(records);
|
|
@@ -373,7 +393,7 @@ RCT_EXPORT_METHOD(getLocations:(RCTPromiseResolveBlock)resolve rejecter:(RCTProm
|
|
|
373
393
|
}];
|
|
374
394
|
}
|
|
375
395
|
|
|
376
|
-
RCT_EXPORT_METHOD(sync:(RCTPromiseResolveBlock)resolve
|
|
396
|
+
RCT_EXPORT_METHOD(sync:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
377
397
|
{
|
|
378
398
|
[locationManager sync:^(NSArray* records) {
|
|
379
399
|
resolve(records);
|
|
@@ -382,7 +402,7 @@ RCT_EXPORT_METHOD(sync:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejec
|
|
|
382
402
|
}];
|
|
383
403
|
}
|
|
384
404
|
|
|
385
|
-
RCT_EXPORT_METHOD(getGeofences:(RCTPromiseResolveBlock)resolve
|
|
405
|
+
RCT_EXPORT_METHOD(getGeofences:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
386
406
|
{
|
|
387
407
|
[locationManager getGeofences:^(NSArray* geofences) {
|
|
388
408
|
NSMutableArray *result = [NSMutableArray new];
|
|
@@ -393,7 +413,7 @@ RCT_EXPORT_METHOD(getGeofences:(RCTPromiseResolveBlock)resolve rejecter:(RCTProm
|
|
|
393
413
|
}];
|
|
394
414
|
}
|
|
395
415
|
|
|
396
|
-
RCT_EXPORT_METHOD(getGeofence:(NSString*)identifier
|
|
416
|
+
RCT_EXPORT_METHOD(getGeofence:(NSString*)identifier resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
397
417
|
{
|
|
398
418
|
[locationManager getGeofence:identifier success:^(TSGeofence* geofence) {
|
|
399
419
|
resolve([geofence toDictionary]);
|
|
@@ -402,14 +422,14 @@ RCT_EXPORT_METHOD(getGeofence:(NSString*)identifier resolver:(RCTPromiseResolveB
|
|
|
402
422
|
}];
|
|
403
423
|
}
|
|
404
424
|
|
|
405
|
-
RCT_EXPORT_METHOD(geofenceExists:(NSString*)identifier
|
|
425
|
+
RCT_EXPORT_METHOD(geofenceExists:(NSString*)identifier resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
406
426
|
{
|
|
407
427
|
[locationManager geofenceExists:identifier callback:^(BOOL exists) {
|
|
408
428
|
resolve(@(exists));
|
|
409
429
|
}];
|
|
410
430
|
}
|
|
411
431
|
|
|
412
|
-
RCT_EXPORT_METHOD(addGeofence:(NSDictionary*)params
|
|
432
|
+
RCT_EXPORT_METHOD(addGeofence:(NSDictionary*)params resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
413
433
|
{
|
|
414
434
|
TSGeofence *geofence = [self buildGeofence:params];
|
|
415
435
|
if (!geofence) {
|
|
@@ -424,7 +444,7 @@ RCT_EXPORT_METHOD(addGeofence:(NSDictionary*)params resolver:(RCTPromiseResolveB
|
|
|
424
444
|
}];
|
|
425
445
|
}
|
|
426
446
|
|
|
427
|
-
RCT_EXPORT_METHOD(addGeofences:(NSArray*) data
|
|
447
|
+
RCT_EXPORT_METHOD(addGeofences:(NSArray*) data resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
428
448
|
{
|
|
429
449
|
NSMutableArray *geofences = [NSMutableArray new];
|
|
430
450
|
for (NSDictionary *params in data) {
|
|
@@ -462,7 +482,7 @@ RCT_EXPORT_METHOD(addGeofences:(NSArray*) data resolver:(RCTPromiseResolveBlock)
|
|
|
462
482
|
vertices: params[@"vertices"]];
|
|
463
483
|
}
|
|
464
484
|
|
|
465
|
-
RCT_EXPORT_METHOD(removeGeofence:(NSString*)identifier
|
|
485
|
+
RCT_EXPORT_METHOD(removeGeofence:(NSString*)identifier resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
466
486
|
{
|
|
467
487
|
[locationManager removeGeofence:identifier success:^{
|
|
468
488
|
resolve(@(YES));
|
|
@@ -471,7 +491,7 @@ RCT_EXPORT_METHOD(removeGeofence:(NSString*)identifier resolver:(RCTPromiseResol
|
|
|
471
491
|
}];
|
|
472
492
|
}
|
|
473
493
|
|
|
474
|
-
RCT_EXPORT_METHOD(removeGeofences:(RCTPromiseResolveBlock)resolve
|
|
494
|
+
RCT_EXPORT_METHOD(removeGeofences:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
475
495
|
{
|
|
476
496
|
NSArray *geofences = @[];
|
|
477
497
|
[locationManager removeGeofences:geofences success:^{
|
|
@@ -481,13 +501,13 @@ RCT_EXPORT_METHOD(removeGeofences:(RCTPromiseResolveBlock)resolve rejecter:(RCTP
|
|
|
481
501
|
}];
|
|
482
502
|
}
|
|
483
503
|
|
|
484
|
-
RCT_EXPORT_METHOD(getOdometer:(RCTPromiseResolveBlock)resolve
|
|
504
|
+
RCT_EXPORT_METHOD(getOdometer:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
485
505
|
{
|
|
486
506
|
NSNumber *distance = @([locationManager getOdometer]);
|
|
487
507
|
resolve(distance);
|
|
488
508
|
}
|
|
489
509
|
|
|
490
|
-
RCT_EXPORT_METHOD(setOdometer:(double)value
|
|
510
|
+
RCT_EXPORT_METHOD(setOdometer:(double)value resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
491
511
|
{
|
|
492
512
|
TSCurrentPositionRequest *request = [TSCurrentPositionRequest requestWithSuccess:^(TSLocationEvent *event) {
|
|
493
513
|
resolve([event toDictionary]);
|
|
@@ -497,7 +517,7 @@ RCT_EXPORT_METHOD(setOdometer:(double)value resolver:(RCTPromiseResolveBlock)res
|
|
|
497
517
|
[locationManager setOdometer:value request:request];
|
|
498
518
|
}
|
|
499
519
|
|
|
500
|
-
RCT_EXPORT_METHOD(destroyLocations:(RCTPromiseResolveBlock)resolve
|
|
520
|
+
RCT_EXPORT_METHOD(destroyLocations:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
501
521
|
{
|
|
502
522
|
BOOL result = [locationManager destroyLocations];
|
|
503
523
|
if (result) {
|
|
@@ -507,7 +527,7 @@ RCT_EXPORT_METHOD(destroyLocations:(RCTPromiseResolveBlock)resolve rejecter:(RCT
|
|
|
507
527
|
}
|
|
508
528
|
}
|
|
509
529
|
|
|
510
|
-
RCT_EXPORT_METHOD(destroyLocation:(NSString*)uuid
|
|
530
|
+
RCT_EXPORT_METHOD(destroyLocation:(NSString*)uuid resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
511
531
|
{
|
|
512
532
|
[locationManager destroyLocation:uuid success:^{
|
|
513
533
|
resolve(@(YES));
|
|
@@ -516,7 +536,7 @@ RCT_EXPORT_METHOD(destroyLocation:(NSString*)uuid resolver:(RCTPromiseResolveBlo
|
|
|
516
536
|
}];
|
|
517
537
|
}
|
|
518
538
|
|
|
519
|
-
RCT_EXPORT_METHOD(getCount:(RCTPromiseResolveBlock)resolve
|
|
539
|
+
RCT_EXPORT_METHOD(getCount:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
520
540
|
{
|
|
521
541
|
int count = [locationManager getCount];
|
|
522
542
|
if (count >= 0) {
|
|
@@ -526,7 +546,7 @@ RCT_EXPORT_METHOD(getCount:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseR
|
|
|
526
546
|
}
|
|
527
547
|
}
|
|
528
548
|
|
|
529
|
-
RCT_EXPORT_METHOD(insertLocation:(NSDictionary*)params
|
|
549
|
+
RCT_EXPORT_METHOD(insertLocation:(NSDictionary*)params resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
530
550
|
{
|
|
531
551
|
[locationManager insertLocation: params success:^(NSString* uuid) {
|
|
532
552
|
resolve(uuid);
|
|
@@ -535,7 +555,7 @@ RCT_EXPORT_METHOD(insertLocation:(NSDictionary*)params resolver:(RCTPromiseResol
|
|
|
535
555
|
}];
|
|
536
556
|
}
|
|
537
557
|
|
|
538
|
-
RCT_EXPORT_METHOD(getLog:(NSDictionary*)params
|
|
558
|
+
RCT_EXPORT_METHOD(getLog:(NSDictionary*)params resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
539
559
|
{
|
|
540
560
|
LogQuery *query = [[LogQuery alloc] initWithDictionary:params];
|
|
541
561
|
[locationManager getLog:query success:^(NSString* log) {
|
|
@@ -545,7 +565,7 @@ RCT_EXPORT_METHOD(getLog:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)
|
|
|
545
565
|
}];
|
|
546
566
|
}
|
|
547
567
|
|
|
548
|
-
RCT_EXPORT_METHOD(destroyLog:(RCTPromiseResolveBlock)resolve
|
|
568
|
+
RCT_EXPORT_METHOD(destroyLog:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
549
569
|
{
|
|
550
570
|
BOOL result = [locationManager destroyLog];
|
|
551
571
|
if (result) {
|
|
@@ -555,7 +575,7 @@ RCT_EXPORT_METHOD(destroyLog:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromis
|
|
|
555
575
|
}
|
|
556
576
|
}
|
|
557
577
|
|
|
558
|
-
RCT_EXPORT_METHOD(emailLog:(NSString*)email query:(NSDictionary*)params
|
|
578
|
+
RCT_EXPORT_METHOD(emailLog:(NSString*)email query:(NSDictionary*)params resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
559
579
|
{
|
|
560
580
|
LogQuery *query = [[LogQuery alloc] initWithDictionary:params];
|
|
561
581
|
[locationManager emailLog:email query:query success:^{
|
|
@@ -565,7 +585,7 @@ RCT_EXPORT_METHOD(emailLog:(NSString*)email query:(NSDictionary*)params resolver
|
|
|
565
585
|
}];
|
|
566
586
|
}
|
|
567
587
|
|
|
568
|
-
RCT_EXPORT_METHOD(uploadLog:(NSString*)url query:(NSDictionary*)params
|
|
588
|
+
RCT_EXPORT_METHOD(uploadLog:(NSString*)url query:(NSDictionary*)params resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
569
589
|
{
|
|
570
590
|
|
|
571
591
|
|
|
@@ -578,12 +598,16 @@ RCT_EXPORT_METHOD(uploadLog:(NSString*)url query:(NSDictionary*)params resolver:
|
|
|
578
598
|
}
|
|
579
599
|
|
|
580
600
|
|
|
581
|
-
RCT_EXPORT_METHOD(log:(NSString*)level
|
|
601
|
+
RCT_EXPORT_METHOD(log:(NSString*)level
|
|
602
|
+
message:(NSString*)message
|
|
603
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
604
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
582
605
|
{
|
|
583
606
|
[locationManager log:level message:message];
|
|
607
|
+
resolve(@(YES));
|
|
584
608
|
}
|
|
585
609
|
|
|
586
|
-
RCT_EXPORT_METHOD(getSensors:(RCTPromiseResolveBlock)resolve
|
|
610
|
+
RCT_EXPORT_METHOD(getSensors:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
587
611
|
{
|
|
588
612
|
NSDictionary *sensors = @{
|
|
589
613
|
@"platform": @"ios",
|
|
@@ -595,40 +619,40 @@ RCT_EXPORT_METHOD(getSensors:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromis
|
|
|
595
619
|
resolve(sensors);
|
|
596
620
|
}
|
|
597
621
|
|
|
598
|
-
RCT_EXPORT_METHOD(getDeviceInfo:(RCTPromiseResolveBlock)resolve
|
|
622
|
+
RCT_EXPORT_METHOD(getDeviceInfo:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
599
623
|
{
|
|
600
624
|
TSDeviceInfo *deviceInfo = [TSDeviceInfo sharedInstance];
|
|
601
625
|
resolve([deviceInfo toDictionary:@"react-native"]);
|
|
602
626
|
}
|
|
603
627
|
|
|
604
|
-
RCT_EXPORT_METHOD(isPowerSaveMode:(RCTPromiseResolveBlock)resolve
|
|
628
|
+
RCT_EXPORT_METHOD(isPowerSaveMode:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
605
629
|
{
|
|
606
630
|
BOOL isPowerSaveMode = [locationManager isPowerSaveMode];
|
|
607
631
|
resolve(@(isPowerSaveMode));
|
|
608
632
|
}
|
|
609
633
|
|
|
610
|
-
RCT_EXPORT_METHOD(isIgnoringBatteryOptimizations:(RCTPromiseResolveBlock)resolve
|
|
634
|
+
RCT_EXPORT_METHOD(isIgnoringBatteryOptimizations:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
611
635
|
{
|
|
612
636
|
resolve(@(NO));
|
|
613
637
|
}
|
|
614
638
|
|
|
615
|
-
RCT_EXPORT_METHOD(requestSettings:(NSDictionary*)args
|
|
639
|
+
RCT_EXPORT_METHOD(requestSettings:(NSDictionary*)args resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
616
640
|
{
|
|
617
641
|
reject(@"request_settings_error", @"No iOS Implementation", nil);
|
|
618
642
|
}
|
|
619
643
|
|
|
620
|
-
RCT_EXPORT_METHOD(showSettings:(NSDictionary*)args
|
|
644
|
+
RCT_EXPORT_METHOD(showSettings:(NSDictionary*)args resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
621
645
|
{
|
|
622
646
|
reject(@"show_settings_error", @"No iOS Implementation", nil);
|
|
623
647
|
}
|
|
624
648
|
|
|
625
|
-
RCT_EXPORT_METHOD(getProviderState:(RCTPromiseResolveBlock)resolve
|
|
649
|
+
RCT_EXPORT_METHOD(getProviderState:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
626
650
|
{
|
|
627
651
|
TSProviderChangeEvent *event = [locationManager getProviderState];
|
|
628
652
|
resolve([event toDictionary]);
|
|
629
653
|
}
|
|
630
654
|
|
|
631
|
-
RCT_EXPORT_METHOD(requestPermission:(RCTPromiseResolveBlock)resolve
|
|
655
|
+
RCT_EXPORT_METHOD(requestPermission:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
632
656
|
{
|
|
633
657
|
[locationManager requestPermission:^(NSNumber *status) {
|
|
634
658
|
resolve(status);
|
|
@@ -637,7 +661,7 @@ RCT_EXPORT_METHOD(requestPermission:(RCTPromiseResolveBlock)resolve rejecter:(RC
|
|
|
637
661
|
}];
|
|
638
662
|
}
|
|
639
663
|
|
|
640
|
-
RCT_EXPORT_METHOD(requestTemporaryFullAccuracy:(NSString*)purpose
|
|
664
|
+
RCT_EXPORT_METHOD(requestTemporaryFullAccuracy:(NSString*)purpose resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
641
665
|
{
|
|
642
666
|
[locationManager requestTemporaryFullAccuracy:purpose success:^(NSInteger accuracyAuthorization) {
|
|
643
667
|
resolve(@(accuracyAuthorization));
|
|
@@ -646,7 +670,11 @@ RCT_EXPORT_METHOD(requestTemporaryFullAccuracy:(NSString*)purpose resolver:(RCTP
|
|
|
646
670
|
}];
|
|
647
671
|
}
|
|
648
672
|
|
|
649
|
-
RCT_EXPORT_METHOD(getTransistorToken:(NSString*)orgname
|
|
673
|
+
RCT_EXPORT_METHOD(getTransistorToken:(NSString*)orgname
|
|
674
|
+
username:(NSString*)username
|
|
675
|
+
url:(NSString*)url
|
|
676
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
677
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
650
678
|
{
|
|
651
679
|
[TransistorAuthorizationToken findOrCreateWithOrg:orgname
|
|
652
680
|
username:username
|
|
@@ -659,15 +687,18 @@ RCT_EXPORT_METHOD(getTransistorToken:(NSString*)orgname username:(NSString*)user
|
|
|
659
687
|
}];
|
|
660
688
|
}
|
|
661
689
|
|
|
662
|
-
RCT_EXPORT_METHOD(destroyTransistorToken:(NSString*)url
|
|
690
|
+
RCT_EXPORT_METHOD(destroyTransistorToken:(NSString*)url
|
|
691
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
692
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
663
693
|
{
|
|
664
694
|
[TransistorAuthorizationToken destroyWithUrl:url];
|
|
665
695
|
resolve(@(YES));
|
|
666
696
|
}
|
|
667
697
|
|
|
668
|
-
RCT_EXPORT_METHOD(playSound:(
|
|
698
|
+
RCT_EXPORT_METHOD(playSound:(NSString*)soundId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
669
699
|
{
|
|
670
|
-
|
|
700
|
+
NSInteger soundIdInt = [soundId integerValue];
|
|
701
|
+
[locationManager playSound: soundIdInt];
|
|
671
702
|
resolve(@(YES));
|
|
672
703
|
}
|
|
673
704
|
|
|
@@ -691,6 +722,12 @@ RCT_EXPORT_METHOD(playSound:(int)soundId resolver:(RCTPromiseResolveBlock)resolv
|
|
|
691
722
|
locationManager = nil;
|
|
692
723
|
}
|
|
693
724
|
|
|
725
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
726
|
+
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
|
|
727
|
+
{
|
|
728
|
+
return std::make_shared<NativeRNBackgroundGeolocationSpecJSI>(params);
|
|
729
|
+
}
|
|
730
|
+
#endif
|
|
694
731
|
|
|
695
732
|
@end
|
|
696
733
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-background-geolocation",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.3",
|
|
4
4
|
"description": "The most sophisticated cross-platform background location-tracking & geofencing module with battery-conscious motion-detection intelligence",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "yarn run build:expo",
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build:expo": "rimraf expo/plugin/build && tsc --build ./expo/plugin",
|
|
9
|
+
"docs": "node ./scripts/generate-docs.mjs",
|
|
10
|
+
"docs:publish": "./scripts/publish-docs.sh"
|
|
11
|
+
},
|
|
5
12
|
"codegenConfig": {
|
|
6
13
|
"name": "RNBackgroundGeolocation",
|
|
7
|
-
"type": "
|
|
8
|
-
"jsSrcsDir": "./src",
|
|
14
|
+
"type": "modules",
|
|
15
|
+
"jsSrcsDir": "./src/specs",
|
|
9
16
|
"android": {
|
|
10
17
|
"javaPackageName": "com.transistorsoft.rnbackgroundgeolocation"
|
|
18
|
+
},
|
|
19
|
+
"ios": {
|
|
20
|
+
"swiftModuleName": "RNBackgroundGeolocation",
|
|
21
|
+
"packageName": "RNBackgroundGeolocation"
|
|
11
22
|
}
|
|
12
23
|
},
|
|
13
24
|
"main": "src/index.js",
|
|
@@ -28,7 +39,7 @@
|
|
|
28
39
|
],
|
|
29
40
|
"dependencies": {
|
|
30
41
|
"@babel/runtime": "^7.26.0",
|
|
31
|
-
"@transistorsoft/background-geolocation-types": "^5.0.
|
|
42
|
+
"@transistorsoft/background-geolocation-types": "^5.0.1",
|
|
32
43
|
"tslib": "^2.6.3"
|
|
33
44
|
},
|
|
34
45
|
"author": "Chris Scott <chris@transistorsoft.com>",
|
|
@@ -46,12 +57,5 @@
|
|
|
46
57
|
"rimraf": "^5.0.0",
|
|
47
58
|
"typedoc": "^0.28.14",
|
|
48
59
|
"typescript": "^5.6.0"
|
|
49
|
-
},
|
|
50
|
-
"scripts": {
|
|
51
|
-
"build": "yarn run build:expo",
|
|
52
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
53
|
-
"build:expo": "rimraf expo/plugin/build && tsc --build ./expo/plugin",
|
|
54
|
-
"docs": "node ./scripts/generate-docs.mjs",
|
|
55
|
-
"docs:publish": "./scripts/publish-docs.sh"
|
|
56
60
|
}
|
|
57
|
-
}
|
|
61
|
+
}
|
package/src/Logger.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
// Logger.js
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
|
-
import
|
|
4
|
+
import NativeModule from "./NativeModule";
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
const RNBackgroundGeolocation = NativeModule; // uses the same getNativeBGGeo() under the hood
|
|
6
7
|
|
|
7
8
|
const LOG_LEVEL_DEBUG = "debug";
|
|
8
9
|
const LOG_LEVEL_NOTICE = "notice";
|
|
@@ -14,12 +15,16 @@ const ORDER_ASC = 1;
|
|
|
14
15
|
const ORDER_DESC = -1;
|
|
15
16
|
|
|
16
17
|
function log(level, msg) {
|
|
18
|
+
// You can either:
|
|
19
|
+
// 1) call the native logger via NativeModule.logger
|
|
20
|
+
// NativeModule.logger[level](msg);
|
|
21
|
+
// or
|
|
22
|
+
// 2) just use the native `log` directly if exposed:
|
|
17
23
|
RNBackgroundGeolocation.log(level, msg);
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
function validateQuery(query) {
|
|
21
27
|
if (typeof(query) !== 'object') return {};
|
|
22
|
-
|
|
23
28
|
if (query.hasOwnProperty('start') && isNaN(query.start)) {
|
|
24
29
|
throw new Error('Invalid SQLQuery.start. Expected unix timestamp but received: ' + query.start);
|
|
25
30
|
}
|
|
@@ -33,31 +38,17 @@ export default class Logger {
|
|
|
33
38
|
static get ORDER_ASC() { return ORDER_ASC; }
|
|
34
39
|
static get ORDER_DESC() { return ORDER_DESC; }
|
|
35
40
|
|
|
36
|
-
static debug(msg)
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static
|
|
41
|
-
log(LOG_LEVEL_ERROR, msg);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static warn(msg) {
|
|
45
|
-
log(LOG_LEVEL_WARN, msg);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static info(msg) {
|
|
49
|
-
log(LOG_LEVEL_INFO, msg);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static notice(msg) {
|
|
53
|
-
log(LOG_LEVEL_NOTICE, msg);
|
|
54
|
-
}
|
|
41
|
+
static debug(msg) { log(LOG_LEVEL_DEBUG, msg); }
|
|
42
|
+
static error(msg) { log(LOG_LEVEL_ERROR, msg); }
|
|
43
|
+
static warn(msg) { log(LOG_LEVEL_WARN, msg); }
|
|
44
|
+
static info(msg) { log(LOG_LEVEL_INFO, msg); }
|
|
45
|
+
static notice(msg) { log(LOG_LEVEL_NOTICE, msg); }
|
|
55
46
|
|
|
56
47
|
static getLog(query) {
|
|
57
|
-
return RNBackgroundGeolocation.getLog(validateQuery(query));
|
|
48
|
+
return RNBackgroundGeolocation.getLog(validateQuery(query));
|
|
58
49
|
}
|
|
59
50
|
|
|
60
|
-
static emailLog(email, query) {
|
|
51
|
+
static emailLog(email, query) {
|
|
61
52
|
return RNBackgroundGeolocation.emailLog(email, validateQuery(query));
|
|
62
53
|
}
|
|
63
54
|
|
|
@@ -66,6 +57,6 @@ export default class Logger {
|
|
|
66
57
|
}
|
|
67
58
|
|
|
68
59
|
static destroyLog() {
|
|
69
|
-
return RNBackgroundGeolocation.destroyLog();
|
|
60
|
+
return RNBackgroundGeolocation.destroyLog();
|
|
70
61
|
}
|
|
71
62
|
}
|
package/src/NativeModule.js
CHANGED
|
@@ -1,18 +1,45 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// foo
|
|
4
3
|
import {
|
|
5
4
|
NativeEventEmitter,
|
|
6
5
|
NativeModules,
|
|
7
|
-
|
|
6
|
+
TurboModuleRegistry,
|
|
8
7
|
Platform,
|
|
9
8
|
AppRegistry,
|
|
10
|
-
} from "react-native"
|
|
9
|
+
} from "react-native";
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
function getNativeBGGeo() {
|
|
12
|
+
// Prefer TurboModule when the new architecture is enabled.
|
|
13
|
+
|
|
14
|
+
if (TurboModuleRegistry && typeof TurboModuleRegistry.get === 'function') {
|
|
15
|
+
try {
|
|
16
|
+
const turbo = TurboModuleRegistry.get('RNBackgroundGeolocation');
|
|
17
|
+
if (turbo) {
|
|
18
|
+
return turbo;
|
|
19
|
+
}
|
|
20
|
+
} catch (e) {
|
|
21
|
+
// If Turbo lookup fails for any reason, fall through to classic bridge.
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Fallback to classic bridge (old architecture).
|
|
26
|
+
const legacy = NativeModules && NativeModules.RNBackgroundGeolocation;
|
|
27
|
+
if (legacy) {
|
|
28
|
+
return legacy;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// If we reach here, the native module is not installed or not linked.
|
|
32
|
+
throw new Error(
|
|
33
|
+
'[react-native-background-geolocation] Native module "RNBackgroundGeolocation" not found. ' +
|
|
34
|
+
'Make sure the library is properly installed and linked for your platform.'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const RNBackgroundGeolocation = getNativeBGGeo();
|
|
13
39
|
|
|
14
40
|
const EventEmitter = new NativeEventEmitter(RNBackgroundGeolocation);
|
|
15
41
|
|
|
42
|
+
|
|
16
43
|
import TransistorAuthorizationService from "./TransistorAuthorizationService";
|
|
17
44
|
|
|
18
45
|
const TAG = "TSLocationManager";
|
|
@@ -260,21 +287,37 @@ export default class NativeModule {
|
|
|
260
287
|
return RNBackgroundGeolocation.getCurrentPosition(options);
|
|
261
288
|
}
|
|
262
289
|
|
|
263
|
-
static watchPosition(options, success, failure) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
290
|
+
static async watchPosition(options, success, failure) {
|
|
291
|
+
|
|
292
|
+
if (typeof success !== 'function') {
|
|
293
|
+
throw `${TAG}#watchPosition requires a success callback`;
|
|
294
|
+
}
|
|
295
|
+
return new Promise(async (resolve, reject) => {
|
|
296
|
+
options = options || {};
|
|
297
|
+
failure = failure || (() => {});
|
|
298
|
+
// Register listener immediately.
|
|
299
|
+
const subscription = EventEmitter.addListener('watchposition', success);
|
|
300
|
+
let watchId;
|
|
301
|
+
try {
|
|
302
|
+
watchId = await RNBackgroundGeolocation.watchPosition(options);
|
|
303
|
+
console.log("********** watchPositonId: ", watchId)
|
|
304
|
+
// Resolve with our wrapped Subscription instance.
|
|
305
|
+
resolve({
|
|
306
|
+
id: watchId,
|
|
307
|
+
remove: () => {
|
|
308
|
+
subscription.remove();
|
|
309
|
+
RNBackgroundGeolocation.stopWatchPosition(watchId);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
} catch (error) {
|
|
313
|
+
subscription.remove();
|
|
314
|
+
reject(error);
|
|
272
315
|
}
|
|
273
|
-
});
|
|
316
|
+
});
|
|
274
317
|
}
|
|
275
318
|
|
|
276
|
-
static stopWatchPosition() {
|
|
277
|
-
return RNBackgroundGeolocation.stopWatchPosition();
|
|
319
|
+
static stopWatchPosition(watchId) {
|
|
320
|
+
return RNBackgroundGeolocation.stopWatchPosition(watchId);
|
|
278
321
|
}
|
|
279
322
|
|
|
280
323
|
static getOdometer() {
|
|
@@ -360,8 +403,8 @@ export default class NativeModule {
|
|
|
360
403
|
return RNBackgroundGeolocation.destroyLog();
|
|
361
404
|
}
|
|
362
405
|
|
|
363
|
-
static emailLog(email) {
|
|
364
|
-
return RNBackgroundGeolocation.emailLog(email);
|
|
406
|
+
static emailLog(email, query) {
|
|
407
|
+
return RNBackgroundGeolocation.emailLog(email, query);
|
|
365
408
|
}
|
|
366
409
|
|
|
367
410
|
static isPowerSaveMode() {
|
package/src/index.js
CHANGED
|
@@ -563,21 +563,20 @@ export default class BackgroundGeolocation {
|
|
|
563
563
|
/**
|
|
564
564
|
* Begin watching a stream of locations
|
|
565
565
|
*/
|
|
566
|
-
static watchPosition(success, failure
|
|
567
|
-
if (typeof
|
|
568
|
-
throw TAG + '#watchPosition
|
|
566
|
+
static watchPosition(options, success, failure) {
|
|
567
|
+
if (typeof success !== 'function') {
|
|
568
|
+
throw TAG + '#watchPosition requires a success callback';
|
|
569
569
|
}
|
|
570
|
-
failure = failure || emptyFn;
|
|
571
570
|
options = options || {};
|
|
572
|
-
|
|
573
|
-
NativeModule.watchPosition(options, success, failure);
|
|
571
|
+
failure = failure || emptyFn;
|
|
572
|
+
return NativeModule.watchPosition(options, success, failure);
|
|
574
573
|
}
|
|
575
574
|
|
|
576
575
|
/**
|
|
577
576
|
* Stop watching location
|
|
578
577
|
*/
|
|
579
|
-
static stopWatchPosition() {
|
|
580
|
-
return NativeModule.stopWatchPosition();
|
|
578
|
+
static stopWatchPosition(watchId) {
|
|
579
|
+
return NativeModule.stopWatchPosition(watchId);
|
|
581
580
|
}
|
|
582
581
|
|
|
583
582
|
/**
|
|
@@ -604,8 +603,9 @@ export default class BackgroundGeolocation {
|
|
|
604
603
|
/**
|
|
605
604
|
* Open deafult email client on device to email the contents of log database attached as a compressed file attachement
|
|
606
605
|
*/
|
|
607
|
-
static emailLog(email) {
|
|
608
|
-
|
|
606
|
+
static emailLog(email, query) {
|
|
607
|
+
query = query || {};
|
|
608
|
+
return Logger.emailLog(email, query);
|
|
609
609
|
}
|
|
610
610
|
|
|
611
611
|
/**
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import type {TurboModule} from 'react-native';
|
|
4
|
+
import {TurboModuleRegistry} from 'react-native';
|
|
5
|
+
import type {Int32, Double} from 'react-native/Libraries/Types/CodegenTypes';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TurboModule spec for RNBackgroundGeolocation.
|
|
9
|
+
* This matches the Promise-based @ReactMethod signatures in
|
|
10
|
+
* RNBackgroundGeolocationModule.java.
|
|
11
|
+
*/
|
|
12
|
+
export interface Spec extends TurboModule {
|
|
13
|
+
// Core / config
|
|
14
|
+
+registerPlugin: (name: string) => void;
|
|
15
|
+
|
|
16
|
+
+ready: (params: Object) => Promise<Object>;
|
|
17
|
+
+configure: (params: Object) => Promise<Object>;
|
|
18
|
+
+setConfig: (params: Object) => Promise<Object>;
|
|
19
|
+
+reset: (defaultConfig: Object) => Promise<Object>;
|
|
20
|
+
|
|
21
|
+
+start: () => Promise<Object>;
|
|
22
|
+
+startSchedule: () => Promise<Object>;
|
|
23
|
+
+stopSchedule: () => Promise<Object>;
|
|
24
|
+
+startGeofences: () => Promise<Object>;
|
|
25
|
+
+stop: () => Promise<Object>;
|
|
26
|
+
|
|
27
|
+
+changePace: (moving: boolean) => Promise<boolean>;
|
|
28
|
+
+getState: () => Promise<Object>;
|
|
29
|
+
|
|
30
|
+
// Locations / persistence
|
|
31
|
+
+getLocations: () => Promise<Array<Object>>;
|
|
32
|
+
+getCount: () => Promise<Int32>;
|
|
33
|
+
+insertLocation: (params: Object) => Promise<string>;
|
|
34
|
+
|
|
35
|
+
// Deprecated alias -> destroyLocations
|
|
36
|
+
+clearDatabase: () => Promise<boolean>;
|
|
37
|
+
|
|
38
|
+
+destroyLocations: () => Promise<boolean>;
|
|
39
|
+
+destroyLocation: (uuid: string) => Promise<boolean>;
|
|
40
|
+
|
|
41
|
+
+destroyLog: () => Promise<boolean>;
|
|
42
|
+
+sync: () => Promise<Array<Object>>;
|
|
43
|
+
|
|
44
|
+
// Geolocation
|
|
45
|
+
+getCurrentPosition: (options: Object) => Promise<Object>;
|
|
46
|
+
+watchPosition: (options: Object) => Promise<Int32>;
|
|
47
|
+
+stopWatchPosition: (watchId: Int32) => Promise<boolean>;
|
|
48
|
+
|
|
49
|
+
+getOdometer: () => Promise<Double>;
|
|
50
|
+
+setOdometer: (value: Double) => Promise<Object>;
|
|
51
|
+
|
|
52
|
+
// Geofences
|
|
53
|
+
+addGeofence: (config: Object) => Promise<boolean>;
|
|
54
|
+
+addGeofences: (geofences: Array<Object>) => Promise<boolean>;
|
|
55
|
+
+removeGeofence: (identifier: string) => Promise<boolean>;
|
|
56
|
+
+removeGeofences: () => Promise<boolean>;
|
|
57
|
+
+getGeofences: () => Promise<Array<Object>>;
|
|
58
|
+
+getGeofence: (identifier: string) => Promise<Object>;
|
|
59
|
+
+geofenceExists: (identifier: string) => Promise<boolean>;
|
|
60
|
+
|
|
61
|
+
// Background tasks
|
|
62
|
+
+beginBackgroundTask: () => Promise<Int32>;
|
|
63
|
+
+finish: (taskId: Int32) => Promise<Int32>;
|
|
64
|
+
+finishHeadlessTask: (taskId: Int32) => Promise<boolean>;
|
|
65
|
+
|
|
66
|
+
// Transistor auth token
|
|
67
|
+
+getTransistorToken: (
|
|
68
|
+
orgname: string,
|
|
69
|
+
username: string,
|
|
70
|
+
url: string,
|
|
71
|
+
) => Promise<Object>;
|
|
72
|
+
|
|
73
|
+
+destroyTransistorToken: (url: string) => Promise<boolean>;
|
|
74
|
+
|
|
75
|
+
// Logging
|
|
76
|
+
|
|
77
|
+
+playSound: (soundId: string) => Promise<boolean>;
|
|
78
|
+
+getLog: (query: Object) => Promise<string>;
|
|
79
|
+
+emailLog: (email: string, query: Object) => Promise<boolean>;
|
|
80
|
+
+uploadLog: (url: string, query: Object) => Promise<boolean>;
|
|
81
|
+
+log: (level: string, message: string) => Promise<boolean>;
|
|
82
|
+
|
|
83
|
+
// Device / sensors / settings
|
|
84
|
+
+getSensors: () => Promise<Object>;
|
|
85
|
+
+getDeviceInfo: () => Promise<Object>;
|
|
86
|
+
+isPowerSaveMode: () => Promise<boolean>;
|
|
87
|
+
+isIgnoringBatteryOptimizations: () => Promise<boolean>;
|
|
88
|
+
|
|
89
|
+
+requestSettings: (args: Object) => Promise<Object>;
|
|
90
|
+
+showSettings: (args: Object) => Promise<boolean>;
|
|
91
|
+
|
|
92
|
+
+getProviderState: () => Promise<Object>;
|
|
93
|
+
+requestPermission: () => Promise<Int32>;
|
|
94
|
+
+requestTemporaryFullAccuracy: (purpose: string) => Promise<Int32>;
|
|
95
|
+
|
|
96
|
+
// Required by NativeEventEmitter
|
|
97
|
+
+addListener: (eventName: string) => void;
|
|
98
|
+
+removeListeners: (count: Int32) => void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Default export used by RN at runtime (for Turbo path).
|
|
102
|
+
export default (TurboModuleRegistry.getEnforcing<Spec>(
|
|
103
|
+
'RNBackgroundGeolocation',
|
|
104
|
+
): Spec);
|