Not hacky way to make RN think it's TV even when it's not (modifying uiMode?)

sdkVersion: ‘42.0.0’
Platforms(Android/iOS/web/all): Android

expo diagnostics

  Expo CLI 4.11.0 environment info:
    System:
      OS: Windows 10 10.0.21390
    Binaries:
      Node: 14.16.1 - C:\Program Files\nodejs\node.EXE
      npm: 6.14.12 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  4.2.0.0 AI-202.7660.26.42.7351085
    npmPackages:
      expo: ~42.0.1 => 42.0.3
      react: 16.13.1 => 16.13.1
      react-dom: 16.13.1 => 16.13.1
      react-native: https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz => 0.63.2
      react-native-web: ~0.13.12 => 0.13.18
    Expo Workflow: managed

Hey guys, so I need my app to run like it’s Android TV on an AOSP Android box. As a POC I tried to change the function in node_modules/react-native/Libraries/Utilities/Platform.android.js from

get isTV(): boolean {
    return this.constants.uiMode === 'tv';
  }

to

  get isTV(): boolean {
    return true;
  },

And it works fine on the box. I would like a less hacky way to do it though. The solution would seem to be able to change uiMode to tv, but I found out it’s not a param you can change in expo’s app.json nor does it look like changeable from the JS code. Is there a way to do it?

Thanks ahead.

Hi @jerrybels

Sorry, I don’t know the actual answer, but perhaps you can use patch-package to make the modification to Platform.android.js more palatable.

2 Likes

Haha yeah that’s what I ended up doing. Thanks :slight_smile:

2 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.