react-native-background-geolocation 4.1.1 → 4.4.1
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 +52 -0
- package/android/build.gradle +7 -10
- package/android/libs/com/transistorsoft/tslocationmanager/{3.1.29/tslocationmanager-3.1.29.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.29/tslocationmanager-3.1.29.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.29/tslocationmanager-reverse-3.1.29.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.29/tslocationmanager-reverse-3.1.29.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 +41 -79
- package/ios/RNBackgroundGeolocation/RNBackgroundGeolocation.m +60 -136
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/Info.plist +5 -5
- 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 +9 -9
- 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.29/tslocationmanager-3.1.29.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.29/tslocationmanager-3.1.29.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.29/tslocationmanager-3.1.29.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.29/tslocationmanager-3.1.29.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.29/tslocationmanager-3.1.29.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.29/tslocationmanager-3.1.29.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.29/tslocationmanager-3.1.29.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.29/tslocationmanager-3.1.29.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.29/tslocationmanager-reverse-3.1.29.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.29/tslocationmanager-reverse-3.1.29.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.29/tslocationmanager-reverse-3.1.29.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.29/tslocationmanager-reverse-3.1.29.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.29/tslocationmanager-reverse-3.1.29.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.29/tslocationmanager-reverse-3.1.29.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.29/tslocationmanager-reverse-3.1.29.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.29/tslocationmanager-reverse-3.1.29.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.4.1 — 2021-10-29
|
|
4
|
+
* [Added] Added a `Subscription` interface to Typescript API. Added helpful docs to Subscription for new event-handler subscriptions.
|
|
5
|
+
|
|
6
|
+
```typescript
|
|
7
|
+
import BackgroundGeolocation, {
|
|
8
|
+
Subscription
|
|
9
|
+
} from "...";
|
|
10
|
+
.
|
|
11
|
+
.
|
|
12
|
+
.
|
|
13
|
+
const subscription:Subscription = BacckgroundGeolocation.onLocation(myHandler);
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 4.4.0 — 2021-10-25
|
|
17
|
+
* [Added] New `Authorization.strategy "SAS"` (alternative to default `JWT`).
|
|
18
|
+
* [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`.
|
|
19
|
+
* [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:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
/// OLD
|
|
23
|
+
const onLocation = (location) => {
|
|
24
|
+
console.log('[onLocation');
|
|
25
|
+
}
|
|
26
|
+
BackgroundGeolocation.onLocation(onLocation);
|
|
27
|
+
...
|
|
28
|
+
// deprecated: removeListener
|
|
29
|
+
BackgroundGeolocation.removeListener('location', onLocation);
|
|
30
|
+
|
|
31
|
+
/// NEW: capture returned subscription instance.
|
|
32
|
+
const onLocationSubscription = BackgroundGeolocation.onLocation(onLocation);
|
|
33
|
+
...
|
|
34
|
+
// Removing an event-listener.
|
|
35
|
+
onLocationSubscription.remove();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 4.3.0 — 2021-09-14
|
|
39
|
+
|
|
40
|
+
* [Added][Android] Implement new Android 12 "reduced accuracy" mechanism `requestTemporaryFullAccuracy`.
|
|
41
|
+
* [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.
|
|
42
|
+
* [Fixed][Android] Fixed crash reported by Huawei device, where verticalAccuracy returns NaN.
|
|
43
|
+
|
|
44
|
+
## [4.2.2] — 2021-08-23
|
|
45
|
+
* [Fixed][iOS] add config change listeners for `heartbeatInterval` and `preventSuspend` to dynamically update interval when changed with `setConfig`.
|
|
46
|
+
* [Fixed][Android] Add `accuracyAuthorization` param to event data provided to `onProviderChange` event.
|
|
47
|
+
* [Changed][Android] Update Android default `okhttp` version to `3.12.13`.
|
|
48
|
+
* [Changed][Android] Update Android `eventbus` version to `3.2.0`.
|
|
49
|
+
* [Changed][Android] Update Android `android-permissions` to import from *MavenCentral* instead of deprecated `jCenter`.
|
|
50
|
+
* [Fixed][Android] Fix an edge-case requesting motion permission. If `getCurrentPosition()` is executed before `.start()`, the Android SDK fails to request motion permission.
|
|
51
|
+
|
|
52
|
+
## 4.1.2 — 2021-07-05
|
|
53
|
+
* [Changed] Build iOS TSLocationManager.xcframework with XCode 12.4 instead of 12.5
|
|
54
|
+
|
|
3
55
|
## 4.1.1 — 2021-06-11
|
|
4
56
|
* [Fixed][iOS] Reports 2 reports of iOS crash `NSInvalidArgumentException (TSLocation.m line 178)` with iOS 14
|
|
5
57
|
.x. Wrap JSON serialization in @try/@catch block. iOS JSON serialization docs state the supplied NSError err
|
package/android/build.gradle
CHANGED
|
@@ -3,13 +3,13 @@ apply plugin: 'com.android.library'
|
|
|
3
3
|
// Android dependencies
|
|
4
4
|
def DEFAULT_COMPILE_SDK_VERSION = 28
|
|
5
5
|
def DEFAULT_TARGET_SDK_VERSION = 28
|
|
6
|
-
def DEFAULT_APP_COMPAT_VERSION = "
|
|
6
|
+
def DEFAULT_APP_COMPAT_VERSION = "1.3.1"
|
|
7
7
|
|
|
8
8
|
// Plugin dependencies
|
|
9
|
-
def DEFAULT_GOOGLE_PLAY_SERVICES_LOCATION_VERSION = "
|
|
10
|
-
def DEFAULT_OK_HTTP_VERSION = "3.12.
|
|
9
|
+
def DEFAULT_GOOGLE_PLAY_SERVICES_LOCATION_VERSION = "18.0.0"
|
|
10
|
+
def DEFAULT_OK_HTTP_VERSION = "3.12.13"
|
|
11
11
|
def DEFAULT_ANDROID_PERMISSIONS_VERSION = "0.1.8"
|
|
12
|
-
def DEFAULT_EVENTBUS_VERSION = "3.
|
|
12
|
+
def DEFAULT_EVENTBUS_VERSION = "3.2.0"
|
|
13
13
|
def DEFAULT_LOCAL_BROADCAST_MANAGER_VERSION = "1.0.0"
|
|
14
14
|
|
|
15
15
|
def useAndroidX = (project.hasProperty("android.useAndroidX")) ? project.property("android.useAndroidX") : false
|
|
@@ -37,10 +37,7 @@ repositories{
|
|
|
37
37
|
|
|
38
38
|
dependencies {
|
|
39
39
|
// Prefer appCompatVersion vs supportLibVersion.
|
|
40
|
-
def appCompatVersion = safeExtGet('appCompatVersion',
|
|
41
|
-
|
|
42
|
-
def appCompatMajorVersion = appCompatVersion.split('\\.')[0] as int
|
|
43
|
-
def appCompatLibName = (appCompatMajorVersion < 20) ? "androidx.appcompat:appcompat" : "com.android.support:appcompat-v7"
|
|
40
|
+
def appCompatVersion = safeExtGet('appCompatVersion', DEFAULT_APP_COMPAT_VERSION)
|
|
44
41
|
def playServicesLocationVersion = safeExtGet('googlePlayServicesLocationVersion', DEFAULT_GOOGLE_PLAY_SERVICES_LOCATION_VERSION)
|
|
45
42
|
def okHttpVersion = safeExtGet('okHttpVersion', DEFAULT_OK_HTTP_VERSION)
|
|
46
43
|
def androidPermissionsVersion = safeExtGet('androidPermissionsVersion', DEFAULT_ANDROID_PERMISSIONS_VERSION)
|
|
@@ -55,11 +52,11 @@ dependencies {
|
|
|
55
52
|
api(group: 'com.transistorsoft', name:'tslocationmanager-reverse', version: '+')
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
implementation "
|
|
55
|
+
implementation "androidx.appcompat:appcompat:$appCompatVersion"
|
|
59
56
|
implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"
|
|
60
57
|
implementation "org.greenrobot:eventbus:$eventBusVersion"
|
|
61
58
|
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
|
|
62
59
|
implementation 'org.slf4j:slf4j-api:1.7.25'
|
|
63
60
|
implementation 'com.github.tony19:logback-android:2.0.0'
|
|
64
|
-
implementation "
|
|
61
|
+
implementation "io.github.nishkarsh:android-permissions:$androidPermissionsVersion"
|
|
65
62
|
}
|
|
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>
|
|
@@ -115,6 +115,22 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
115
115
|
mEvents.add(TSAuthorization.NAME);
|
|
116
116
|
|
|
117
117
|
reactContext.addLifecycleEventListener(this);
|
|
118
|
+
|
|
119
|
+
BackgroundGeolocation adapter = getAdapter();
|
|
120
|
+
adapter.onLocation(new LocationCallback());
|
|
121
|
+
adapter.onMotionChange(new MotionChangeCallback());
|
|
122
|
+
adapter.onActivityChange(new ActivityChangeCallback());
|
|
123
|
+
adapter.onLocationProviderChange(new LocationProviderChangeCallback());
|
|
124
|
+
adapter.onGeofencesChange(new GeofencesChangeCallback());
|
|
125
|
+
adapter.onGeofence(new GeofenceCallback());
|
|
126
|
+
adapter.onHeartbeat(new HeartbeatCallback());
|
|
127
|
+
adapter.onHttp(new HttpResponseCallback());
|
|
128
|
+
adapter.onSchedule(new ScheduleCallback());
|
|
129
|
+
adapter.onPowerSaveChange(new PowerSaveChangeCallack());
|
|
130
|
+
adapter.onConnectivityChange(new ConnectivityChangeCallback());
|
|
131
|
+
adapter.onEnabledChange(new EnabledChangeCallback());
|
|
132
|
+
adapter.onNotificationAction(new NotificationActionCallback());
|
|
133
|
+
HttpService.getInstance(getReactApplicationContext()).onAuthorization(new AuthorizationCallback());
|
|
118
134
|
}
|
|
119
135
|
|
|
120
136
|
@Override
|
|
@@ -184,6 +200,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
184
200
|
params.putBoolean("network", event.isNetworkEnabled());
|
|
185
201
|
params.putBoolean("gps", event.isGPSEnabled());
|
|
186
202
|
params.putBoolean("enabled", event.isEnabled());
|
|
203
|
+
params.putInt("accuracyAuthorization", event.getAccuracyAuthorization());
|
|
187
204
|
params.putInt("status", event.getStatus());
|
|
188
205
|
sendEvent(BackgroundGeolocation.EVENT_PROVIDERCHANGE, params);
|
|
189
206
|
}
|
|
@@ -305,6 +322,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
305
322
|
}
|
|
306
323
|
}
|
|
307
324
|
}
|
|
325
|
+
|
|
308
326
|
@Override
|
|
309
327
|
public void onHostResume() {
|
|
310
328
|
if (!mInitialized) {
|
|
@@ -345,19 +363,24 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
345
363
|
public void ready(ReadableMap params, final Callback success, final Callback failure) {
|
|
346
364
|
TSConfig config = TSConfig.getInstance(getReactApplicationContext());
|
|
347
365
|
|
|
366
|
+
boolean reset = true;
|
|
367
|
+
if (params.hasKey("reset")) {
|
|
368
|
+
reset = params.getBoolean("reset");
|
|
369
|
+
}
|
|
370
|
+
|
|
348
371
|
if (mReady) {
|
|
349
|
-
|
|
350
|
-
|
|
372
|
+
if (reset) {
|
|
373
|
+
TSLog.logger.warn(TSLog.warn("#ready already called. Redirecting to #setConfig"));
|
|
374
|
+
setConfig(params, success, failure);
|
|
375
|
+
} else {
|
|
376
|
+
TSLog.logger.warn(TSLog.warn("#ready already called. Ignored config since reset: false"));
|
|
377
|
+
}
|
|
351
378
|
return;
|
|
352
379
|
}
|
|
353
380
|
mReady = true;
|
|
354
381
|
if (config.isFirstBoot()) {
|
|
355
382
|
config.updateWithJSONObject(mapToJson(setHeadlessJobService(params)));
|
|
356
383
|
} else {
|
|
357
|
-
boolean reset = true;
|
|
358
|
-
if (params.hasKey("reset")) {
|
|
359
|
-
reset = params.getBoolean("reset");
|
|
360
|
-
}
|
|
361
384
|
if (reset) {
|
|
362
385
|
config.reset();
|
|
363
386
|
config.updateWithJSONObject(mapToJson(setHeadlessJobService(params)));
|
|
@@ -972,92 +995,31 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
972
995
|
success.invoke(status);
|
|
973
996
|
}
|
|
974
997
|
@Override public void onFailure(int status) {
|
|
975
|
-
|
|
998
|
+
success.invoke(status);
|
|
976
999
|
}
|
|
977
1000
|
});
|
|
978
1001
|
}
|
|
979
1002
|
|
|
980
1003
|
@ReactMethod
|
|
981
|
-
public void requestTemporaryFullAccuracy(String purpose, Callback success, Callback failure) {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
@ReactMethod
|
|
988
|
-
public void addEventListener(String event) {
|
|
989
|
-
|
|
990
|
-
if (!mEvents.contains(event)) {
|
|
991
|
-
TSLog.logger.warn(TSLog.warn("[RNBackgroundGeolocation addListener] Unknown event: " + event));
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
|
-
BackgroundGeolocation adapter = getAdapter();
|
|
995
|
-
Integer count;
|
|
996
|
-
|
|
997
|
-
synchronized(mListeners) {
|
|
998
|
-
if (mListeners.containsKey(event)) {
|
|
999
|
-
count = mListeners.get(event);
|
|
1000
|
-
count++;
|
|
1001
|
-
mListeners.put(event, count);
|
|
1002
|
-
} else {
|
|
1003
|
-
count = 1;
|
|
1004
|
-
mListeners.put(event, count);
|
|
1004
|
+
public void requestTemporaryFullAccuracy(String purpose, final Callback success, final Callback failure) {
|
|
1005
|
+
getAdapter().requestTemporaryFullAccuracy(purpose, new TSRequestPermissionCallback() {
|
|
1006
|
+
@Override public void onSuccess(int accuracyAuthorization) {
|
|
1007
|
+
success.invoke(accuracyAuthorization);
|
|
1005
1008
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_LOCATION)) {
|
|
1009
|
-
adapter.onLocation(new LocationCallback());
|
|
1010
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_MOTIONCHANGE)) {
|
|
1011
|
-
adapter.onMotionChange(new MotionChangeCallback());
|
|
1012
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_ACTIVITYCHANGE)) {
|
|
1013
|
-
adapter.onActivityChange(new ActivityChangeCallback());
|
|
1014
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_PROVIDERCHANGE)) {
|
|
1015
|
-
adapter.onLocationProviderChange(new LocationProviderChangeCallback());
|
|
1016
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_GEOFENCESCHANGE)) {
|
|
1017
|
-
adapter.onGeofencesChange(new GeofencesChangeCallback());
|
|
1018
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_GEOFENCE)) {
|
|
1019
|
-
adapter.onGeofence(new GeofenceCallback());
|
|
1020
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_HEARTBEAT)) {
|
|
1021
|
-
adapter.onHeartbeat(new HeartbeatCallback());
|
|
1022
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_HTTP)) {
|
|
1023
|
-
adapter.onHttp(new HttpResponseCallback());
|
|
1024
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_SCHEDULE)) {
|
|
1025
|
-
adapter.onSchedule(new ScheduleCallback());
|
|
1026
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_POWERSAVECHANGE)) {
|
|
1027
|
-
adapter.onPowerSaveChange(new PowerSaveChangeCallack());
|
|
1028
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_CONNECTIVITYCHANGE)) {
|
|
1029
|
-
adapter.onConnectivityChange(new ConnectivityChangeCallback());
|
|
1030
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_ENABLEDCHANGE)) {
|
|
1031
|
-
adapter.onEnabledChange(new EnabledChangeCallback());
|
|
1032
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_NOTIFICATIONACTION)) {
|
|
1033
|
-
adapter.onNotificationAction(new NotificationActionCallback());
|
|
1034
|
-
} else if (event.equalsIgnoreCase(TSAuthorization.NAME)) {
|
|
1035
|
-
HttpService.getInstance(getReactApplicationContext()).onAuthorization(new AuthorizationCallback());
|
|
1009
|
+
@Override public void onFailure(int accuracyAuthorization) {
|
|
1010
|
+
success.invoke(accuracyAuthorization);
|
|
1036
1011
|
}
|
|
1037
|
-
}
|
|
1012
|
+
});
|
|
1038
1013
|
}
|
|
1039
1014
|
|
|
1040
1015
|
@ReactMethod
|
|
1041
|
-
public void
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
synchronized (mListeners) {
|
|
1045
|
-
if (mListeners.containsKey(event)) {
|
|
1046
|
-
count = mListeners.get(event);
|
|
1047
|
-
count--;
|
|
1048
|
-
if (count > 0) {
|
|
1049
|
-
mListeners.put(event, count);
|
|
1050
|
-
} else {
|
|
1051
|
-
getAdapter().removeListeners(event);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1016
|
+
public void addListener(String event) {
|
|
1017
|
+
// Keep: Required for RN built-in NativeEventEmitter calls.
|
|
1055
1018
|
}
|
|
1056
1019
|
|
|
1057
1020
|
@ReactMethod
|
|
1058
|
-
public void
|
|
1059
|
-
|
|
1060
|
-
success.invoke();
|
|
1021
|
+
public void removeListeners(Integer count) {
|
|
1022
|
+
// Keep: Required for RN built-in NativeEventEmitter calls.
|
|
1061
1023
|
}
|
|
1062
1024
|
|
|
1063
1025
|
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
|
}
|