@sentiance-react-native/core 6.21.0 → 6.22.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/RNSentianceCore.podspec
CHANGED
|
@@ -11,6 +11,7 @@ import SENTSDK
|
|
|
11
11
|
open class AbstractSentianceModule: RCTEventEmitter {
|
|
12
12
|
|
|
13
13
|
public let sentiance: Sentiance
|
|
14
|
+
public var hasListeners: Bool = false
|
|
14
15
|
|
|
15
16
|
override convenience init() {
|
|
16
17
|
self.init(sentiance: Sentiance.shared)
|
|
@@ -20,6 +21,20 @@ open class AbstractSentianceModule: RCTEventEmitter {
|
|
|
20
21
|
self.sentiance = sentiance
|
|
21
22
|
super.init()
|
|
22
23
|
}
|
|
24
|
+
|
|
25
|
+
open override func startObserving() {
|
|
26
|
+
hasListeners = true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
open override func stopObserving() {
|
|
30
|
+
hasListeners = false
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
open override func sendEvent(withName name: String!, body: Any!) {
|
|
34
|
+
if (hasListeners) {
|
|
35
|
+
super.sendEvent(withName: name, body: body)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
|
|
24
39
|
@objc
|
|
25
40
|
func addNativeListener() {
|
package/ios/RNSentianceCore.m
CHANGED
|
@@ -59,8 +59,14 @@ RCT_EXPORT_MODULE(SentianceCore)
|
|
|
59
59
|
return NO;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
- (void)sendEventWithName:(NSString *)name body:(id)body {
|
|
63
|
+
if (self.hasListeners) {
|
|
64
|
+
[super sendEventWithName:name body:body];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
62
68
|
- (void)onDrivingInsightsReadyWithInsights:(SENTDrivingInsights *)insights {
|
|
63
|
-
|
|
69
|
+
[self sendEventWithName:DrivingInsightsReadyEvent body:[self convertDrivingInsights:insights]];
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
- (void)onEventTimelineUpdateWithEvent:(SENTTimelineEvent * _Nonnull)event {
|
|
@@ -68,19 +74,19 @@ RCT_EXPORT_MODULE(SentianceCore)
|
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
- (void)onProvisionalAwareEventTimelineUpdateWithEvent:(SENTTimelineEvent * _Nonnull)event {
|
|
71
|
-
|
|
77
|
+
[self sendEventWithName:TimelineUpdateEvent body:[self convertEvent:event]];
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
- (void)onSmartGeofenceEvent:(SENTSmartGeofenceEvent * _Nonnull)smartGeofenceEvent {
|
|
75
|
-
|
|
81
|
+
[self sendEventWithName:SmartGeofenceEvent body:[self convertSmartGeofenceEvent:smartGeofenceEvent]];
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
- (void)didUpdateProvisionalAwareUserContext:(SENTUserContext *)userContext forCriteriaMask:(SENTUserContextUpdateCriteria)criteriaMask {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
NSDictionary *dict = @{
|
|
86
|
+
@"userContext": [self convertUserContextToDict:userContext],
|
|
87
|
+
@"criteria": [self convertUserContextCriteriaToArray:criteriaMask]
|
|
88
|
+
};
|
|
89
|
+
[self sendEventWithName:UserContextUpdateEvent body:dict];
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
- (void)didUpdateUserContext:(SENTUserContext *)userContext
|
|
@@ -214,20 +220,20 @@ RCT_EXPORT_MODULE(SentianceCore)
|
|
|
214
220
|
}
|
|
215
221
|
|
|
216
222
|
- (SENTUserLinker) getUserLinker {
|
|
217
|
-
|
|
218
|
-
return self.userLinker;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
__weak typeof(self) weakSelf = self;
|
|
222
|
-
|
|
223
|
-
self.userLinker = ^(NSString *installId, void (^linkSuccess)(void),
|
|
224
|
-
void (^linkFailed)(void)) {
|
|
225
|
-
weakSelf.userLinkSuccess = linkSuccess;
|
|
226
|
-
weakSelf.userLinkFailed = linkFailed;
|
|
227
|
-
[weakSelf sendEventWithName:UserLinkEvent body:[weakSelf convertInstallIdToDict:installId]];
|
|
228
|
-
};
|
|
229
|
-
|
|
223
|
+
if (self.userLinker != nil) {
|
|
230
224
|
return self.userLinker;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
__weak typeof(self) weakSelf = self;
|
|
228
|
+
|
|
229
|
+
self.userLinker = ^(NSString *installId, void (^linkSuccess)(void),
|
|
230
|
+
void (^linkFailed)(void)) {
|
|
231
|
+
weakSelf.userLinkSuccess = linkSuccess;
|
|
232
|
+
weakSelf.userLinkFailed = linkFailed;
|
|
233
|
+
[weakSelf sendEventWithName:UserLinkEvent body:[weakSelf convertInstallIdToDict:installId]];
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
return self.userLinker;
|
|
231
237
|
}
|
|
232
238
|
|
|
233
239
|
|
|
@@ -237,9 +243,7 @@ RCT_EXPORT_MODULE(SentianceCore)
|
|
|
237
243
|
__weak typeof(self) weakSelf = self;
|
|
238
244
|
|
|
239
245
|
[self setSdkStatusHandler:^(SENTSDKStatus *status) {
|
|
240
|
-
|
|
241
|
-
[weakSelf sendEventWithName:SdkStatusUpdateEvent body:[weakSelf convertSdkStatusToDict:status]];
|
|
242
|
-
}
|
|
246
|
+
[weakSelf sendEventWithName:SdkStatusUpdateEvent body:[weakSelf convertSdkStatusToDict:status]];
|
|
243
247
|
}];
|
|
244
248
|
return self.sdkStatusHandler;
|
|
245
249
|
}
|
|
@@ -771,20 +775,18 @@ RCT_EXPORT_METHOD(deleteKeychainEntries:(RCTPromiseResolveBlock)resolve rejecter
|
|
|
771
775
|
|
|
772
776
|
RCT_EXPORT_METHOD(listenUserActivityUpdates:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
773
777
|
{
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
reject(e.name, e.reason, nil);
|
|
787
|
-
}
|
|
778
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
779
|
+
|
|
780
|
+
@try {
|
|
781
|
+
__weak typeof(self) weakSelf = self;
|
|
782
|
+
[[Sentiance sharedInstance] setUserActivityListener:^(SENTUserActivity *userActivity) {
|
|
783
|
+
NSDictionary *userActivityDict = [self convertUserActivityToDict:userActivity];
|
|
784
|
+
[weakSelf sendEventWithName:UserActivityUpdateEvent body:userActivityDict];
|
|
785
|
+
}];
|
|
786
|
+
resolve(nil);
|
|
787
|
+
} @catch (NSException *e) {
|
|
788
|
+
reject(e.name, e.reason, nil);
|
|
789
|
+
}
|
|
788
790
|
}
|
|
789
791
|
|
|
790
792
|
RCT_EXPORT_METHOD(getUserActivity:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
@@ -824,10 +826,8 @@ RCT_EXPORT_METHOD(listenVehicleCrashEvents:(RCTPromiseResolveBlock)resolve rejec
|
|
|
824
826
|
__weak typeof(self) weakSelf = self;
|
|
825
827
|
|
|
826
828
|
[[Sentiance sharedInstance] setVehicleCrashHandler:^(SENTVehicleCrashEvent *crashEvent) {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
[weakSelf sendEventWithName:VehicleCrashEvent body:crashEventDict];
|
|
830
|
-
}
|
|
829
|
+
NSDictionary *crashEventDict = [self convertVehicleCrashEventToDict:crashEvent];
|
|
830
|
+
[weakSelf sendEventWithName:VehicleCrashEvent body:crashEventDict];
|
|
831
831
|
}];
|
|
832
832
|
resolve(@(YES));
|
|
833
833
|
} @catch (NSException *e) {
|
|
@@ -837,21 +837,19 @@ RCT_EXPORT_METHOD(listenVehicleCrashEvents:(RCTPromiseResolveBlock)resolve rejec
|
|
|
837
837
|
|
|
838
838
|
RCT_EXPORT_METHOD(listenVehicleCrashDiagnostic:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
839
839
|
{
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
reject(e.name, e.reason, nil);
|
|
854
|
-
}
|
|
840
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
841
|
+
|
|
842
|
+
@try {
|
|
843
|
+
__weak typeof(self) weakSelf = self;
|
|
844
|
+
|
|
845
|
+
[[Sentiance sharedInstance] setVehicleCrashDiagnosticHandler:^(SENTVehicleCrashDiagnostic *crashDiagnostic) {
|
|
846
|
+
NSDictionary *crashDiagnosticEventDict = [self convertVehicleCrashDiagnosticToDict:crashDiagnostic];
|
|
847
|
+
[weakSelf sendEventWithName:VehicleCrashDiagnosticEvent body:crashDiagnosticEventDict];
|
|
848
|
+
}];
|
|
849
|
+
resolve(@(YES));
|
|
850
|
+
} @catch (NSException *e) {
|
|
851
|
+
reject(e.name, e.reason, nil);
|
|
852
|
+
}
|
|
855
853
|
}
|
|
856
854
|
|
|
857
855
|
RCT_EXPORT_METHOD(isThirdPartyLinked:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
@@ -1031,9 +1029,7 @@ RCT_EXPORT_METHOD(listenTripTimeout:(RCTPromiseResolveBlock)resolve rejecter:(RC
|
|
|
1031
1029
|
{
|
|
1032
1030
|
__weak typeof(self) weakSelf = self;
|
|
1033
1031
|
[[Sentiance sharedInstance] setTripTimeoutListener:^ {
|
|
1034
|
-
|
|
1035
|
-
[weakSelf sendEventWithName:TripTimeoutEvent body:nil];
|
|
1036
|
-
}
|
|
1032
|
+
[weakSelf sendEventWithName:TripTimeoutEvent body:nil];
|
|
1037
1033
|
}];
|
|
1038
1034
|
resolve(nil);
|
|
1039
1035
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentiance-react-native/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.22.0-rc.1",
|
|
4
4
|
"description": "The Sentiance Core library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"targetSdk": 34,
|
|
24
24
|
"compileSdk": 34,
|
|
25
25
|
"buildTools": "34.0.0",
|
|
26
|
-
"sentiance": "6.
|
|
26
|
+
"sentiance": "6.22.0-rc1"
|
|
27
27
|
},
|
|
28
28
|
"ios": {
|
|
29
|
-
"sentiance": "
|
|
29
|
+
"sentiance": "6.22.0-rc1"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|