简体   繁体   English

如何在 React-Native 上分析网络?

[英]How to profile network on React-Native?

I am searching that for a day but can't get proper solution.我正在搜索一天,但无法获得正确的解决方案。

I have to know how to profile network requests on my react-native app.我必须知道如何在我的 react-native 应用程序上分析网络请求。

I am uploading data to the API and two servers and want to know what is the size of uploaded data.我正在将数据上传到 API 和两台服务器,想知道上传数据的大小。 How can I track that.我怎么能跟踪那个。

I tried Android Studio Network Profiler but I think it misses some request parts and there is an IOS side of application.我尝试过 Android Studio Network Profiler,但我认为它错过了一些请求部分,并且有一个 IOS 端的应用程序。 Any advice?有什么建议吗?

Thanks in advance提前致谢

In order to view network requests on iOS, you'll need to do a couple things.为了在 iOS 上查看网络请求,您需要做一些事情。

First, you'll need to enable Web Inspector on your iOS device.首先,您需要在 iOS 设备上启用 Web Inspector。 On iOS go to Settings > Safari > Advanced.在 iOS 上,转到设置 > Safari > 高级。 In there you can enable "Web Inspector".在那里您可以启用“Web Inspector”。

Second, open Safari and make sure you can select the "Develop" menu item in the top menu bar.其次,打开 Safari 并确保您可以选择顶部菜单栏中的“开发”菜单项。 If not you'll have to enable developer settings in the Safari preferences by going to Preferences.. > Advanced and there should be a checkbox near the bottom that will enable Develop menu in menu bar.如果不是,您必须通过转到 Preferences.. > Advanced 在 Safari 首选项中启用开发人员设置,底部附近应该有一个复选框,可以在菜单栏中启用 Develop 菜单。

Finally, plug in your iOS device to your computer via USB with the React Native application running and open Safari.最后,在运行 React Native 应用程序的情况下,通过 USB 将您的 iOS 设备插入计算机并打开 Safari。 Open the Develop menu and you should see your iOS device listed as one of the 3rd or 4th items down.打开“开发”菜单,您应该会看到您的 iOS 设备被列为第 3 或第 4 项之一。 Select your iOS device from the menu and a sub menu should pop up with a list of "Inspectable elements".从菜单中选择您的 iOS 设备,应弹出一个带有“可检查元素”列表的子菜单。 Your React Native app should be listed there and this will open Safari's developer tools.您的 React Native 应用程序应该列在那里,这将打开 Safari 的开发人员工具。

From here you should be able to select the network tab and be able to profile the network for your React Native app on iOS.从这里您应该能够选择网络选项卡,并能够为 iOS 上的 React Native 应用程序配置网络。

As for Android, someone else will have to answer that.至于Android,则必须由其他人来回答。 Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM