React Native: Stop Shaking Your Phone!

Jesse Sessler
Delivery.com Engineering
2 min readMay 5, 2016

If you’re developing a React Native app on an Android device then you know this story.

You’re sitting there holding your $500 phone plugged in to your $2,000 MacBook and you need to reload the app. So you shake it. You’re nervous because you probably shake it 300 times a day and one of these days it’s going to slip and now you’re out $2,500. The worrying makes your hands sweaty, only increasing the likelihood of a slip-up, so you get even more nervous and… well, you get the idea.

Here’s a nifty trick to prevent that from happening, and to make life just a little bit easier during development. You can set up a keyboard shortcut to open the menu on your phone from your laptop.

  1. Set up an Automator Service by opening Automator, clicking “New Document”, and choosing “Service”.

2. Find and select the “Run Shell Script” action. Choose “no input” for “Service receives” and enter:

/usr/local/bin/adb shell input keyevent 82

If adb is located elsewhere in your system, change the path to adb. You can find out with:

$ which adb

3. Save and remember what name you give the action.

4. Open “System Preferences”, go to “Keyboard” and select the “Shortcuts” tab. Select “Services” on the left column and find your service by name.

5. Click where it says “none” and enter the keyboard shortcut you want to use. Make it something unique or it will conflict with an existing shortcut.

Notes:

  • Android only
  • Must be plugged in
  • If you’ve never run the following with this device, run it first before trying the shortcut:
$ adb reverse tcp:8081 tcp:8081

And that’s it. Enjoy!

--

--