react-native-background-geolocation 4.3.0 → 4.4.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/CHANGELOG.md +42 -0
- package/README.md +209 -61
- package/android/libs/com/transistorsoft/tslocationmanager/{3.1.33/tslocationmanager-3.1.33.aar → 3.1.35/tslocationmanager-3.1.35.aar} +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/{3.1.33/tslocationmanager-3.1.33.pom → 3.1.35/tslocationmanager-3.1.35.pom} +1 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/maven-metadata.xml +4 -5
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/{3.1.33/tslocationmanager-reverse-3.1.33.aar → 3.1.35/tslocationmanager-reverse-3.1.35.aar} +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/{3.1.33/tslocationmanager-reverse-3.1.33.pom → 3.1.35/tslocationmanager-reverse-3.1.35.pom} +1 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/maven-metadata.xml +4 -5
- package/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/RNBackgroundGeolocationModule.java +40 -80
- package/ios/RNBackgroundGeolocation/RNBackgroundGeolocation.m +65 -136
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/Info.plist +9 -9
- 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.33/tslocationmanager-3.1.33.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.sha512 +0 -1
|
@@ -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)));
|
|
@@ -991,79 +1017,13 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
991
1017
|
}
|
|
992
1018
|
|
|
993
1019
|
@ReactMethod
|
|
994
|
-
public void
|
|
995
|
-
|
|
996
|
-
if (!mEvents.contains(event)) {
|
|
997
|
-
TSLog.logger.warn(TSLog.warn("[RNBackgroundGeolocation addListener] Unknown event: " + event));
|
|
998
|
-
return;
|
|
999
|
-
}
|
|
1000
|
-
BackgroundGeolocation adapter = getAdapter();
|
|
1001
|
-
Integer count;
|
|
1002
|
-
|
|
1003
|
-
synchronized(mListeners) {
|
|
1004
|
-
if (mListeners.containsKey(event)) {
|
|
1005
|
-
count = mListeners.get(event);
|
|
1006
|
-
count++;
|
|
1007
|
-
mListeners.put(event, count);
|
|
1008
|
-
} else {
|
|
1009
|
-
count = 1;
|
|
1010
|
-
mListeners.put(event, count);
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
if (count == 1) {
|
|
1014
|
-
if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_LOCATION)) {
|
|
1015
|
-
adapter.onLocation(new LocationCallback());
|
|
1016
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_MOTIONCHANGE)) {
|
|
1017
|
-
adapter.onMotionChange(new MotionChangeCallback());
|
|
1018
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_ACTIVITYCHANGE)) {
|
|
1019
|
-
adapter.onActivityChange(new ActivityChangeCallback());
|
|
1020
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_PROVIDERCHANGE)) {
|
|
1021
|
-
adapter.onLocationProviderChange(new LocationProviderChangeCallback());
|
|
1022
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_GEOFENCESCHANGE)) {
|
|
1023
|
-
adapter.onGeofencesChange(new GeofencesChangeCallback());
|
|
1024
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_GEOFENCE)) {
|
|
1025
|
-
adapter.onGeofence(new GeofenceCallback());
|
|
1026
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_HEARTBEAT)) {
|
|
1027
|
-
adapter.onHeartbeat(new HeartbeatCallback());
|
|
1028
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_HTTP)) {
|
|
1029
|
-
adapter.onHttp(new HttpResponseCallback());
|
|
1030
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_SCHEDULE)) {
|
|
1031
|
-
adapter.onSchedule(new ScheduleCallback());
|
|
1032
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_POWERSAVECHANGE)) {
|
|
1033
|
-
adapter.onPowerSaveChange(new PowerSaveChangeCallack());
|
|
1034
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_CONNECTIVITYCHANGE)) {
|
|
1035
|
-
adapter.onConnectivityChange(new ConnectivityChangeCallback());
|
|
1036
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_ENABLEDCHANGE)) {
|
|
1037
|
-
adapter.onEnabledChange(new EnabledChangeCallback());
|
|
1038
|
-
} else if (event.equalsIgnoreCase(BackgroundGeolocation.EVENT_NOTIFICATIONACTION)) {
|
|
1039
|
-
adapter.onNotificationAction(new NotificationActionCallback());
|
|
1040
|
-
} else if (event.equalsIgnoreCase(TSAuthorization.NAME)) {
|
|
1041
|
-
HttpService.getInstance(getReactApplicationContext()).onAuthorization(new AuthorizationCallback());
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
@ReactMethod
|
|
1047
|
-
public void removeListener(String event) {
|
|
1048
|
-
Integer count;
|
|
1049
|
-
|
|
1050
|
-
synchronized (mListeners) {
|
|
1051
|
-
if (mListeners.containsKey(event)) {
|
|
1052
|
-
count = mListeners.get(event);
|
|
1053
|
-
count--;
|
|
1054
|
-
if (count > 0) {
|
|
1055
|
-
mListeners.put(event, count);
|
|
1056
|
-
} else {
|
|
1057
|
-
getAdapter().removeListeners(event);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1020
|
+
public void addListener(String event) {
|
|
1021
|
+
// Keep: Required for RN built-in NativeEventEmitter calls.
|
|
1061
1022
|
}
|
|
1062
1023
|
|
|
1063
1024
|
@ReactMethod
|
|
1064
|
-
public void
|
|
1065
|
-
|
|
1066
|
-
success.invoke();
|
|
1025
|
+
public void removeListeners(Integer count) {
|
|
1026
|
+
// Keep: Required for RN built-in NativeEventEmitter calls.
|
|
1067
1027
|
}
|
|
1068
1028
|
|
|
1069
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,12 @@ RCT_EXPORT_METHOD(playSound:(int)soundId)
|
|
|
736
661
|
|
|
737
662
|
- (void)invalidate
|
|
738
663
|
{
|
|
739
|
-
|
|
664
|
+
// [super invalidate] if exists.
|
|
665
|
+
// https://github.com/transistorsoft/react-native-background-geolocation/issues/1407
|
|
666
|
+
if([super respondsToSelector:@selector(invalidate)]){
|
|
667
|
+
[super performSelector:@selector(invalidate)];
|
|
668
|
+
}
|
|
669
|
+
|
|
740
670
|
[locationManager removeListeners];
|
|
741
671
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
742
672
|
[self.locationManager stopWatchPosition];
|
|
@@ -745,7 +675,6 @@ RCT_EXPORT_METHOD(playSound:(int)soundId)
|
|
|
745
675
|
|
|
746
676
|
- (void)dealloc
|
|
747
677
|
{
|
|
748
|
-
@synchronized(listeners) { [listeners removeAllObjects]; }
|
|
749
678
|
[locationManager removeListeners];
|
|
750
679
|
locationManager = nil;
|
|
751
680
|
}
|
|
@@ -6,47 +6,47 @@
|
|
|
6
6
|
<array>
|
|
7
7
|
<dict>
|
|
8
8
|
<key>LibraryIdentifier</key>
|
|
9
|
-
<string>ios-
|
|
9
|
+
<string>ios-arm64_x86_64-maccatalyst</string>
|
|
10
10
|
<key>LibraryPath</key>
|
|
11
11
|
<string>TSLocationManager.framework</string>
|
|
12
12
|
<key>SupportedArchitectures</key>
|
|
13
13
|
<array>
|
|
14
14
|
<string>arm64</string>
|
|
15
|
-
<string>i386</string>
|
|
16
15
|
<string>x86_64</string>
|
|
17
16
|
</array>
|
|
18
17
|
<key>SupportedPlatform</key>
|
|
19
18
|
<string>ios</string>
|
|
20
19
|
<key>SupportedPlatformVariant</key>
|
|
21
|
-
<string>
|
|
20
|
+
<string>maccatalyst</string>
|
|
22
21
|
</dict>
|
|
23
22
|
<dict>
|
|
24
23
|
<key>LibraryIdentifier</key>
|
|
25
|
-
<string>ios-
|
|
24
|
+
<string>ios-arm64_i386_x86_64-simulator</string>
|
|
26
25
|
<key>LibraryPath</key>
|
|
27
26
|
<string>TSLocationManager.framework</string>
|
|
28
27
|
<key>SupportedArchitectures</key>
|
|
29
28
|
<array>
|
|
30
29
|
<string>arm64</string>
|
|
31
|
-
<string>
|
|
30
|
+
<string>i386</string>
|
|
31
|
+
<string>x86_64</string>
|
|
32
32
|
</array>
|
|
33
33
|
<key>SupportedPlatform</key>
|
|
34
34
|
<string>ios</string>
|
|
35
|
+
<key>SupportedPlatformVariant</key>
|
|
36
|
+
<string>simulator</string>
|
|
35
37
|
</dict>
|
|
36
38
|
<dict>
|
|
37
39
|
<key>LibraryIdentifier</key>
|
|
38
|
-
<string>ios-
|
|
40
|
+
<string>ios-arm64_armv7</string>
|
|
39
41
|
<key>LibraryPath</key>
|
|
40
42
|
<string>TSLocationManager.framework</string>
|
|
41
43
|
<key>SupportedArchitectures</key>
|
|
42
44
|
<array>
|
|
43
45
|
<string>arm64</string>
|
|
44
|
-
<string>
|
|
46
|
+
<string>armv7</string>
|
|
45
47
|
</array>
|
|
46
48
|
<key>SupportedPlatform</key>
|
|
47
49
|
<string>ios</string>
|
|
48
|
-
<key>SupportedPlatformVariant</key>
|
|
49
|
-
<string>maccatalyst</string>
|
|
50
50
|
</dict>
|
|
51
51
|
</array>
|
|
52
52
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<plist version="1.0">
|
|
4
4
|
<dict>
|
|
5
5
|
<key>BuildMachineOSBuild</key>
|
|
6
|
-
<string>
|
|
6
|
+
<string>21A559</string>
|
|
7
7
|
<key>CFBundleDevelopmentRegion</key>
|
|
8
8
|
<string>en</string>
|
|
9
9
|
<key>CFBundleExecutable</key>
|
|
@@ -17,29 +17,29 @@
|
|
|
17
17
|
<key>CFBundlePackageType</key>
|
|
18
18
|
<string>FMWK</string>
|
|
19
19
|
<key>CFBundleShortVersionString</key>
|
|
20
|
-
<string>4.0
|
|
20
|
+
<string>4.1.0</string>
|
|
21
21
|
<key>CFBundleSupportedPlatforms</key>
|
|
22
22
|
<array>
|
|
23
23
|
<string>MacOSX</string>
|
|
24
24
|
</array>
|
|
25
25
|
<key>CFBundleVersion</key>
|
|
26
|
-
<string>
|
|
26
|
+
<string>382</string>
|
|
27
27
|
<key>DTCompiler</key>
|
|
28
28
|
<string>com.apple.compilers.llvm.clang.1_0</string>
|
|
29
29
|
<key>DTPlatformBuild</key>
|
|
30
|
-
<string>
|
|
30
|
+
<string>13A1030d</string>
|
|
31
31
|
<key>DTPlatformName</key>
|
|
32
32
|
<string>macosx</string>
|
|
33
33
|
<key>DTPlatformVersion</key>
|
|
34
|
-
<string>
|
|
34
|
+
<string>12.0</string>
|
|
35
35
|
<key>DTSDKBuild</key>
|
|
36
|
-
<string>
|
|
36
|
+
<string>21A344</string>
|
|
37
37
|
<key>DTSDKName</key>
|
|
38
|
-
<string>
|
|
38
|
+
<string>macosx12.0</string>
|
|
39
39
|
<key>DTXcode</key>
|
|
40
|
-
<string>
|
|
40
|
+
<string>1310</string>
|
|
41
41
|
<key>DTXcodeBuild</key>
|
|
42
|
-
<string>
|
|
42
|
+
<string>13A1030d</string>
|
|
43
43
|
<key>LSMinimumSystemVersion</key>
|
|
44
44
|
<string>10.15</string>
|
|
45
45
|
<key>UIDeviceFamily</key>
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-background-geolocation",
|
|
3
|
-
"version": "4.3
|
|
3
|
+
"version": "4.4.3",
|
|
4
4
|
"description": "The most sophisticated cross-platform background location-tracking & geofencing module with battery-conscious motion-detection intelligence",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"react-native": ">=0.36.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"react-native-background-fetch": "~4.0.
|
|
46
|
+
"react-native-background-fetch": "~4.0.4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@transistorsoft/typedoc-theme": "^2.0.
|
|
49
|
+
"@transistorsoft/typedoc-theme": "^2.0.8",
|
|
50
50
|
"chalk": "^4.1.0",
|
|
51
51
|
"fs-extra": "^9.1.0",
|
|
52
52
|
"rimraf": "^3.0.2"
|