react-native-background-geolocation 4.2.2 → 4.4.2
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/CHANGELOG.md +45 -0
- package/android/libs/com/transistorsoft/tslocationmanager/{3.1.31/tslocationmanager-3.1.31.aar → 3.1.34/tslocationmanager-3.1.34.aar} +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.aar.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.aar.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.aar.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.aar.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/{3.1.28/tslocationmanager-3.1.28.pom → 3.1.34/tslocationmanager-3.1.34.pom} +1 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.pom.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.pom.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.pom.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.pom.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/maven-metadata.xml +6 -4
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/{3.1.31/tslocationmanager-reverse-3.1.31.aar → 3.1.34/tslocationmanager-reverse-3.1.34.aar} +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.34/tslocationmanager-reverse-3.1.34.aar.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.34/tslocationmanager-reverse-3.1.34.aar.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.34/tslocationmanager-reverse-3.1.34.aar.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.34/tslocationmanager-reverse-3.1.34.aar.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/{3.1.28/tslocationmanager-reverse-3.1.28.pom → 3.1.34/tslocationmanager-reverse-3.1.34.pom} +1 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.34/tslocationmanager-reverse-3.1.34.pom.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.34/tslocationmanager-reverse-3.1.34.pom.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.34/tslocationmanager-reverse-3.1.34.pom.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.34/tslocationmanager-reverse-3.1.34.pom.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/maven-metadata.xml +6 -4
- package/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/RNBackgroundGeolocationModule.java +48 -83
- package/ios/RNBackgroundGeolocation/RNBackgroundGeolocation.m +60 -136
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/Info.plist +6 -6
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_armv7/TSLocationManager.framework/Info.plist +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_armv7/TSLocationManager.framework/TSLocationManager +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/Info.plist +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/TSLocationManager +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeResources +1 -1
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Resources/Info.plist +3 -3
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/TSLocationManager +0 -0
- package/package.json +3 -3
- package/src/NativeModule.js +77 -31
- package/src/declarations/BackgroundGeolocation.d.ts +52 -32
- package/src/declarations/interfaces/Subscription.d.ts +104 -0
- package/src/index.js +16 -16
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.28/tslocationmanager-3.1.28.aar +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.28/tslocationmanager-3.1.28.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.28/tslocationmanager-3.1.28.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.28/tslocationmanager-3.1.28.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.28/tslocationmanager-3.1.28.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.28/tslocationmanager-3.1.28.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.28/tslocationmanager-3.1.28.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.28/tslocationmanager-3.1.28.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.28/tslocationmanager-3.1.28.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.31/tslocationmanager-3.1.31.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.31/tslocationmanager-3.1.31.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.31/tslocationmanager-3.1.31.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.31/tslocationmanager-3.1.31.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.31/tslocationmanager-3.1.31.pom +0 -9
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.31/tslocationmanager-3.1.31.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.31/tslocationmanager-3.1.31.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.31/tslocationmanager-3.1.31.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.31/tslocationmanager-3.1.31.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.28/tslocationmanager-reverse-3.1.28.aar +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.28/tslocationmanager-reverse-3.1.28.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.28/tslocationmanager-reverse-3.1.28.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.28/tslocationmanager-reverse-3.1.28.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.28/tslocationmanager-reverse-3.1.28.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.28/tslocationmanager-reverse-3.1.28.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.28/tslocationmanager-reverse-3.1.28.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.28/tslocationmanager-reverse-3.1.28.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.28/tslocationmanager-reverse-3.1.28.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.31/tslocationmanager-reverse-3.1.31.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.31/tslocationmanager-reverse-3.1.31.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.31/tslocationmanager-reverse-3.1.31.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.31/tslocationmanager-reverse-3.1.31.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.31/tslocationmanager-reverse-3.1.31.pom +0 -9
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.31/tslocationmanager-reverse-3.1.31.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.31/tslocationmanager-reverse-3.1.31.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.31/tslocationmanager-reverse-3.1.31.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.31/tslocationmanager-reverse-3.1.31.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.4.2 — 2021-10-29
|
|
4
|
+
* [Fixed][Android] Android 12 behaviour changes mean that foreground-services remain running. When an Android app is terminated, the app process does not terminate (since the foreground-service is active) and `RNBackgroundGeolocationModule` remains in memory. Given that, the plugin cannot rely on registering its event-listeners in the `RNBackgroundGeolocationModule` constructor, but must perform that task when `.ready()` is called. This also requires resetting `mReady = false` when the `MainActivity` is destroyed, so that the next time `.ready()` is called, the event-listeners are re-registered.
|
|
5
|
+
* [Fixed][Android] When `.ready()` is called __`reset: false`__, the `success` callback was not invoked with the current `State`. This bug was introduced in previous `v4.4.1`.
|
|
6
|
+
|
|
7
|
+
## 4.4.1 — 2021-10-29
|
|
8
|
+
* [Added] Added a `Subscription` interface to Typescript API. Added helpful docs to Subscription for new event-handler subscriptions.
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import BackgroundGeolocation, {
|
|
12
|
+
Subscription
|
|
13
|
+
} from "...";
|
|
14
|
+
.
|
|
15
|
+
.
|
|
16
|
+
.
|
|
17
|
+
const subscription:Subscription = BacckgroundGeolocation.onLocation(myHandler);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 4.4.0 — 2021-10-25
|
|
21
|
+
* [Added] New `Authorization.strategy "SAS"` (alternative to default `JWT`).
|
|
22
|
+
* [Fixed] Fixed __`RCTEventEmitter`__ warning "addListener", "removeListeners". A corresponding fix has also been released for [react-native-background-fetch](https://github.com/transistorsoft/react-native-background-fetch/blob/master/CHANGELOG.md#404--2021-10-22) so be sure to update to `background-fetch >= 4.0.4`.
|
|
23
|
+
* [Changed] **Deprecated** `BackgroundGeolocation.removeListener`. All event-handlers now return a `react-native` `Subscription` instance containing a `.remove()` method. You will keep track of your own `subscription` instances and call `.remove()` upon them when you wish to remove an event listener. Eg:
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
/// OLD
|
|
27
|
+
const onLocation = (location) => {
|
|
28
|
+
console.log('[onLocation');
|
|
29
|
+
}
|
|
30
|
+
BackgroundGeolocation.onLocation(onLocation);
|
|
31
|
+
...
|
|
32
|
+
// deprecated: removeListener
|
|
33
|
+
BackgroundGeolocation.removeListener('location', onLocation);
|
|
34
|
+
|
|
35
|
+
/// NEW: capture returned subscription instance.
|
|
36
|
+
const onLocationSubscription = BackgroundGeolocation.onLocation(onLocation);
|
|
37
|
+
...
|
|
38
|
+
// Removing an event-listener.
|
|
39
|
+
onLocationSubscription.remove();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 4.3.0 — 2021-09-14
|
|
43
|
+
|
|
44
|
+
* [Added][Android] Implement new Android 12 "reduced accuracy" mechanism `requestTemporaryFullAccuracy`.
|
|
45
|
+
* [Fixed][iOS] `Authorization.refreshPayload refreshToken` was not performing a String replace on the `{refreshToken}` template, instead over-writing the entire string. Eg: if provided with `'refresh_token': 'Bearer {refreshToken}`, `Bearer ` would be over-written and replaced with only the refresh-token.
|
|
46
|
+
* [Fixed][Android] Fixed crash reported by Huawei device, where verticalAccuracy returns NaN.
|
|
47
|
+
|
|
3
48
|
## [4.2.2] — 2021-08-23
|
|
4
49
|
* [Fixed][iOS] add config change listeners for `heartbeatInterval` and `preventSuspend` to dynamically update interval when changed with `setConfig`.
|
|
5
50
|
* [Fixed][Android] Add `accuracyAuthorization` param to event data provided to `onProviderChange` event.
|
|
Binary file
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.aar.md5
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b29e51d5d171bd1836954c83f1657dd3
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.aar.sha1
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
738f4f927fde78332eeeb300ca1ac2ffbe6ddc26
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.aar.sha256
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a3dd1567edc75edbf1feb8bc3682d5e02ded8605e49854ba3169f391bfc8d09f
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.aar.sha512
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
8d405b0427fd37b225dd4ca90633614371c994f4e1fa2ada7c453a067c08ebc9f7b41b1ebfe13f09bafacfa948385b3a27b6964e3936ecb4e822c184603afe58
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.pom.md5
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20aafcf94ea9673cc521f064d46ade7b
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.pom.sha1
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
008bd7362c4446af36bef9e156b6c702a7e3b781
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.pom.sha256
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5dc8c142d50c9e6c9986a1b3d374e9ed86427da743e4030d24c45c9c0c4c2fdf
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.34/tslocationmanager-3.1.34.pom.sha512
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
d8d251199fbd1fa61abcb4bf82b4e67624d82fc03fb34d114b10d99bcf4e5d443f65e38e16620a0020c566d844a51e600f4f5aa073c754a4ac2824210ba30498
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
<groupId>com.transistorsoft</groupId>
|
|
4
4
|
<artifactId>tslocationmanager</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>3.1.
|
|
7
|
-
<release>3.1.
|
|
6
|
+
<latest>3.1.34</latest>
|
|
7
|
+
<release>3.1.34</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>3.1.
|
|
9
|
+
<version>3.1.32</version>
|
|
10
|
+
<version>3.1.33</version>
|
|
11
|
+
<version>3.1.34</version>
|
|
10
12
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
13
|
+
<lastUpdated>20211013180057</lastUpdated>
|
|
12
14
|
</versioning>
|
|
13
15
|
</metadata>
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c18e72e1b8a4706f760959f59a0d918c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2e0c81175a1b44c05be8dbf607d65886d402f656
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
649f4c006732c5b2a04b6f90fba952377fa7281dda7374a20f5c67661439b45f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cfa5f14f859d2bd881867cc63b1968a7527b5a7e8082b551d3e3ad854783fcadefd9f2e21f2071201e1570347348cf4355e5d74c2049a1af4f21c1cca8c208f7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
103b24060fe7ea19fe001a12852489b4
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fbb3841eba4fdd2ffbb024d1a791abe6eb15533b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e6ebe3816a4c6ddb141b433b631e4e00c67adec24e46e45d0f06279cc0677e4f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f4c9c0482e0b822dcca71dcc32eaa5ee3a0caa93e0936e13e1ae38fb53f0b3137125b7cd90ff0469e53bb88caf961955972dc86a442dc2d937ae826a156df7f1
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
<groupId>com.transistorsoft</groupId>
|
|
4
4
|
<artifactId>tslocationmanager-reverse</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>3.1.
|
|
7
|
-
<release>3.1.
|
|
6
|
+
<latest>3.1.34</latest>
|
|
7
|
+
<release>3.1.34</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>3.1.
|
|
9
|
+
<version>3.1.32</version>
|
|
10
|
+
<version>3.1.33</version>
|
|
11
|
+
<version>3.1.34</version>
|
|
10
12
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
13
|
+
<lastUpdated>20211013180057</lastUpdated>
|
|
12
14
|
</versioning>
|
|
13
15
|
</metadata>
|
|
@@ -90,13 +90,14 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
90
90
|
|
|
91
91
|
public RNBackgroundGeolocationModule(ReactApplicationContext reactContext) {
|
|
92
92
|
super(reactContext);
|
|
93
|
+
reactContext.addLifecycleEventListener(this);
|
|
93
94
|
|
|
94
95
|
TSConfig config = TSConfig.getInstance(getReactApplicationContext());
|
|
95
96
|
config.useCLLocationAccuracy(true);
|
|
96
97
|
|
|
97
98
|
config.updateWithBuilder()
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
.setHeadlessJobService(getClass().getPackage().getName() + "." + JOB_SERVICE_CLASS)
|
|
100
|
+
.commit();
|
|
100
101
|
|
|
101
102
|
// These are the only events which can be subscribed to.
|
|
102
103
|
mEvents.add(BackgroundGeolocation.EVENT_LOCATION);
|
|
@@ -113,8 +114,6 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
113
114
|
mEvents.add(BackgroundGeolocation.EVENT_ENABLEDCHANGE);
|
|
114
115
|
mEvents.add(BackgroundGeolocation.EVENT_NOTIFICATIONACTION);
|
|
115
116
|
mEvents.add(TSAuthorization.NAME);
|
|
116
|
-
|
|
117
|
-
reactContext.addLifecycleEventListener(this);
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
@Override
|
|
@@ -126,6 +125,23 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
126
125
|
return "RNBackgroundGeolocation";
|
|
127
126
|
}
|
|
128
127
|
|
|
128
|
+
private void registerEvents() {
|
|
129
|
+
BackgroundGeolocation adapter = getAdapter();
|
|
130
|
+
adapter.onLocation(new LocationCallback());
|
|
131
|
+
adapter.onMotionChange(new MotionChangeCallback());
|
|
132
|
+
adapter.onActivityChange(new ActivityChangeCallback());
|
|
133
|
+
adapter.onLocationProviderChange(new LocationProviderChangeCallback());
|
|
134
|
+
adapter.onGeofencesChange(new GeofencesChangeCallback());
|
|
135
|
+
adapter.onGeofence(new GeofenceCallback());
|
|
136
|
+
adapter.onHeartbeat(new HeartbeatCallback());
|
|
137
|
+
adapter.onHttp(new HttpResponseCallback());
|
|
138
|
+
adapter.onSchedule(new ScheduleCallback());
|
|
139
|
+
adapter.onPowerSaveChange(new PowerSaveChangeCallack());
|
|
140
|
+
adapter.onConnectivityChange(new ConnectivityChangeCallback());
|
|
141
|
+
adapter.onEnabledChange(new EnabledChangeCallback());
|
|
142
|
+
adapter.onNotificationAction(new NotificationActionCallback());
|
|
143
|
+
HttpService.getInstance(getReactApplicationContext()).onAuthorization(new AuthorizationCallback());
|
|
144
|
+
}
|
|
129
145
|
|
|
130
146
|
/**
|
|
131
147
|
* location event callback
|
|
@@ -306,6 +322,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
306
322
|
}
|
|
307
323
|
}
|
|
308
324
|
}
|
|
325
|
+
|
|
309
326
|
@Override
|
|
310
327
|
public void onHostResume() {
|
|
311
328
|
if (!mInitialized) {
|
|
@@ -323,6 +340,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
323
340
|
@Override
|
|
324
341
|
public void onHostDestroy() {
|
|
325
342
|
mInitialized = false;
|
|
343
|
+
mReady = false;
|
|
326
344
|
removeAllListeners();
|
|
327
345
|
getAdapter().onActivityDestroy();
|
|
328
346
|
}
|
|
@@ -346,19 +364,27 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
346
364
|
public void ready(ReadableMap params, final Callback success, final Callback failure) {
|
|
347
365
|
TSConfig config = TSConfig.getInstance(getReactApplicationContext());
|
|
348
366
|
|
|
367
|
+
boolean reset = true;
|
|
368
|
+
if (params.hasKey("reset")) {
|
|
369
|
+
reset = params.getBoolean("reset");
|
|
370
|
+
}
|
|
371
|
+
|
|
349
372
|
if (mReady) {
|
|
350
|
-
|
|
351
|
-
|
|
373
|
+
if (reset) {
|
|
374
|
+
TSLog.logger.warn(TSLog.warn("#ready already called. Redirecting to #setConfig"));
|
|
375
|
+
setConfig(params, success, failure);
|
|
376
|
+
} else {
|
|
377
|
+
TSLog.logger.warn(TSLog.warn("#ready already called. Ignored config since reset: false"));
|
|
378
|
+
success.invoke(getState());
|
|
379
|
+
}
|
|
352
380
|
return;
|
|
353
381
|
}
|
|
354
382
|
mReady = true;
|
|
383
|
+
registerEvents();
|
|
384
|
+
|
|
355
385
|
if (config.isFirstBoot()) {
|
|
356
386
|
config.updateWithJSONObject(mapToJson(setHeadlessJobService(params)));
|
|
357
387
|
} else {
|
|
358
|
-
boolean reset = true;
|
|
359
|
-
if (params.hasKey("reset")) {
|
|
360
|
-
reset = params.getBoolean("reset");
|
|
361
|
-
}
|
|
362
388
|
if (reset) {
|
|
363
389
|
config.reset();
|
|
364
390
|
config.updateWithJSONObject(mapToJson(setHeadlessJobService(params)));
|
|
@@ -973,92 +999,31 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
973
999
|
success.invoke(status);
|
|
974
1000
|
}
|
|
975
1001
|
@Override public void onFailure(int status) {
|
|
976
|
-
|
|
1002
|
+
success.invoke(status);
|
|
977
1003
|
}
|
|
978
1004
|
});
|
|
979
1005
|
}
|
|
980
1006
|
|
|
981
1007
|
@ReactMethod
|
|
982
|
-
public void requestTemporaryFullAccuracy(String purpose, Callback success, Callback failure) {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
@ReactMethod
|
|
989
|
-
public void addEventListener(String event) {
|
|
990
|
-
|
|
991
|
-
if (!mEvents.contains(event)) {
|
|
992
|
-
TSLog.logger.warn(TSLog.warn("[RNBackgroundGeolocation addListener] Unknown event: " + event));
|
|
993
|
-
return;
|
|
994
|
-
}
|
|
995
|
-
BackgroundGeolocation adapter = getAdapter();
|
|
996
|
-
Integer count;
|
|
997
|
-
|
|
998
|
-
synchronized(mListeners) {
|
|
999
|
-
if (mListeners.containsKey(event)) {
|
|
1000
|
-
count = mListeners.get(event);
|
|
1001
|
-
count++;
|
|
1002
|
-
mListeners.put(event, count);
|
|
1003
|
-
} else {
|
|
1004
|
-
count = 1;
|
|
1005
|
-
mListeners.put(event, count);
|
|
1008
|
+
public void requestTemporaryFullAccuracy(String purpose, final Callback success, final Callback failure) {
|
|
1009
|
+
getAdapter().requestTemporaryFullAccuracy(purpose, new TSRequestPermissionCallback() {
|
|
1010
|
+
@Override public void onSuccess(int accuracyAuthorization) {
|
|
1011
|
+
success.invoke(accuracyAuthorization);
|
|
1006
1012
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_LOCATION)) {
|
|
1010
|
-
adapter.onLocation(new LocationCallback());
|
|
1011
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_MOTIONCHANGE)) {
|
|
1012
|
-
adapter.onMotionChange(new MotionChangeCallback());
|
|
1013
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_ACTIVITYCHANGE)) {
|
|
1014
|
-
adapter.onActivityChange(new ActivityChangeCallback());
|
|
1015
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_PROVIDERCHANGE)) {
|
|
1016
|
-
adapter.onLocationProviderChange(new LocationProviderChangeCallback());
|
|
1017
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_GEOFENCESCHANGE)) {
|
|
1018
|
-
adapter.onGeofencesChange(new GeofencesChangeCallback());
|
|
1019
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_GEOFENCE)) {
|
|
1020
|
-
adapter.onGeofence(new GeofenceCallback());
|
|
1021
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_HEARTBEAT)) {
|
|
1022
|
-
adapter.onHeartbeat(new HeartbeatCallback());
|
|
1023
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_HTTP)) {
|
|
1024
|
-
adapter.onHttp(new HttpResponseCallback());
|
|
1025
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_SCHEDULE)) {
|
|
1026
|
-
adapter.onSchedule(new ScheduleCallback());
|
|
1027
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_POWERSAVECHANGE)) {
|
|
1028
|
-
adapter.onPowerSaveChange(new PowerSaveChangeCallack());
|
|
1029
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_CONNECTIVITYCHANGE)) {
|
|
1030
|
-
adapter.onConnectivityChange(new ConnectivityChangeCallback());
|
|
1031
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_ENABLEDCHANGE)) {
|
|
1032
|
-
adapter.onEnabledChange(new EnabledChangeCallback());
|
|
1033
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_NOTIFICATIONACTION)) {
|
|
1034
|
-
adapter.onNotificationAction(new NotificationActionCallback());
|
|
1035
|
-
} else if (event.equalsIgnoreCase(TSAuthorization.NAME)) {
|
|
1036
|
-
HttpService.getInstance(getReactApplicationContext()).onAuthorization(new AuthorizationCallback());
|
|
1013
|
+
@Override public void onFailure(int accuracyAuthorization) {
|
|
1014
|
+
success.invoke(accuracyAuthorization);
|
|
1037
1015
|
}
|
|
1038
|
-
}
|
|
1016
|
+
});
|
|
1039
1017
|
}
|
|
1040
1018
|
|
|
1041
1019
|
@ReactMethod
|
|
1042
|
-
public void
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
synchronized (mListeners) {
|
|
1046
|
-
if (mListeners.containsKey(event)) {
|
|
1047
|
-
count = mListeners.get(event);
|
|
1048
|
-
count--;
|
|
1049
|
-
if (count > 0) {
|
|
1050
|
-
mListeners.put(event, count);
|
|
1051
|
-
} else {
|
|
1052
|
-
getAdapter().removeListeners(event);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1020
|
+
public void addListener(String event) {
|
|
1021
|
+
// Keep: Required for RN built-in NativeEventEmitter calls.
|
|
1056
1022
|
}
|
|
1057
1023
|
|
|
1058
1024
|
@ReactMethod
|
|
1059
|
-
public void
|
|
1060
|
-
|
|
1061
|
-
success.invoke();
|
|
1025
|
+
public void removeListeners(Integer count) {
|
|
1026
|
+
// Keep: Required for RN built-in NativeEventEmitter calls.
|
|
1062
1027
|
}
|
|
1063
1028
|
|
|
1064
1029
|
private void removeAllListeners() {
|
|
@@ -30,22 +30,7 @@ static NSString *const EVENT_NOTIFICATIONACTION = @"notificationaction";
|
|
|
30
30
|
static NSString *const EVENT_AUTHORIZATION = @"authorization";
|
|
31
31
|
|
|
32
32
|
@implementation RNBackgroundGeolocation {
|
|
33
|
-
NSMutableDictionary *listeners;
|
|
34
33
|
BOOL ready;
|
|
35
|
-
void(^onLocation)(TSLocation*);
|
|
36
|
-
void(^onLocationError)(NSError*);
|
|
37
|
-
void(^onMotionChange)(TSLocation*);
|
|
38
|
-
void(^onActivityChange)(TSActivityChangeEvent*);
|
|
39
|
-
void(^onHeartbeat)(TSHeartbeatEvent*);
|
|
40
|
-
void(^onGeofence)(TSGeofenceEvent*);
|
|
41
|
-
void(^onGeofencesChange)(TSGeofencesChangeEvent*);
|
|
42
|
-
void(^onHttp)(TSHttpEvent*);
|
|
43
|
-
void(^onProviderChange)(TSProviderChangeEvent*);
|
|
44
|
-
void(^onSchedule)(TSScheduleEvent*);
|
|
45
|
-
void(^onPowerSaveChange)(TSPowerSaveChangeEvent*);
|
|
46
|
-
void(^onConnectivityChange)(TSConnectivityChangeEvent*);
|
|
47
|
-
void(^onEnabledChange)(TSEnabledChangeEvent*);
|
|
48
|
-
void(^onAuthorization)(TSAuthorizationEvent*);
|
|
49
34
|
}
|
|
50
35
|
|
|
51
36
|
@synthesize locationManager;
|
|
@@ -66,60 +51,7 @@ RCT_EXPORT_MODULE();
|
|
|
66
51
|
if (self) {
|
|
67
52
|
ready = NO;
|
|
68
53
|
|
|
69
|
-
__typeof(self) __weak me = self;
|
|
70
|
-
|
|
71
54
|
// Build event-listener blocks
|
|
72
|
-
onLocation = ^void(TSLocation *location) {
|
|
73
|
-
[me sendEvent:EVENT_LOCATION body:[location toDictionary]];
|
|
74
|
-
};
|
|
75
|
-
onLocationError = ^void(NSError *error) {
|
|
76
|
-
[me sendEvent:EVENT_LOCATION body: @{@"error":@(error.code)}];
|
|
77
|
-
};
|
|
78
|
-
onMotionChange = ^void(TSLocation *location) {
|
|
79
|
-
[me sendEvent:EVENT_MOTIONCHANGE body:@{@"isMoving":@(location.isMoving), @"location":[location toDictionary]}];
|
|
80
|
-
};
|
|
81
|
-
onActivityChange = ^void(TSActivityChangeEvent *event) {
|
|
82
|
-
NSDictionary *params = @{@"activity": event.activity, @"confidence": @(event.confidence)};
|
|
83
|
-
[me sendEvent:EVENT_ACTIVITYCHANGE body:params];
|
|
84
|
-
};
|
|
85
|
-
onHeartbeat = ^void(TSHeartbeatEvent *event) {
|
|
86
|
-
[me sendEvent:EVENT_HEARTBEAT body:@{@"location":[event.location toDictionary]}];
|
|
87
|
-
};
|
|
88
|
-
onGeofence = ^void(TSGeofenceEvent *event) {
|
|
89
|
-
NSMutableDictionary *params = [[event toDictionary] mutableCopy];
|
|
90
|
-
[params setObject:[event.location toDictionary] forKey:@"location"];
|
|
91
|
-
[me sendEvent:EVENT_GEOFENCE body:params];
|
|
92
|
-
};
|
|
93
|
-
onGeofencesChange = ^void(TSGeofencesChangeEvent *event) {
|
|
94
|
-
[me sendEvent:EVENT_GEOFENCESCHANGE body:[event toDictionary]];
|
|
95
|
-
};
|
|
96
|
-
onHttp = ^void(TSHttpEvent *response) {
|
|
97
|
-
NSDictionary *params = @{@"success": @(response.isSuccess), @"status": @(response.statusCode), @"responseText":response.responseText};
|
|
98
|
-
[me sendEvent:EVENT_HTTP body:params];
|
|
99
|
-
};
|
|
100
|
-
onProviderChange = ^void(TSProviderChangeEvent *event) {
|
|
101
|
-
[me sendEvent:EVENT_PROVIDERCHANGE body:[event toDictionary]];
|
|
102
|
-
};
|
|
103
|
-
onSchedule = ^void(TSScheduleEvent *event) {
|
|
104
|
-
[me sendEvent:EVENT_SCHEDULE body:event.state];
|
|
105
|
-
};
|
|
106
|
-
onPowerSaveChange = ^void(TSPowerSaveChangeEvent *event) {
|
|
107
|
-
[me sendEvent:EVENT_POWERSAVECHANGE body:@(event.isPowerSaveMode)];
|
|
108
|
-
};
|
|
109
|
-
onConnectivityChange = ^void(TSConnectivityChangeEvent *event) {
|
|
110
|
-
NSDictionary *params = @{@"connected":@(event.hasConnection)};
|
|
111
|
-
[me sendEvent:EVENT_CONNECTIVITYCHANGE body:params];
|
|
112
|
-
};
|
|
113
|
-
onEnabledChange = ^void(TSEnabledChangeEvent *event) {
|
|
114
|
-
[me sendEvent:EVENT_ENABLEDCHANGE body:@(event.enabled)];
|
|
115
|
-
};
|
|
116
|
-
onAuthorization = ^void(TSAuthorizationEvent *event) {
|
|
117
|
-
[me sendEvent:EVENT_AUTHORIZATION body:[event toDictionary]];
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// EventEmitter listener-counts
|
|
121
|
-
listeners = [NSMutableDictionary new];
|
|
122
|
-
|
|
123
55
|
// TSLocationManager instance
|
|
124
56
|
locationManager = [TSLocationManager sharedInstance];
|
|
125
57
|
|
|
@@ -127,10 +59,59 @@ RCT_EXPORT_MODULE();
|
|
|
127
59
|
UIViewController *root = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
|
|
128
60
|
locationManager.viewController = root;
|
|
129
61
|
}
|
|
130
|
-
|
|
131
62
|
return self;
|
|
132
63
|
}
|
|
133
64
|
|
|
65
|
+
-(void) registerEventListeners {
|
|
66
|
+
__typeof(self) __weak me = self;
|
|
67
|
+
[locationManager onLocation:^(TSLocation *location) {
|
|
68
|
+
[me sendEvent:EVENT_LOCATION body:[location toDictionary]];
|
|
69
|
+
} failure:^(NSError *error) {
|
|
70
|
+
[me sendEvent:EVENT_LOCATION body: @{@"error":@(error.code)}];
|
|
71
|
+
}];
|
|
72
|
+
[locationManager onMotionChange:^(TSLocation *location) {
|
|
73
|
+
[me sendEvent:EVENT_MOTIONCHANGE body:@{@"isMoving":@(location.isMoving), @"location":[location toDictionary]}];
|
|
74
|
+
}];
|
|
75
|
+
[locationManager onActivityChange:^(TSActivityChangeEvent *event) {
|
|
76
|
+
NSDictionary *params = @{@"activity": event.activity, @"confidence": @(event.confidence)};
|
|
77
|
+
[me sendEvent:EVENT_ACTIVITYCHANGE body:params];
|
|
78
|
+
}];
|
|
79
|
+
[locationManager onHeartbeat:^(TSHeartbeatEvent *event) {
|
|
80
|
+
[me sendEvent:EVENT_HEARTBEAT body:@{@"location":[event.location toDictionary]}];
|
|
81
|
+
}];
|
|
82
|
+
[locationManager onGeofence:^(TSGeofenceEvent *event) {
|
|
83
|
+
NSMutableDictionary *params = [[event toDictionary] mutableCopy];
|
|
84
|
+
[params setObject:[event.location toDictionary] forKey:@"location"];
|
|
85
|
+
[me sendEvent:EVENT_GEOFENCE body:params];
|
|
86
|
+
}];
|
|
87
|
+
[locationManager onGeofencesChange:^(TSGeofencesChangeEvent *event) {
|
|
88
|
+
[me sendEvent:EVENT_GEOFENCESCHANGE body:[event toDictionary]];
|
|
89
|
+
}];
|
|
90
|
+
[locationManager onHttp:^(TSHttpEvent *response) {
|
|
91
|
+
NSDictionary *params = @{@"success": @(response.isSuccess), @"status": @(response.statusCode), @"responseText":response.responseText};
|
|
92
|
+
[me sendEvent:EVENT_HTTP body:params];
|
|
93
|
+
}];
|
|
94
|
+
[locationManager onProviderChange:^(TSProviderChangeEvent *event) {
|
|
95
|
+
[me sendEvent:EVENT_PROVIDERCHANGE body:[event toDictionary]];
|
|
96
|
+
}];
|
|
97
|
+
[locationManager onSchedule:^(TSScheduleEvent *event) {
|
|
98
|
+
[me sendEvent:EVENT_SCHEDULE body:event.state];
|
|
99
|
+
}];
|
|
100
|
+
[locationManager onPowerSaveChange:^(TSPowerSaveChangeEvent *event) {
|
|
101
|
+
[me sendEvent:EVENT_POWERSAVECHANGE body:@(event.isPowerSaveMode)];
|
|
102
|
+
}];
|
|
103
|
+
[locationManager onConnectivityChange:^(TSConnectivityChangeEvent *event) {
|
|
104
|
+
NSDictionary *params = @{@"connected":@(event.hasConnection)};
|
|
105
|
+
[me sendEvent:EVENT_CONNECTIVITYCHANGE body:params];
|
|
106
|
+
}];
|
|
107
|
+
[locationManager onEnabledChange:^(TSEnabledChangeEvent *event) {
|
|
108
|
+
[me sendEvent:EVENT_ENABLEDCHANGE body:@(event.enabled)];
|
|
109
|
+
}];
|
|
110
|
+
[locationManager onAuthorization:^(TSAuthorizationEvent *event) {
|
|
111
|
+
[me sendEvent:EVENT_AUTHORIZATION body:[event toDictionary]];
|
|
112
|
+
}];
|
|
113
|
+
}
|
|
114
|
+
|
|
134
115
|
- (NSArray<NSString *> *)supportedEvents {
|
|
135
116
|
return @[
|
|
136
117
|
EVENT_LOCATION,
|
|
@@ -174,20 +155,26 @@ RCT_EXPORT_METHOD(reset:(NSDictionary*)params success:(RCTResponseSenderBlock)su
|
|
|
174
155
|
*/
|
|
175
156
|
RCT_EXPORT_METHOD(ready:(NSDictionary*)params success:(RCTResponseSenderBlock)success failure:(RCTResponseSenderBlock)failure)
|
|
176
157
|
{
|
|
158
|
+
BOOL reset = (params[@"reset"]) ? [params[@"reset"] boolValue] : YES;
|
|
177
159
|
if (ready) {
|
|
178
|
-
[locationManager log:@"warn" message:@"#ready already called. Redirecting to #setConfig"];
|
|
179
160
|
TSConfig *config = [TSConfig sharedInstance];
|
|
180
|
-
|
|
161
|
+
if (reset) {
|
|
162
|
+
[locationManager log:@"warn" message:@"#ready already called. Redirecting to #setConfig"];
|
|
163
|
+
[config updateWithDictionary:params];
|
|
164
|
+
} else {
|
|
165
|
+
[locationManager log:@"warn" message:@"#ready already called. Ignored Config since reset: false"];
|
|
166
|
+
}
|
|
181
167
|
success(@[[config toDictionary]]);
|
|
182
168
|
return;
|
|
183
169
|
}
|
|
184
170
|
ready = YES;
|
|
171
|
+
[self registerEventListeners];
|
|
172
|
+
|
|
185
173
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
186
174
|
TSConfig *config = [TSConfig sharedInstance];
|
|
187
175
|
if (config.isFirstBoot) {
|
|
188
176
|
[config updateWithDictionary:params];
|
|
189
177
|
} else {
|
|
190
|
-
BOOL reset = (params[@"reset"]) ? [params[@"reset"] boolValue] : YES;
|
|
191
178
|
if (reset) {
|
|
192
179
|
[config reset:YES];
|
|
193
180
|
[config updateWithDictionary:params];
|
|
@@ -215,72 +202,10 @@ RCT_EXPORT_METHOD(configure:(NSDictionary*)params success:(RCTResponseSenderBloc
|
|
|
215
202
|
});
|
|
216
203
|
}
|
|
217
204
|
|
|
218
|
-
RCT_EXPORT_METHOD(addEventListener:(NSString*)event)
|
|
219
|
-
{
|
|
220
|
-
@synchronized(listeners) {
|
|
221
|
-
if ([listeners objectForKey:event]) {
|
|
222
|
-
// Increment listener-count for this event
|
|
223
|
-
NSInteger count = [[listeners objectForKey:event] integerValue];
|
|
224
|
-
count++;
|
|
225
|
-
[listeners setObject:@(count) forKey:event];
|
|
226
|
-
} else {
|
|
227
|
-
// First listener for this event
|
|
228
|
-
[listeners setObject:@(1) forKey:event];
|
|
229
|
-
|
|
230
|
-
if ([event isEqualToString:EVENT_LOCATION]) {
|
|
231
|
-
[locationManager onLocation:onLocation failure:onLocationError];
|
|
232
|
-
} else if ([event isEqualToString:EVENT_MOTIONCHANGE]) {
|
|
233
|
-
[locationManager onMotionChange:onMotionChange];
|
|
234
|
-
} else if ([event isEqualToString:EVENT_ACTIVITYCHANGE]) {
|
|
235
|
-
[locationManager onActivityChange:onActivityChange];
|
|
236
|
-
} else if ([event isEqualToString:EVENT_HEARTBEAT]) {
|
|
237
|
-
[locationManager onHeartbeat:onHeartbeat];
|
|
238
|
-
} else if ([event isEqualToString:EVENT_GEOFENCE]) {
|
|
239
|
-
[locationManager onGeofence:onGeofence];
|
|
240
|
-
} else if ([event isEqualToString:EVENT_GEOFENCESCHANGE]) {
|
|
241
|
-
[locationManager onGeofencesChange:onGeofencesChange];
|
|
242
|
-
} else if ([event isEqualToString:EVENT_HTTP]) {
|
|
243
|
-
[locationManager onHttp:onHttp];
|
|
244
|
-
} else if ([event isEqualToString:EVENT_PROVIDERCHANGE]) {
|
|
245
|
-
[locationManager onProviderChange:onProviderChange];
|
|
246
|
-
} else if ([event isEqualToString:EVENT_SCHEDULE]) {
|
|
247
|
-
[locationManager onSchedule:onSchedule];
|
|
248
|
-
} else if ([event isEqualToString:EVENT_POWERSAVECHANGE]) {
|
|
249
|
-
[locationManager onPowerSaveChange:onPowerSaveChange];
|
|
250
|
-
} else if ([event isEqualToString:EVENT_CONNECTIVITYCHANGE]) {
|
|
251
|
-
[locationManager onConnectivityChange:onConnectivityChange];
|
|
252
|
-
} else if ([event isEqualToString:EVENT_ENABLEDCHANGE]) {
|
|
253
|
-
[locationManager onEnabledChange:onEnabledChange];
|
|
254
|
-
} else if ([event isEqualToString:EVENT_AUTHORIZATION]) {
|
|
255
|
-
[[TSHttpService sharedInstance] onAuthorization:onAuthorization];
|
|
256
|
-
} else if ([event isEqualToString:EVENT_NOTIFICATIONACTION]) {
|
|
257
|
-
// No iOS implementation.
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
205
|
|
|
263
|
-
RCT_EXPORT_METHOD(removeListener:(NSString*)event)
|
|
264
|
-
{
|
|
265
|
-
@synchronized(listeners) {
|
|
266
|
-
if ([listeners objectForKey:event]) {
|
|
267
|
-
// Decrement listener-count for this event.
|
|
268
|
-
NSInteger count = [[listeners objectForKey:event] integerValue];
|
|
269
|
-
count--;
|
|
270
|
-
if (count > 0) {
|
|
271
|
-
[listeners setObject:@(count) forKey:event];
|
|
272
|
-
} else {
|
|
273
|
-
// No more listeners: tell TSLocationManager to removeListeners for this event.
|
|
274
|
-
[locationManager removeListeners];
|
|
275
|
-
[listeners removeObjectForKey:event];
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
206
|
|
|
281
207
|
RCT_EXPORT_METHOD(removeAllListeners:(RCTResponseSenderBlock)success failure:(RCTResponseSenderBlock)failure)
|
|
282
208
|
{
|
|
283
|
-
@synchronized(listeners) { [listeners removeAllObjects]; }
|
|
284
209
|
[locationManager removeListeners];
|
|
285
210
|
success(@[]);
|
|
286
211
|
}
|
|
@@ -736,7 +661,7 @@ RCT_EXPORT_METHOD(playSound:(int)soundId)
|
|
|
736
661
|
|
|
737
662
|
- (void)invalidate
|
|
738
663
|
{
|
|
739
|
-
|
|
664
|
+
[super invalidate];
|
|
740
665
|
[locationManager removeListeners];
|
|
741
666
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
742
667
|
[self.locationManager stopWatchPosition];
|
|
@@ -745,7 +670,6 @@ RCT_EXPORT_METHOD(playSound:(int)soundId)
|
|
|
745
670
|
|
|
746
671
|
- (void)dealloc
|
|
747
672
|
{
|
|
748
|
-
@synchronized(listeners) { [listeners removeAllObjects]; }
|
|
749
673
|
[locationManager removeListeners];
|
|
750
674
|
locationManager = nil;
|
|
751
675
|
}
|