Inspired myself to go search for working examples.
Found a near-working example at Stack Overflow at https://stackoverflow.com/questions/65270083/how-does-the-ios-14-api-wkscriptmessagehandlerwithreply-work-for-communicating-w
Pushed a working SwiftUI version to
https://github.com/vaughey/WithReplySample/tree/main
All the trashing I did with data and object types, Sendable, and MainActor was in vain. Undocumented signature for the javascript call was the culprit.
Topic:
Programming Languages
SubTopic:
Swift
Tags: