@sentiance-react-native/core 6.2.0-rc.2 → 6.2.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/android/src/main/java/com/sentiance/react/bridge/core/SentianceConverter.java +2 -13
- package/android/src/main/java/com/sentiance/react/bridge/core/common/SentianceCommonConverter.java +24 -0
- package/ios/RNSentianceCore+Converter.m +25 -0
- package/ios/RNSentianceCore.podspec +1 -1
- package/lib/index.d.ts +4 -4
- package/package.json +3 -3
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.sentiance.react.bridge.core;
|
|
2
2
|
|
|
3
|
+
import static com.sentiance.react.bridge.core.common.SentianceCommonConverter.convertLocation;
|
|
4
|
+
|
|
3
5
|
import android.location.Location;
|
|
4
6
|
|
|
5
7
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -207,19 +209,6 @@ public class SentianceConverter {
|
|
|
207
209
|
return map;
|
|
208
210
|
}
|
|
209
211
|
|
|
210
|
-
public static WritableMap convertLocation(Location location) {
|
|
211
|
-
WritableMap locationMap = Arguments.createMap();
|
|
212
|
-
|
|
213
|
-
locationMap.putString("latitude", String.valueOf(location.getLatitude()));
|
|
214
|
-
locationMap.putString("longitude", String.valueOf(location.getLongitude()));
|
|
215
|
-
locationMap.putString("accuracy", String.valueOf(location.getAccuracy()));
|
|
216
|
-
locationMap.putString("altitude", String.valueOf(location.getAltitude()));
|
|
217
|
-
locationMap.putString("provider", location.getProvider());
|
|
218
|
-
|
|
219
|
-
return locationMap;
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
212
|
public static String convertTripType(TripType tripType) {
|
|
224
213
|
switch (tripType) {
|
|
225
214
|
case ANY:
|
package/android/src/main/java/com/sentiance/react/bridge/core/common/SentianceCommonConverter.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.sentiance.react.bridge.core.common;
|
|
2
|
+
|
|
3
|
+
import android.location.Location;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Arguments;
|
|
6
|
+
import com.facebook.react.bridge.WritableMap;
|
|
7
|
+
|
|
8
|
+
public class SentianceCommonConverter {
|
|
9
|
+
|
|
10
|
+
public static WritableMap convertLocation(Location location) {
|
|
11
|
+
WritableMap locationMap = Arguments.createMap();
|
|
12
|
+
locationMap.putDouble("timestamp", location.getTime());
|
|
13
|
+
locationMap.putDouble("latitude", location.getLatitude());
|
|
14
|
+
locationMap.putDouble("longitude", location.getLongitude());
|
|
15
|
+
if (location.hasAccuracy()) {
|
|
16
|
+
locationMap.putDouble("accuracy", location.getAccuracy());
|
|
17
|
+
}
|
|
18
|
+
if (location.hasAltitude()) {
|
|
19
|
+
locationMap.putDouble("altitude", location.getAltitude());
|
|
20
|
+
}
|
|
21
|
+
locationMap.putString("provider", location.getProvider());
|
|
22
|
+
return locationMap;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
#import "RNSentianceCore+Converter.h"
|
|
10
10
|
@import UIKit.UIApplication;
|
|
11
|
+
@import CoreLocation;
|
|
11
12
|
|
|
12
13
|
@interface RNSentianceCore (Private)
|
|
13
14
|
|
|
14
15
|
- (NSString*)convertTimelineEventTypeToString:(SENTTimelineEventType)type;
|
|
15
16
|
- (NSDictionary*)convertGeolocation:(SENTGeolocation*)location;
|
|
17
|
+
- (NSDictionary*)convertCllocation:(CLLocation*)location;
|
|
16
18
|
- (NSString*)convertVenueSignificance:(SENTVenueSignificance)type;
|
|
17
19
|
- (NSDictionary*)convertVenue:(SENTVenue*)venue;
|
|
18
20
|
- (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event;
|
|
@@ -52,6 +54,22 @@
|
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
- (NSDictionary*)convertCllocation:(CLLocation*)location {
|
|
58
|
+
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
|
59
|
+
dict[@"timestamp"] = @((long) ([location.timestamp timeIntervalSince1970] * 1000));
|
|
60
|
+
dict[@"latitude"] = @(location.coordinate.latitude);
|
|
61
|
+
dict[@"longitude"] = @(location.coordinate.longitude);
|
|
62
|
+
|
|
63
|
+
if (location.horizontalAccuracy >= 0) {
|
|
64
|
+
dict[@"accuracy"] = @(location.horizontalAccuracy);
|
|
65
|
+
}
|
|
66
|
+
if (location.verticalAccuracy > 0) {
|
|
67
|
+
dict[@"altitude"] = @(location.altitude);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return dict;
|
|
71
|
+
}
|
|
72
|
+
|
|
55
73
|
- (NSString*)convertSemanticTime:(SENTSemanticTime)semanticTime {
|
|
56
74
|
switch (semanticTime) {
|
|
57
75
|
case SENTSemanticTimeMorning:
|
|
@@ -756,6 +774,13 @@
|
|
|
756
774
|
dict[@"speedAtImpact"] = @(crashEvent.speedAtImpact);
|
|
757
775
|
dict[@"deltaV"] = @(crashEvent.deltaV);
|
|
758
776
|
dict[@"confidence"] = @(crashEvent.confidence);
|
|
777
|
+
|
|
778
|
+
NSMutableArray *precedingLocations = [[NSMutableArray alloc] init];
|
|
779
|
+
for (CLLocation* location in crashEvent.precedingLocations) {
|
|
780
|
+
[precedingLocations addObject:[self convertCllocation:location]];
|
|
781
|
+
}
|
|
782
|
+
dict[@"precedingLocations"] = precedingLocations;
|
|
783
|
+
|
|
759
784
|
return [dict copy];
|
|
760
785
|
}
|
|
761
786
|
|
package/lib/index.d.ts
CHANGED
|
@@ -61,10 +61,10 @@ declare module "@sentiance-react-native/core" {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export interface Location {
|
|
64
|
-
latitude:
|
|
65
|
-
longitude:
|
|
66
|
-
accuracy?:
|
|
67
|
-
altitude?:
|
|
64
|
+
latitude: number;
|
|
65
|
+
longitude: number;
|
|
66
|
+
accuracy?: number;
|
|
67
|
+
altitude?: number;
|
|
68
68
|
provider?: string; // Android only
|
|
69
69
|
}
|
|
70
70
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentiance-react-native/core",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "React Native Sentiance core library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"targetSdk": 31,
|
|
30
30
|
"compileSdk": 31,
|
|
31
31
|
"buildTools": "30.0.3",
|
|
32
|
-
"sentiance": "6.2
|
|
32
|
+
"sentiance": "6.2+"
|
|
33
33
|
},
|
|
34
34
|
"ios": {
|
|
35
|
-
"sentiance": "~> 6.2.0
|
|
35
|
+
"sentiance": "~> 6.2.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|