Back to Blog

How to Build a Bluetooth App with Expo & React Native

React NativeiOSBluetooth
/
How to Build a Bluetooth App with Expo & React Native
📱

How to Build a Bluetooth App with Expo & React Native

Expo is a platform for rapidly and easily developing React Native apps, and they have added experimental support for Bluetooth! Here's a step-by-step guide to setting up and building a functioning Bluetooth app for iOS.
  1. Install Expo
  1. Install XCode
  1. Initialize a new Expo project
      • Use the "Blank" managed template
  1. Add dependencies: expo add react-native-ble-plx @config-plugins/react-native-ble-plx expo-dev-client
  1. Add @config-plugins/react-native-ble-plx to a plugins array in your app.json:
      • (More details on Expo's Bluetooth support here)
  1. Setup the core code from https://github.com/t3db0t/react-native-bluetooth-example
      • Copy and paste the code in App.js
  1. Test on physical device (BLE doesn't exist on simulators)
      • Plug in phone to computer via USB & unlock
      • expo run:ios -d or expo run:android -d
      • If your device is not listed, you may need to:
        • Open XCode
        • Go to Window > Devices and Simulators
        • Unlock your phone and select your device
      • Expo will attempt to manage signing for you automatically. If it doesn't work, see "Setup XCode and provisioning" below
      • Note: using expo run converts your project from a "managed" expo workflow to a "bare" workflow.
  1. Open the app in Expo Go
      • The easiest way I've found to connect to the local Metro server is to login to an Expo account on both your computer and your phone. Then your app should appear under "Recently in Development"
  1. If necessary: Setup XCode and provisioning
      • Download and install profile
      • Uncheck "Automatically Manage Signing"
      • Select downloaded Profile

Discussion

COMMENTS

Thoughts? Email me at hello@inventbuild.studio—I may publish thoughtful replies.

No comments yet. Be the first to share your thoughts!