Hello, I'm trying to launch some JS code, and it's using atob function from js. But when I launch code in swift with JSContext, I have an error ReferenceError: Can't find variable: atob.
What can I do to solve this?
Base64 encoding in JSContext
The atob() function is part of the window object in browser JavaScript, but there is no window object when using JSContext directly.
One solution would be to implement the functionality in native code (Swift or Objective-C) and call it from JavaScript. See JSExport (link) and various online tutorials.