Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I can run this library in my react native project. I need to create a mobile app #30

Open
yogeshwar-matchps opened this issue Mar 28, 2023 · 6 comments

Comments

@yogeshwar-matchps
Copy link

No description provided.

@freeboub
Copy link

I tried to port it to react native, but it is not so easy ...

@yogeshwar-matchps
Copy link
Author

Any alternative code reference or full source code of Android app @freeboub

@freeboub
Copy link

Unfortunately it was not successful, but I can share the code 'as is' (if I still have it).
We found issue with this repo depending of the android tv device used, that's another reason why we stopped working on it...

@yogeshwar-matchps
Copy link
Author

@louis49 Can you provide Android & iOS Code in Java and Swift for TV Remote

@vricosti
Copy link

vricosti commented May 13, 2024

Same problem here when I add androidtv-remote to a react native/typescript project I get an error about the crypto depdencies:

error: Error: Unable to resolve module crypto from /home/vricosti/Dev/lota-remotectl/lota-remotectl-app/node_modules/androidtv-remote/dist/certificate/CertificateGenerator.js: crypto could not be found within the project or in these directories:
  node_modules
  ../../node_modules
  10 | var _nodeForge = _interopRequireDefault(require("node-forge"));
  11 |
> 12 | var _crypto = _interopRequireDefault(require("crypto"));
     |                                               ^
  13 |
  14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15 |
    at ModuleResolver.resolveDependency (/home/vricosti/Dev/lota-remotectl/lota-remotectl-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:138:15)
    at DependencyGraph.resolveDependency (/home/vricosti/Dev/lota-remotectl/lota-remotectl-app/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
    at /home/vricosti/Dev/lota-remotectl/lota-remotectl-app/node_modules/metro/src/lib/transformHelpers.js:156:21
    at resolveDependencies (/home/vricosti/Dev/lota-remotectl/lota-remotectl-app/node_modules/metro/src/DeltaBundler/buildSubgraph.js:42:25)
    at visit (/home/vricosti/Dev/lota-remotectl/lota-remotectl-app/node_modules/metro/src/DeltaBundler/buildSubgraph.js:83:30)
    at async Promise.all (index 1)
    at async visit (/home/vricosti/Dev/lota-remotectl/lota-remotectl-app/node_modules/metro/src/DeltaBundler/buildSubgraph.js:92:5)
    at async Promise.all (index 0)
    at async visit (/home/vricosti/Dev/lota-remotectl/lota-remotectl-app/node_modules/metro/src/DeltaBundler/buildSubgraph.js:92:5)
    at async Promise.all (index 0)
 ERROR  [Error: undefined Unable to resolve module crypto from /home/vricosti/Dev/lota-remotectl/lota-remotectl-app/node_modules/androidtv-remote/dist/certificate/CertificateGenerator.js: crypto could not be found within the project or in these directories:
  node_modules
  ../../node_modules
  10 | var _nodeForge = _interopRequireDefault(require("node-forge"));
  11 |
> 12 | var _crypto = _interopRequireDefault(require("crypto"));
     |                                               ^
  13 |
  14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15 |]

It would be great to fix it inside this project because other solutions implies to play with react-native-quick-crypto or crypto-browserify or rn-nodeify and it's a bit clumsy.

Update: I followed the crypto-browserify path since I don't need crypto performance:

yarn add crypto-browserify
yarn add react-native-tcp-socket
yarn add react-native-url-polyfill
yarn add path-browserify
yarn --dev add babel-plugin-rewrite-require

Inside babel.config.js:

module.exports = {
  presets: [
    'module:@react-native/babel-preset'
  ],
  plugins: [
    ['babel-plugin-rewrite-require', {
      "aliases": {
        "crypto": "crypto-browserify",
        "tls": "react-native-tcp-socket",
        "url": "react-native-url-polyfill",
        "path": "path-browserify"
      }
    }],
    // from doc: react-native-reanimated/plugin has to be listed last.
    'react-native-reanimated/plugin',
  ],
};

The last error is about missing systeminformation on react ,native and for this one, I think it would be better to fix directly the source code instead of provinding a ugly hack. Don't even know if this project is still maintained...

@vricosti
Copy link

vricosti commented May 14, 2024

Here is my progress: digitalbazaar/forge#1079

Actually I have removed dependecies on specific node modules (crypto, fs path, systeminfomation) https://github.com/vricosti/androidtv-remote/tree/dev/simplify-deps at the end I have a freeze as soon as I instantiate AndroidRemote...

I have progressed and finally I think the last part is to manage to replace tls module:
https://github.com/vricosti/TestAndroidTVRemoteApp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants