How do I open react-native's dev menu on real device
If you are on a mac, there is a handy tool called Frappe. https://github.com/niftylettuce/frappe
You can use this command from the shell
adb shell input keyevent 82
if haven't run react-native run-android
or if the device gets disconnected after you have run the react-native run-android
. You need to re-enable the development server port. You can run this command and try again with the previous command
adb reverse tcp:8081 tcp:8081
EDIT: this solution only works for android devices and is among the hacks proposed in the question above. So it is improvable. However It is selected as valid answer until this happens.
Here is what I do:
Android:
Add a script to your package.json:
"android-shake": "adb shell input keyevent 82"
You will then be able to call yarn android-shake
to have the menu popup on Android (as long as the device is connected to the computer that is).
iOS
Settings -> Accessibility -> AssistiveTouch
- Turn it on.
- Tap on Customize Top Level Menu...
- Remove all icons but one, and set it to shake.
That will give you a button that you can tap instead of shaking the device.
I hope this can help others.
I add a simple absolutely positioned button and this onClick handler to it
imoprt { NativeModules } from 'react-native';
...
onMenuButtonClick(){
NativeModules.DevMenu.show();
}