Skip to content

tvOS 9 - Experiments - TVApplicationController Javascript Environment (TVMLKit) - AppleTv.

Notifications You must be signed in to change notification settings

Sweefties/tvOS9-TVMLKitDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tvOS 9 - New OS - TVMLKit tvOS! - Example

tvOS 9~ Experiments - TVApplicationController Javascript Environment - appleTv.

Example

Pictures Source

Licence CCO Public Domain from : Pixabay.com

Requirements

  • = XCode 8.0.

  • = Swift 3.

  • = tvOS 9.0

Tested on tvOS 9.0 Simulator, Apple Tv Developer Kit.

Important

this is the Xcode 8 / Swift updated project.

App Transport Security Settings

To support HTTP hosted : add the Boolean type Value to YES for NSAllowsArbitraryLoads in app's info.plist file.

Client-Server App

Code Example

AppDelegate Class

import TVMLKit

...

// MARK: - Properties
var window: UIWindow?
var appController : TVApplicationController?
static let TVBaseURL = "http://localhost:9001/"
static let TVBootURL = "\(AppDelegate.TVBaseURL)js/main.js"

// MARK: - UIApplication Overrides
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    self.window = UIWindow(frame:UIScreen.mainScreen().bounds)

    /// Create the TVApplicationControllerContext
    let appControllerContext = TVApplicationControllerContext()

    /// Javascript Context for TVMLKit Application
    if let javaScriptURL = NSURL(string: AppDelegate.TVBootURL) {
        appControllerContext.javaScriptApplicationURL = javaScriptURL
    }

    appControllerContext.launchOptions["BASEURL"] = AppDelegate.TVBaseURL

    if let launchOptions = launchOptions as? [String: AnyObject] {
        for (kind, value) in launchOptions {
            appControllerContext.launchOptions[kind] = value
        }
    }

    /// Javascript Environment
    appController = TVApplicationController(context: appControllerContext, window: self.window, delegate: self)

    return true
}

...

Usage

To run the example project, download or clone the repo. Run client-server app with Terminal command :

python -m SimpleHTTPServer 9001

Build and Run tvOS Simulator!

About

tvOS 9 - Experiments - TVApplicationController Javascript Environment (TVMLKit) - AppleTv.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages