@screeb/react-native 2.1.1 → 2.1.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.
|
@@ -51,9 +51,6 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// TODO: pass to pluginInit
|
|
55
|
-
var initOptions = InitOptions()
|
|
56
|
-
|
|
57
54
|
Handler(Looper.getMainLooper()).post {
|
|
58
55
|
Screeb.pluginInit(channelId, userId, map, mapHooks)
|
|
59
56
|
}
|
|
@@ -189,8 +186,11 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
189
186
|
}
|
|
190
187
|
|
|
191
188
|
@ReactMethod
|
|
192
|
-
fun onHookResult(hookId: String,
|
|
193
|
-
|
|
189
|
+
fun onHookResult(hookId: String, payload: ReadableMap?){
|
|
190
|
+
if (payload != null) {
|
|
191
|
+
val result = payload!!.toHashMap()["result"] as Any?
|
|
192
|
+
Screeb.onHookResult(hookId, result)
|
|
193
|
+
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
@ReactMethod
|
package/ios/ScreebModule.m
CHANGED
|
@@ -11,6 +11,7 @@ RCT_EXTERN_METHOD(unassignGroup:(NSString *)type name:(NSString *)name_ properti
|
|
|
11
11
|
RCT_EXTERN_METHOD(trackEvent:(NSString *)eventId properties:(NSDictionary<NSString *, id> *)properties_)
|
|
12
12
|
RCT_EXTERN_METHOD(trackScreen:(NSString *)screen properties:(NSDictionary<NSString *, id> *)properties_)
|
|
13
13
|
RCT_EXTERN_METHOD(startSurvey:(NSString *)surveyId allowMultipleResponses:(BOOL)allowMultipleResponses_ hiddenFields:(NSDictionary<NSString *, id> *)hiddenFields_ ignoreSurveyStatus:(BOOL)ignoreSurveyStatus_ hooks:(NSDictionary<NSString *, id> *)hooks_)
|
|
14
|
+
RCT_EXTERN_METHOD(onHookResult:(NSString *)hookId payload:(NSDictionary<NSString *, id> *)payload_)
|
|
14
15
|
RCT_EXTERN_METHOD(debug)
|
|
15
16
|
RCT_EXTERN_METHOD(debugTargeting)
|
|
16
17
|
RCT_EXTERN_METHOD(closeSdk)
|
package/ios/ScreebModule.swift
CHANGED
|
@@ -137,10 +137,12 @@ class ScreebModule: RCTEventEmitter {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
@objc func onHookResult(_ hookId: String,
|
|
140
|
+
@objc func onHookResult(_ hookId: String, payload: [String: Any]?) {
|
|
141
141
|
DispatchQueue.main.async {
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
if payload != nil {
|
|
143
|
+
let encoded = self.toAnyEncodable(payload["result"]
|
|
144
|
+
Screeb.onHookResult(hookId, encoded)
|
|
145
|
+
}
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -139,16 +139,14 @@ export function closeSurvey() {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
function handleEvent(event: any) {
|
|
142
|
-
console.log(event);
|
|
143
142
|
if (event?.hookId != null) {
|
|
144
143
|
let hook = hooksRegistry.get(event.hookId);
|
|
145
144
|
if (hook != null) {
|
|
146
145
|
const result = hook(event.payload);
|
|
147
|
-
console.log("Hook result: ", result);
|
|
148
|
-
console.log(event.payload);
|
|
149
146
|
const originalHookId = event?.payload?.hook_id;
|
|
150
147
|
if (originalHookId) {
|
|
151
|
-
|
|
148
|
+
// result must be a map to fit with react native allowed types
|
|
149
|
+
ScreebModule.onHookResult(originalHookId, { result });
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
}
|