如何在不摇动物理设备的情况下在 React Native 上激活调试?

How to activate debug on React Native without Shaking the physical device?

在物理设备上晃动有时会很困难,尤其是当设备和电缆几乎没有连接时(对于充电插座或电缆的某些问题)。

我发生过几次,当我想摇晃我的连接丢失时。

有什么方法可以在物理设备上模拟摇晃手势吗?

我遇到了同样的问题,我找到了这些解决方案 :

----------------对于 ANDROID 设备----------------

运行在物理设备或模拟器上安装您的应用程序后,运行此命令可查看开发菜单:

adb shell input keyevent KEYCODE_MENU

--------------------对于 IOS 设备-------------------- ------

您可以轻松地将摇动手势添加到辅助触摸,当您的应用程序 运行ning 您可以在调试菜单上单击它时,如果您想知道如何激活它,将会显示 check the link

--------对于代码内部的两者---------

import React from 'react';
import {
  View,
  PanResponder,
  NativeModules,
}            from 'react-native';


const DevMenuTrigger = ({children}) => {
  const {DevMenu} = NativeModules;
  const panResponder = PanResponder.create({
    onStartShouldSetPanResponder: (evt, gestureState) => {
      if (gestureState.numberActiveTouches === 3) {
        DevMenu.show();
      }
    },
  });
  return <View style={{flex: 1}} {...panResponder.panHandlers}>{children}</View>;
};

AppRegistry.registerComponent('myApp', (): any => <DevMenuTrigger><MyApp></DevMenuTrigger>);