You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/building-for-tv.md
+24-14Lines changed: 24 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,18 +5,18 @@ title: Building For TV Devices
5
5
6
6
TV devices support has been implemented with the intention of making existing React Native applications work on Apple TV and Android TV, with few or no changes needed in the JavaScript code for the applications.
> **Deprecated.** Use [react-native-tvos](https://github.com/react-native-community/react-native-tvos) instead. For the details please check the [0.62 release blog post](https://reactnative.dev/blog/#moving-apple-tv-to-react-native-tvos).
22
22
@@ -39,7 +39,7 @@ var running_on_tv = Platform.isTV;
39
39
var running_on_apple_tv =Platform.isTVOS;
40
40
```
41
41
42
-
<blockclass="android" />
42
+
<blockclassName="android" />
43
43
44
44
## Build changes
45
45
@@ -68,11 +68,11 @@ var Platform = require('Platform');
68
68
var running_on_android_tv =Platform.isTV;
69
69
```
70
70
71
-
<blockclass="ios android" />
71
+
<blockclassName="ios android" />
72
72
73
73
## Code changes
74
74
75
-
<blockclass="ios" />
75
+
<blockclassName="ios" />
76
76
77
77
-_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.
78
78
@@ -84,23 +84,23 @@ var running_on_android_tv = Platform.isTV;
84
84
-`onBlur` will be executed when the touchable view goes out of focus
85
85
-`onPress` will be executed when the touchable view is actually selected by pressing the "select" button on the TV remote.
86
86
87
-
<blockclass="android" />
87
+
<blockclassName="android" />
88
88
89
89
-_Access to touchable controls_: When running on Android TV the Android framework will automatically apply a directional navigation scheme based on relative position of focusable elements in your views. 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 `TouchableWithoutFeedback`, `TouchableHighlight`, `TouchableOpacity` and `TouchableNativeFeedback` will work as expected. In particular:
90
90
91
91
-`onFocus` will be executed when the touchable view goes into focus
92
92
-`onBlur` will be executed when the touchable view goes out of focus
93
93
-`onPress` will be executed when the touchable view is actually selected by pressing the "select" button on the TV remote.
94
94
95
-
<blockclass="ios" />
95
+
<blockclassName="ios" />
96
96
97
97
-_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` JavaScript object. Application code that needs to implement custom handling of TV remote events can create an instance of `TVEventHandler` and listen for these events, as in the following code:
98
98
99
-
<blockclass="android"/>
99
+
<blockclassName="android"/>
100
100
101
101
-_TV remote/keyboard input_: A new native class, `ReactAndroidTVRootViewHelper`, sets up key events handlers for TV remote events. When TV remote events occur, this class fires a JS event. This event will be picked up by instances of the `TVEventHandler` JavaScript object. Application code that needs to implement custom handling of TV remote events can create an instance of `TVEventHandler` and listen for these events, as in the following code:
102
102
103
-
<blockclass="ios android"/>
103
+
<blockclassName="ios android"/>
104
104
105
105
```jsx
106
106
var TVEventHandler =require('TVEventHandler');
@@ -141,18 +141,28 @@ class Game2048 extends React.Component {
141
141
}
142
142
```
143
143
144
-
<block class="ios" />
144
+
<block className="ios" />
145
145
146
146
- _Dev Menu support_: On the simulator, cmd-D will bring up the developer menu, similar to 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 :) )
147
147
148
148
- _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.
149
149
150
150
- _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.
151
151
152
-
<block class="android" />
152
+
- _TabBarIOS behavior_: The `TabBarIOS` component wraps the native `UITabBar` API, which works differently on Apple TV. To avoid jittery re-rendering of the tab bar in tvOS (see [this issue](https://github.com/facebook/react-native/issues/15081)), the selected tab bar item can only be set from Javascript on initial render, and is controlled after that by the user through native code.
153
+
154
+
<block className="android" />
153
155
154
156
- _Dev Menu support_: On the simulator, cmd-M will bring up the developer menu, similar to Android. To bring it up on a real Android TV device, press the menu button or long press the fast-forward button on the remote. (Please do not shake the Android TV device, that will not work :) )
155
157
158
+
<block className="ios" />
159
+
160
+
- _Known issues_:
161
+
162
+
- [ListView scrolling](https://github.com/facebook/react-native/issues/12793). The issue can be worked around by setting `removeClippedSubviews` to false in ListView and similar components. For more discussion of this issue, see [this PR](https://github.com/facebook/react-native/pull/12944).
163
+
164
+
<block className="android" />
165
+
156
166
- _Known issues_:
157
167
158
-
- `TextInput` components do not work for now (i.e. they cannot receive focus, see [this comment](https://github.com/facebook/react-native/pull/16500#issuecomment-629285638)).
168
+
- `InputText` components do not work for now (i.e. they cannot receive focus).
0 commit comments