[英]How can I open a chrome tab on my laptop from my react-native app (like remote debugging does)?
I am creating a small debugging app to monitor a particular interaction (WebRTC) between two users of my main app.我正在创建一个小型调试应用程序来监视我的主应用程序的两个用户之间的特定交互 (WebRTC)。
I have a web app (React) and a mobile app (React-Native) that each connect through socket.io to a node server I created.我有一个 Web 应用程序 (React) 和一个移动应用程序 (React-Native),它们都通过 socket.io 连接到我创建的节点服务器。 This node server's purpose is to collect information from both users, and display this information in a web page in real time.
该节点服务器的目的是收集双方用户的信息,并将这些信息实时显示在网页中。
My web app has a button that when you click it it opens up that debugging web page in a new tab with the debugging information;我的 Web 应用程序有一个按钮,当您单击它时,它会在包含调试信息的新选项卡中打开该调试网页; I just use
window.open
.我只是使用
window.open
。 Is it possible to do something similar from my mobile device, running a react-native application?是否可以从我的移动设备上执行类似的操作,运行 react-native 应用程序? That is, can I click a button and have a browser tab open on my laptop somehow?
也就是说,我可以单击一个按钮并以某种方式在我的笔记本电脑上打开一个浏览器选项卡吗? Does React-Native remote debugging work with something like this?
React-Native 远程调试是否适用于这样的事情?
There is currently no supported way you can do this in React Native.目前在 React Native 中没有支持的方法可以做到这一点。
However, you can certainly add it yourself.但是,您当然可以自己添加它。
Navigate to node_modules/react-native/local-cli/server/middleware/getDevToolsMiddleware.js
导航到
node_modules/react-native/local-cli/server/middleware/getDevToolsMiddleware.js
Look for launchChrome(debuggerURL);
寻找
launchChrome(debuggerURL);
, you can invoke another launchChrome
function with your desired URL. ,您可以使用所需的 URL 调用另一个
launchChrome
函数。
This will only appear when you select Debug JS Remotely
.这只会在您选择
Debug JS Remotely
时出现。
You can configure the CLI server code more to launch the URL when you are not debugging.在不调试时,您可以配置 CLI 服务器代码以启动 URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.