I'm working on tvOS app (using TVML) and I'm trying to call a Swift function with completion handler from JS.
In the TVApplicationControllerDelegate I try with code like this:
let getVastData : @convention(block) (String, @escaping (UInt32, [String], String) -> ()) -> Void = {
(url : String, _ completion:@escaping (_ duration: UInt32, _ addLinks: [String], _ videoLink: String) -> ()) -> Void in
VastManager.shared.startParsing(with: url, completion)
}
jsContext.setObject(unsafeBitCast(getVastData, to: AnyObject.self), forKeyedSubscript: "getVastData" as (NSCopying & NSObjectProtocol)!)
but I'm geting error: "TypeError: getVastData is not a function. (In 'getVastData', 'getVastData' is an instance of NSBlock"
Do you know where I'm wrong or how to correct call Swift func with completion handler from JS?
Thanks in advance, Milos