AppleTV - tvos - Hybrid app using native and TVMLKIT - Can't back to native app
<p>I'm a beginner on TVOS.</p>

<p>I'd like to create an hybrid app on AppleTV using a native app and TVMLKIT.
My native application is just a simple native app with buttons (using swift).</p>

<p>When we click on a button, I launch a a javascript app using TVLMKIT and TVJS.</p>

<p>My TVJS as uses the Player to display a video.
When the video is over, I want to close the TVJS app and back to the native ViewController.</p>

<p>My problem is that when I back to native app, I loose the focus on my native View (the app is frozen).</p>

<p>native ViewController:</p>

<pre><code>import UIKit
import TVMLKit

class ViewController: UIViewController, TVApplicationControllerDelegate {

var window: UIWindow?
var appController: TVApplicationController?
var appControllerContext = TVApplicationControllerContext();
static let TVBaseURL = "http://localhost:9001/"
static let TVBootURL = "\(ViewController.TVBaseURL)/client/js/application.js"

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

@IBOutlet weak var label: UILabel!

@IBOutlet weak var viewAd: UIView!

@IBAction func clickOnlaunchAd(sender: AnyObject) {
    window = UIWindow(frame: UIScreen.mainScreen().bounds)

    guard let javaScriptURL = NSURL(string: ViewController.TVBootURL) else {
        fatalError("unable to create NSURL")
    }
    appControllerContext.javaScriptApplicationURL = javaScriptURL
    appControllerContext.launchOptions["BASEURL"] = ViewController.TVBaseURL

    appController = TVApplicationController(context: appControllerContext, window: window,delegate: self)

}
@IBAction func clickOnChangeText(sender: AnyObject) {
    label.text = "changed";
}

func appController(appController: TVApplicationController, didStopWithOptions options: [String : AnyObject]?) {
   self.setNeedsFocusUpdate()
   self.updateFocusIfNeeded()
}

func appController(appController: TVApplicationController, evaluateAppJavaScriptInContext jsContext: JSContext){
    let notifyEventToNative : @convention(block) (NSString!) -&gt; Void = {
        (string : NSString!) -&gt; Void in
            print("[log]: \(string)\n")
            self.appController?.stop()
    }
    jsContext.setObject(unsafeBitCast(notifyEventToNative, AnyObject.self), forKeyedSubscript: "notifyEventToNative")
}
}
</code></pre>

<p>Just before calling "notifyEventToNative" from my TVJS, I call "navigationDocument.clear();" to clear the TVML view.</p>

<p>I can see my native app but I can't interact with it.</p>

<p>Any ideas?
Thanks.</p>