Base64 encoding in JSContext

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?

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.

Base64 encoding in JSContext
 
 
Q