(Part 3 of 5)
This is the third part of our tvOS tutorial. Please check out the previous Article to know more about this series.
Add the following code to application.js:
TVApplicationController — The TVApplicationController that was initialised in AppDelegate.swift will pass on its TVApplicationControllerContext here.
Later, we’ll make use of context’s contents, but for now, we’re just going to create a simple alert to display on screen, to ensure that your app is running without any errors.
Explanation of the code:
- Using createAlert defined, we get a TVML document for us to present. The navigationDocument is similar to UINavigationController in iOS. It serves as the stack that can push, pop and present TVML documents.
- createAlert is a function that returns a TVML document. It is similar to UIAlertController in iOS.
The createAlert used here is one of the 18 pre-defined templates of Apple’s TVML. Click here to check the remaining templates of TVML. Hurray! Finally, you’re almost ready for your first build and run!
Setting up the Server
Open the terminal tab from your client directory and run the following code:
This starts up a simple Python-based web server in your client directory. Now you’re ready for takeoff!
Go back to your Xcode project and build and run. You should be greeted with your first tvOS TVML app!
I don’t know how you feel now, but when I first got this page my confidence level shot up and I started crying out in joy.