prembly-react-native-kyc 1.0.1 → 1.0.2
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.
|
@@ -113,8 +113,10 @@ const PremblyIdentityWidget = ({ isVisible, widgetKey, widgetId, email = '', pho
|
|
|
113
113
|
const handleMessage = (event) => {
|
|
114
114
|
try {
|
|
115
115
|
const data = JSON.parse(event.nativeEvent.data);
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
// The web widget might send the event name in either `event` or `status` property
|
|
117
|
+
const eventName = data.event || data.status;
|
|
118
|
+
if (eventName) {
|
|
119
|
+
switch (eventName) {
|
|
118
120
|
case 'closed':
|
|
119
121
|
callback({ status: 'closed' });
|
|
120
122
|
break;
|
|
@@ -122,13 +124,20 @@ const PremblyIdentityWidget = ({ isVisible, widgetKey, widgetId, email = '', pho
|
|
|
122
124
|
callback({ status: 'error', message: data.message });
|
|
123
125
|
break;
|
|
124
126
|
case 'verified':
|
|
127
|
+
case 'success':
|
|
125
128
|
callback({ status: 'success', data: data });
|
|
126
129
|
break;
|
|
127
130
|
default:
|
|
128
|
-
console.warn('Received unknown event from WebView:',
|
|
131
|
+
console.warn('Received unknown event from WebView:', eventName);
|
|
132
|
+
// Forward unknown events to the callback so the developer can see them
|
|
133
|
+
callback({ status: eventName, data: data });
|
|
129
134
|
break;
|
|
130
135
|
}
|
|
131
136
|
}
|
|
137
|
+
else {
|
|
138
|
+
// Fallback: just send the raw data back to the callback
|
|
139
|
+
callback({ status: 'unknown_payload', data: data });
|
|
140
|
+
}
|
|
132
141
|
}
|
|
133
142
|
catch (e) {
|
|
134
143
|
console.error('Error decoding JSON from WebView:', e);
|