@sentiance-react-native/core 6.1.2 → 6.2.0-rc.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/ios/RNSentianceCore+Converter.m +93 -48
- package/ios/RNSentianceCore.m +0 -1
- package/lib/index.d.ts +14 -8
- package/package.json +1 -1
|
@@ -14,9 +14,7 @@
|
|
|
14
14
|
- (NSString*)convertTimelineEventTypeToString:(SENTTimelineEventType)type;
|
|
15
15
|
- (NSDictionary*)convertGeolocation:(SENTGeolocation*)location;
|
|
16
16
|
- (NSString*)convertVenueSignificance:(SENTVenueSignificance)type;
|
|
17
|
-
- (NSDictionary*)convertVisit:(SENTVisit*)visit;
|
|
18
17
|
- (NSDictionary*)convertVenue:(SENTVenue*)venue;
|
|
19
|
-
- (NSDictionary*)convertVenueCandidate:(SENTVenueCandidate*)candidate;
|
|
20
18
|
- (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event;
|
|
21
19
|
- (NSString*)convertTransportModeToString:(SENTTimelineTransportMode) mode;
|
|
22
20
|
- (void)addTransportEventInfoToDict:(NSMutableDictionary*)dict event:(SENTTransportEvent*)event;
|
|
@@ -68,62 +66,87 @@
|
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
- (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
- (NSString*)convertVenueType:(SENTVenueType)type {
|
|
70
|
+
switch (type) {
|
|
71
|
+
case SENTVenueTypeDrinkDay:
|
|
72
|
+
return @"DRINK_DAY";
|
|
73
|
+
case SENTVenueTypeDrinkEvening:
|
|
74
|
+
return @"DRINK_EVENING";
|
|
75
|
+
case SENTVenueTypeEducationIndependent:
|
|
76
|
+
return @"EDUCATION_INDEPENDENT";
|
|
77
|
+
case SENTVenueTypeEducationParents:
|
|
78
|
+
return @"EDUCATION_PARENTS";
|
|
79
|
+
case SENTVenueTypeHealth:
|
|
80
|
+
return @"HEALTH";
|
|
81
|
+
case SENTVenueTypeIndustrial:
|
|
82
|
+
return @"INDUSTRIAL";
|
|
83
|
+
case SENTVenueTypeLeisureBeach:
|
|
84
|
+
return @"LEISURE_BEACH";
|
|
85
|
+
case SENTVenueTypeLeisureDay:
|
|
86
|
+
return @"LEISURE_DAY";
|
|
87
|
+
case SENTVenueTypeLeisureEvening:
|
|
88
|
+
return @"LEISURE_EVENING";
|
|
89
|
+
case SENTVenueTypeLeisureMuseum:
|
|
90
|
+
return @"LEISURE_MUSEUM";
|
|
91
|
+
case SENTVenueTypeLeisureNature:
|
|
92
|
+
return @"LEISURE_NATURE";
|
|
93
|
+
case SENTVenueTypeLeisurePark:
|
|
94
|
+
return @"LEISURE_PARK";
|
|
95
|
+
case SENTVenueTypeOffice:
|
|
96
|
+
return @"OFFICE";
|
|
97
|
+
case SENTVenueTypeReligion:
|
|
98
|
+
return @"RELIGION";
|
|
99
|
+
case SENTVenueTypeResidential:
|
|
100
|
+
return @"RESIDENTIAL";
|
|
101
|
+
case SENTVenueTypeRestoMid:
|
|
102
|
+
return @"RESTO_MID";
|
|
103
|
+
case SENTVenueTypeRestoShort:
|
|
104
|
+
return @"RESTO_SHORT";
|
|
105
|
+
case SENTVenueTypeShopLong:
|
|
106
|
+
return @"SHOP_LONG";
|
|
107
|
+
case SENTVenueTypeShopShort:
|
|
108
|
+
return @"SHOP_SHORT";
|
|
109
|
+
case SENTVenueTypeSport:
|
|
110
|
+
return @"SPORT";
|
|
111
|
+
case SENTVenueTypeSportAttend:
|
|
112
|
+
return @"SPORT_ATTEND";
|
|
113
|
+
case SENTVenueTypeTravelBus:
|
|
114
|
+
return @"TRAVEL_BUS";
|
|
115
|
+
case SENTVenueTypeTravelConference:
|
|
116
|
+
return @"TRAVEL_CONFERENCE";
|
|
117
|
+
case SENTVenueTypeTravelFill:
|
|
118
|
+
return @"TRAVEL_FILL";
|
|
119
|
+
case SENTVenueTypeTravelHotel:
|
|
120
|
+
return @"TRAVEL_HOTEL";
|
|
121
|
+
case SENTVenueTypeTravelLong:
|
|
122
|
+
return @"TRAVEL_LONG";
|
|
123
|
+
case SENTVenueTypeTravelShort:
|
|
124
|
+
return @"TRAVEL_SHORT";
|
|
125
|
+
case SENTVenueTypeUnknown:
|
|
126
|
+
default:
|
|
127
|
+
return @"UNKNOWN";
|
|
128
|
+
}
|
|
79
129
|
}
|
|
80
130
|
|
|
81
131
|
- (NSDictionary*)convertVenue:(SENTVenue*)venue {
|
|
82
132
|
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
|
83
133
|
|
|
84
|
-
if (venue.name != nil) {
|
|
85
|
-
dict[@"name"] = venue.name;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
134
|
if (venue.location != nil) {
|
|
89
135
|
dict[@"location"] = [self convertGeolocation:venue.location];
|
|
90
136
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
[venue.
|
|
94
|
-
^(NSString * _Nonnull key, NSString * _Nonnull obj, BOOL * _Nonnull stop) {
|
|
95
|
-
labels[key] = obj;
|
|
96
|
-
}];
|
|
97
|
-
dict[@"venueLabels"] = labels;
|
|
137
|
+
|
|
138
|
+
dict[@"significance"] = [self convertVenueSignificance:venue.significance];
|
|
139
|
+
dict[@"type"] = [self convertVenueType:venue.type];
|
|
98
140
|
|
|
99
141
|
return dict;
|
|
100
142
|
}
|
|
101
143
|
|
|
102
|
-
- (NSDictionary*)convertVenueCandidate:(SENTVenueCandidate*)candidate {
|
|
103
|
-
NSMutableArray* visits = [[NSMutableArray alloc] init];
|
|
104
|
-
for (SENTVisit* visit in candidate.visits) {
|
|
105
|
-
[visits addObject:[self convertVisit:visit]];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return @{
|
|
109
|
-
@"venue": [self convertVenue:candidate.venue],
|
|
110
|
-
@"likelihood": @(candidate.likelihood),
|
|
111
|
-
@"visits": visits
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
144
|
- (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event {
|
|
116
145
|
if (event.location != nil) {
|
|
117
146
|
dict[@"location"] = [self convertGeolocation:event.location];
|
|
118
147
|
}
|
|
119
148
|
|
|
120
|
-
dict[@"
|
|
121
|
-
|
|
122
|
-
NSMutableArray* venueCandidates = [[NSMutableArray alloc] init];
|
|
123
|
-
for (SENTVenueCandidate* candidate in event.venueCandidates) {
|
|
124
|
-
[venueCandidates addObject:[self convertVenueCandidate:candidate]];
|
|
125
|
-
}
|
|
126
|
-
dict[@"venueCandidates"] = venueCandidates;
|
|
149
|
+
dict[@"venue"] = [self convertVenue:event.venue];
|
|
127
150
|
}
|
|
128
151
|
|
|
129
152
|
- (NSString*)convertTransportModeToString:(SENTTimelineTransportMode)mode {
|
|
@@ -152,13 +175,37 @@
|
|
|
152
175
|
|
|
153
176
|
- (void)addTransportEventInfoToDict:(NSMutableDictionary*)dict event:(SENTTransportEvent*)event {
|
|
154
177
|
dict[@"transportMode"] = [self convertTransportModeToString:event.transportMode];
|
|
178
|
+
dict[@"waypoints"] = [self convertWaypointArray:event.waypoints];
|
|
179
|
+
|
|
180
|
+
if (event.distanceInMeters != nil) {
|
|
181
|
+
dict[@"distance"] = event.distanceInMeters;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
- (NSDictionary*)convertWaypoint:(SENTWaypoint*)waypoint {
|
|
186
|
+
return @{
|
|
187
|
+
@"latitude": @(waypoint.latitude),
|
|
188
|
+
@"longitude": @(waypoint.longitude),
|
|
189
|
+
@"accuracy": @(waypoint.accuracyInMeters),
|
|
190
|
+
@"timestamp": @(waypoint.timestamp * 1000)
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
- (NSArray<NSDictionary *> *)convertWaypointArray:(NSArray<SENTWaypoint *> *)waypoints {
|
|
195
|
+
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
196
|
+
for (SENTWaypoint *waypoint in waypoints) {
|
|
197
|
+
[array addObject:[self convertWaypoint:waypoint]];
|
|
198
|
+
}
|
|
199
|
+
return array;
|
|
155
200
|
}
|
|
156
201
|
|
|
157
202
|
- (NSMutableDictionary*)convertEvent:(SENTTimelineEvent*)event {
|
|
158
203
|
NSMutableDictionary *eventDict = [[NSMutableDictionary alloc] init];
|
|
159
204
|
eventDict[@"startTime"] = [event.startDate description];
|
|
205
|
+
eventDict[@"startTimeEpoch"] = @((long) (event.startDate.timeIntervalSince1970 * 1000));
|
|
160
206
|
if (event.endDate != nil) {
|
|
161
207
|
eventDict[@"endTime"] = [event.endDate description];
|
|
208
|
+
eventDict[@"endTimeEpoch"] = @((long) (event.endDate.timeIntervalSince1970 * 1000));
|
|
162
209
|
|
|
163
210
|
NSInteger durationInSeconds = event.durationInSeconds;
|
|
164
211
|
if (durationInSeconds != SENTDurationUnknown) {
|
|
@@ -436,11 +483,11 @@
|
|
|
436
483
|
dict[@"type"] = type;
|
|
437
484
|
dict[@"id"] = @(segment.uniqueId);
|
|
438
485
|
dict[@"startTime"] = [segment.startDate description];
|
|
439
|
-
dict[@"startTimeEpoch"] =
|
|
440
|
-
|
|
486
|
+
dict[@"startTimeEpoch"] = @((long) (segment.startDate.timeIntervalSince1970 * 1000));
|
|
487
|
+
|
|
441
488
|
if (segment.endDate != nil) {
|
|
442
489
|
dict[@"endTime"] = [segment.endDate description];
|
|
443
|
-
dict[@"endTimeEpoch"] =
|
|
490
|
+
dict[@"endTimeEpoch"] = @((long) (segment.endDate.timeIntervalSince1970 * 1000));
|
|
444
491
|
}
|
|
445
492
|
dict[@"attributes"] = [self convertSegmentAttributesToDict:segment.attributes];
|
|
446
493
|
|
|
@@ -489,10 +536,6 @@
|
|
|
489
536
|
[criteria addObject:@"CURRENT_EVENT"];
|
|
490
537
|
}
|
|
491
538
|
|
|
492
|
-
if (criteriaMask & SENTUserContextUpdateCriteriaActiveMoments) {
|
|
493
|
-
[criteria addObject:@"ACTIVE_MOMENTS"];
|
|
494
|
-
}
|
|
495
|
-
|
|
496
539
|
if (criteriaMask & SENTUserContextUpdateCriteriaVisitedVenues) {
|
|
497
540
|
[criteria addObject:@"VISITED_VENUES"];
|
|
498
541
|
}
|
|
@@ -572,6 +615,8 @@
|
|
|
572
615
|
@"mobileQuotaStatus":[self convertQuotaStatusToString:status.mobileQuotaStatus],
|
|
573
616
|
@"diskQuotaStatus":[self convertQuotaStatusToString:status.diskQuotaStatus],
|
|
574
617
|
@"userExists":@(status.userExists),
|
|
618
|
+
@"isBatterySavingEnabled":@(status.isDeviceLowPowerModeEnabled),
|
|
619
|
+
@"isActivityRecognitionPermGranted":@(status.isMotionActivityPermissionGranted),
|
|
575
620
|
@"backgroundRefreshStatus":[self convertBackgroundRefreshStatus:status.backgroundRefreshStatus]
|
|
576
621
|
};
|
|
577
622
|
|
package/ios/RNSentianceCore.m
CHANGED
|
@@ -828,7 +828,6 @@ RCT_EXPORT_METHOD(listenUserContextUpdates:(RCTPromiseResolveBlock)resolve rejec
|
|
|
828
828
|
[Sentiance sharedInstance].userContextDelegate = self;
|
|
829
829
|
[Sentiance sharedInstance].criteriaMaskForUserContextUpdates = SENTUserContextUpdateCriteriaCurrentEvent |
|
|
830
830
|
SENTUserContextUpdateCriteriaActiveSegments |
|
|
831
|
-
SENTUserContextUpdateCriteriaActiveMoments |
|
|
832
831
|
SENTUserContextUpdateCriteriaVisitedVenues;
|
|
833
832
|
resolve(nil);
|
|
834
833
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -9,13 +9,17 @@ declare module "@sentiance-react-native/core" {
|
|
|
9
9
|
export type LocationPermission = "ALWAYS" | "ONLY_WHILE_IN_USE" | "NEVER";
|
|
10
10
|
export type BackgroundRefreshStatus = "AVAILABLE" | "DENIED" | "RESTRICTED";
|
|
11
11
|
export type SdkInitState =
|
|
12
|
-
"NOT_INITIALIZED"
|
|
12
|
+
| "NOT_INITIALIZED"
|
|
13
13
|
| "INIT_IN_PROGRESS"
|
|
14
14
|
| "INITIALIZED"
|
|
15
15
|
| "RESETTING"
|
|
16
16
|
| "UNRECOGNIZED_STATE";
|
|
17
17
|
export type TripType = "TRIP_TYPE_SDK" | "TRIP_TYPE_EXTERNAL";
|
|
18
|
-
export type TransmittableDataType =
|
|
18
|
+
export type TransmittableDataType =
|
|
19
|
+
| "ALL"
|
|
20
|
+
| "SDK_INFO"
|
|
21
|
+
| "VEHICLE_CRASH_INFO"
|
|
22
|
+
| "GENERAL_DETECTIONS";
|
|
19
23
|
|
|
20
24
|
export enum TransportMode {
|
|
21
25
|
UNKNOWN = 1,
|
|
@@ -46,8 +50,8 @@ declare module "@sentiance-react-native/core" {
|
|
|
46
50
|
userInfo: UserInfo;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
export type Linker = (installId: string) => Promise<boolean
|
|
50
|
-
|
|
53
|
+
export type Linker = (installId: string) => Promise<boolean>;
|
|
54
|
+
|
|
51
55
|
export interface UserCreationOptions {
|
|
52
56
|
appId?: string;
|
|
53
57
|
appSecret?: string;
|
|
@@ -112,16 +116,16 @@ declare module "@sentiance-react-native/core" {
|
|
|
112
116
|
diskQuotaStatus: string;
|
|
113
117
|
locationPermission: LocationPermission;
|
|
114
118
|
userExists: boolean;
|
|
119
|
+
isBatterySavingEnabled?: boolean;
|
|
120
|
+
isActivityRecognitionPermGranted?: boolean;
|
|
121
|
+
isPreciseLocationAuthorizationGranted: boolean;
|
|
115
122
|
isBgAccessPermGranted?: boolean; // iOS only
|
|
116
|
-
isActivityRecognitionPermGranted?: boolean; // Android only
|
|
117
123
|
locationSetting?: string; // Android only
|
|
118
124
|
isAirplaneModeEnabled?: boolean; // Android only
|
|
119
125
|
isLocationAvailable?: boolean; // Android only
|
|
120
126
|
isGooglePlayServicesMissing?: boolean; // Android only
|
|
121
127
|
isBatteryOptimizationEnabled?: boolean; // Android only
|
|
122
|
-
isBatterySavingEnabled?: boolean; // Android only
|
|
123
128
|
isBackgroundProcessingRestricted?: boolean; // Android only
|
|
124
|
-
isPreciseLocationAuthorizationGranted: boolean;
|
|
125
129
|
isSchedulingExactAlarmsPermitted?: boolean; // Android only
|
|
126
130
|
backgroundRefreshStatus: BackgroundRefreshStatus; // iOS only
|
|
127
131
|
}
|
|
@@ -226,7 +230,9 @@ declare module "@sentiance-react-native/core" {
|
|
|
226
230
|
onUserActivityUpdated: (userActivity: UserActivity) => void
|
|
227
231
|
): Promise<EmitterSubscription>;
|
|
228
232
|
|
|
229
|
-
setTransmittableDataTypes(
|
|
233
|
+
setTransmittableDataTypes(
|
|
234
|
+
types: Array<TransmittableDataType>
|
|
235
|
+
): Promise<void>;
|
|
230
236
|
|
|
231
237
|
getTransmittableDataTypes(): Promise<Array<TransmittableDataType>>;
|
|
232
238
|
}
|