Skip to content

Commit 6cac60f

Browse files
committed
fix(webview): Fix emitting events without payload on iOS
1 parent 23816ee commit 6cac60f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/webview/index.ios.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,13 @@ export class WKScriptMessageHandlerNotaImpl extends NSObject implements WKScript
758758

759759
try {
760760
const message = JSON.parse(webViewMessage.body as string);
761-
owner.onWebViewEvent(message.eventName, JSON.parse(message.data));
761+
762+
try {
763+
owner.onWebViewEvent(message.eventName, JSON.parse(message.data));
764+
} catch (err) {
765+
owner.writeTrace(`userContentControllerDidReceiveScriptMessage(${userContentController}, ${webViewMessage}) - couldn't parse data: ${message.data}`, Trace.messageType.error);
766+
owner.onWebViewEvent(message.eventName, message.data);
767+
}
762768
} catch (err) {
763769
owner.writeTrace(`userContentControllerDidReceiveScriptMessage(${userContentController}, ${webViewMessage}) - bad message: ${webViewMessage.body}`, Trace.messageType.error);
764770
}

0 commit comments

Comments
 (0)