react-native-radar 3.1.7 → 3.2.0
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/android/build.gradle +14 -13
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/gradle.properties +1 -0
- package/android/src/main/AndroidManifest.xml +0 -11
- package/android/src/main/java/io/radar/react/RNRadarModule.java +5 -3
- package/android/src/main/java/io/radar/react/RNRadarReceiver.java +7 -28
- package/ios/RNRadar.m +11 -10
- package/package.json +4 -1
- package/react-native-radar.podspec +1 -1
package/android/build.gradle
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
buildscript {
|
|
2
2
|
repositories {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
jcenter()
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
7
5
|
}
|
|
8
6
|
|
|
9
7
|
dependencies {
|
|
10
|
-
classpath 'com.android.tools.build:gradle:
|
|
8
|
+
classpath 'com.android.tools.build:gradle:7.0.3'
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
apply plugin: 'com.android.library'
|
|
15
13
|
|
|
16
14
|
android {
|
|
17
|
-
compileSdkVersion
|
|
15
|
+
compileSdkVersion 31
|
|
18
16
|
|
|
19
17
|
defaultConfig {
|
|
20
18
|
minSdkVersion 16
|
|
21
|
-
targetSdkVersion
|
|
19
|
+
targetSdkVersion 31
|
|
22
20
|
versionCode 1
|
|
23
|
-
versionName '3.
|
|
21
|
+
versionName '3.2.0'
|
|
24
22
|
}
|
|
25
23
|
lintOptions {
|
|
26
24
|
abortOnError false
|
|
@@ -28,14 +26,17 @@ android {
|
|
|
28
26
|
testOptions {
|
|
29
27
|
unitTests.returnDefaultValues = true
|
|
30
28
|
}
|
|
29
|
+
configurations.all {
|
|
30
|
+
resolutionStrategy {
|
|
31
|
+
force 'androidx.core:core:1.6.0'
|
|
32
|
+
force 'androidx.core:core-ktx:1.6.0'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
repositories {
|
|
34
38
|
mavenCentral()
|
|
35
|
-
|
|
36
|
-
url 'https://maven.google.com'
|
|
37
|
-
}
|
|
38
|
-
jcenter()
|
|
39
|
+
google()
|
|
39
40
|
maven {
|
|
40
41
|
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
41
42
|
url "$rootDir/../node_modules/react-native/android"
|
|
@@ -44,5 +45,5 @@ repositories {
|
|
|
44
45
|
|
|
45
46
|
dependencies {
|
|
46
47
|
api 'com.facebook.react:react-native:+'
|
|
47
|
-
api 'io.radar:sdk:3.
|
|
48
|
+
api 'io.radar:sdk:3.2.3'
|
|
48
49
|
}
|
|
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|
|
3
3
|
distributionPath=wrapper/dists
|
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
5
|
zipStorePath=wrapper/dists
|
|
6
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
6
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
android.useAndroidX=true
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
2
|
package="io.radar.react">
|
|
3
3
|
|
|
4
|
-
<application>
|
|
5
|
-
<receiver
|
|
6
|
-
android:name="io.radar.react.RNRadarReceiver"
|
|
7
|
-
android:enabled="true"
|
|
8
|
-
android:exported="false">
|
|
9
|
-
<intent-filter>
|
|
10
|
-
<action android:name="io.radar.sdk.RECEIVED" />
|
|
11
|
-
</intent-filter>
|
|
12
|
-
</receiver>
|
|
13
|
-
</application>
|
|
14
|
-
|
|
15
4
|
</manifest>
|
|
@@ -31,6 +31,7 @@ import io.radar.sdk.model.RadarGeofence;
|
|
|
31
31
|
import io.radar.sdk.model.RadarPlace;
|
|
32
32
|
import io.radar.sdk.model.RadarRouteMatrix;
|
|
33
33
|
import io.radar.sdk.model.RadarRoutes;
|
|
34
|
+
import io.radar.sdk.model.RadarTrip;
|
|
34
35
|
import io.radar.sdk.model.RadarUser;
|
|
35
36
|
|
|
36
37
|
import org.json.JSONException;
|
|
@@ -46,6 +47,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
46
47
|
|
|
47
48
|
public RNRadarModule(ReactApplicationContext reactContext) {
|
|
48
49
|
super(reactContext);
|
|
50
|
+
Radar.setReceiver(new RNRadarReceiver());
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
@Override
|
|
@@ -335,7 +337,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
335
337
|
RadarTripOptions options = RadarTripOptions.fromJson(optionsObj);
|
|
336
338
|
Radar.startTrip(options, new Radar.RadarTripCallback() {
|
|
337
339
|
@Override
|
|
338
|
-
public void onComplete(@NonNull Radar.RadarStatus status) {
|
|
340
|
+
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
|
|
339
341
|
|
|
340
342
|
}
|
|
341
343
|
});
|
|
@@ -348,7 +350,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
348
350
|
public void completeTrip() {
|
|
349
351
|
Radar.completeTrip(new Radar.RadarTripCallback() {
|
|
350
352
|
@Override
|
|
351
|
-
public void onComplete(@NonNull Radar.RadarStatus status) {
|
|
353
|
+
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
|
|
352
354
|
|
|
353
355
|
}
|
|
354
356
|
});
|
|
@@ -358,7 +360,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
358
360
|
public void cancelTrip() {
|
|
359
361
|
Radar.cancelTrip(new Radar.RadarTripCallback() {
|
|
360
362
|
@Override
|
|
361
|
-
public void onComplete(@NonNull Radar.RadarStatus status) {
|
|
363
|
+
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
|
|
362
364
|
|
|
363
365
|
}
|
|
364
366
|
});
|
|
@@ -5,6 +5,7 @@ import android.location.Location;
|
|
|
5
5
|
import android.util.Log;
|
|
6
6
|
|
|
7
7
|
import androidx.annotation.NonNull;
|
|
8
|
+
import androidx.annotation.Nullable;
|
|
8
9
|
|
|
9
10
|
import com.facebook.react.ReactApplication;
|
|
10
11
|
import com.facebook.react.ReactInstanceManager;
|
|
@@ -23,49 +24,27 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
23
24
|
public class RNRadarReceiver extends RadarReceiver {
|
|
24
25
|
|
|
25
26
|
private ReactNativeHost reactNativeHost;
|
|
26
|
-
private PendingResult result;
|
|
27
|
-
private AtomicInteger pendingCount = new AtomicInteger(0);
|
|
28
27
|
private static final String TAG = "RNRadarReceiver";
|
|
29
28
|
|
|
30
|
-
private void invokeSendEvent(ReactContext reactContext, String eventName, Object data) {
|
|
31
|
-
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
29
|
private void sendEvent(final String eventName, final Object data) {
|
|
35
30
|
final ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
|
|
36
31
|
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
|
|
37
|
-
if (reactContext
|
|
38
|
-
|
|
39
|
-
result = goAsync();
|
|
40
|
-
}
|
|
41
|
-
pendingCount.incrementAndGet();
|
|
42
|
-
reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
|
|
43
|
-
@Override
|
|
44
|
-
public void onReactContextInitialized(ReactContext reactContext) {
|
|
45
|
-
invokeSendEvent(reactContext, eventName, data);
|
|
46
|
-
reactInstanceManager.removeReactInstanceEventListener(this);
|
|
47
|
-
if (pendingCount.decrementAndGet() == 0) {
|
|
48
|
-
result.finish();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
if (!reactInstanceManager.hasStartedCreatingInitialContext()) {
|
|
53
|
-
reactInstanceManager.createReactContextInBackground();
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
invokeSendEvent(reactContext, eventName, data);
|
|
32
|
+
if (reactContext != null) {
|
|
33
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
|
|
57
34
|
}
|
|
58
35
|
}
|
|
59
36
|
|
|
60
37
|
@Override
|
|
61
|
-
public void onEventsReceived(@NonNull Context context, @NonNull RadarEvent[] events, @
|
|
38
|
+
public void onEventsReceived(@NonNull Context context, @NonNull RadarEvent[] events, @Nullable RadarUser user) {
|
|
62
39
|
try {
|
|
63
40
|
ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
|
|
64
41
|
reactNativeHost = reactApplication.getReactNativeHost();
|
|
65
42
|
|
|
66
43
|
WritableMap map = Arguments.createMap();
|
|
67
44
|
map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
|
|
68
|
-
|
|
45
|
+
if (user != null) {
|
|
46
|
+
map.putMap("user", RNRadarUtils.mapForJson(user.toJson()));
|
|
47
|
+
}
|
|
69
48
|
|
|
70
49
|
sendEvent("events", map);
|
|
71
50
|
} catch (Exception e) {
|
package/ios/RNRadar.m
CHANGED
|
@@ -49,13 +49,14 @@ RCT_EXPORT_MODULE();
|
|
|
49
49
|
hasListeners = NO;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
- (void)didReceiveEvents:(NSArray<RadarEvent *> *)events user:(RadarUser *)user {
|
|
52
|
+
- (void)didReceiveEvents:(NSArray<RadarEvent *> *)events user:(RadarUser * _Nullable )user {
|
|
53
53
|
if (hasListeners) {
|
|
54
|
-
[
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
54
|
+
NSMutableDictionary *body = [NSMutableDictionary new];
|
|
55
|
+
[body setValue:[RadarEvent arrayForEvents:events] forKey:@"events"];
|
|
56
|
+
if (user) {
|
|
57
|
+
[body setValue:[user dictionaryValue] forKey:@"user"];
|
|
58
|
+
}
|
|
59
|
+
[self sendEventWithName:@"events" body:body];
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -73,7 +74,7 @@ RCT_EXPORT_MODULE();
|
|
|
73
74
|
[self sendEventWithName:@"clientLocation" body:@{
|
|
74
75
|
@"location": [Radar dictionaryForLocation:location],
|
|
75
76
|
@"stopped": @(stopped),
|
|
76
|
-
@"source": [Radar
|
|
77
|
+
@"source": [Radar stringForLocationSource:source]
|
|
77
78
|
}];
|
|
78
79
|
}
|
|
79
80
|
}
|
|
@@ -245,15 +246,15 @@ RCT_EXPORT_METHOD(trackOnce:(NSDictionary *)locationDict resolve:(RCTPromiseReso
|
|
|
245
246
|
}
|
|
246
247
|
|
|
247
248
|
RCT_EXPORT_METHOD(startTrackingEfficient) {
|
|
248
|
-
[Radar startTrackingWithOptions:RadarTrackingOptions.
|
|
249
|
+
[Radar startTrackingWithOptions:RadarTrackingOptions.presetEfficient];
|
|
249
250
|
}
|
|
250
251
|
|
|
251
252
|
RCT_EXPORT_METHOD(startTrackingResponsive) {
|
|
252
|
-
[Radar startTrackingWithOptions:RadarTrackingOptions.
|
|
253
|
+
[Radar startTrackingWithOptions:RadarTrackingOptions.presetResponsive];
|
|
253
254
|
}
|
|
254
255
|
|
|
255
256
|
RCT_EXPORT_METHOD(startTrackingContinuous) {
|
|
256
|
-
[Radar startTrackingWithOptions:RadarTrackingOptions.
|
|
257
|
+
[Radar startTrackingWithOptions:RadarTrackingOptions.presetContinuous];
|
|
257
258
|
}
|
|
258
259
|
|
|
259
260
|
RCT_EXPORT_METHOD(startTrackingCustom:(NSDictionary *)optionsDict) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "React Native module for Radar, the leading geofencing and location tracking platform",
|
|
4
4
|
"homepage": "https://radar.io",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.2.0",
|
|
7
7
|
"main": "js/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"android",
|
|
@@ -56,5 +56,8 @@
|
|
|
56
56
|
"repository": {
|
|
57
57
|
"type": "git",
|
|
58
58
|
"url": "https://github.com/radarlabs/react-native-radar.git"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@react-native-community/netinfo": "^7.1.3"
|
|
59
62
|
}
|
|
60
63
|
}
|