The RNTester app supports Apple TV; use the
RNTester-tvOS build target to build for tvOS.
Native layer: React Native Xcode projects all now have Apple TV build targets, with names ending in the string '-tvOS'.
react-native init: New React Native projects created with
react-native init will have Apple TV target automatically created in their XCode projects.
Platform.ios.js. You can check whether code is running on AppleTV by doing
General support for tvOS: Apple TV specific changes in native code are all wrapped by the TARGET_OS_TV define. These include changes to suppress APIs that are not supported on tvOS (e.g. web views, sliders, switches, status bar, etc.), and changes to support user input from the TV remote or keyboard.
Access to touchable controls: When running on Apple TV, the native view class is
RCTTVView, which has additional methods to make use of the tvOS focus engine. The
Touchable mixin has code added to detect focus changes and use existing methods to style the components properly and initiate the proper actions when the view is selected using the TV remote, so
TouchableOpacity will "just work". In particular:
touchableHandleActivePressInwill be executed when the touchable view goes into focus
touchableHandleActivePressOutwill be executed when the touchable view goes out of focus
touchableHandlePresswill be executed when the touchable view is actually selected by pressing the "select" button on the TV remote.
TV remote/keyboard input: A new native class,
RCTTVRemoteHandler, sets up gesture recognizers for TV remote events. When TV remote events occur, this class fires notifications that are picked up by
RCTTVNavigationEventEmitter (a subclass of
RCTEventEmitter), that fires a JS event. This event will be picked up by instances of the
TVEventHandler and listen for these events, as in the following code:
Dev Menu support: On the simulator, cmd-D will bring up the developer menu, just like on iOS. To bring it up on a real Apple TV device, make a long press on the play/pause button on the remote. (Please do not shake the Apple TV device, that will not work :) )
TV remote animations:
RCTTVView native code implements Apple-recommended parallax animations to help guide the eye as the user navigates through views. The animations can be disabled or adjusted with new optional view properties.
Back navigation with the TV remote menu button: The
BackHandler component, originally written to support the Android back button, now also supports back navigation on the Apple TV using the menu button on the TV remote.
TabBarIOS behavior: The
TabBarIOS component wraps the native
Improve this page by sending a pull request!