Reputation: 48566
I'm developing an iOS app that requires BLE but am confused as to the current state and workflow for getting Bluetooth into my app using Expo's tools.
So far I gather there are some constraints that I must work around:
So (and I'm new to this so be patient) I gather that means I must either
expo run:ios -d
and run on a connected device, oreas build -p ios
and download to devices.But what's unclear (and I may not even have the above quite right, in fact I'd be happy to know that it's not that complex) is how to access Bluetooth in the first place. I see that the Expo API provides access to all kinds of platform functionality, but don't see Bluetooth anywhere there. I gather that in order to use Bluetooth, I must use react-native-ble-plx
(ignoring the part where it says my project needs to be "ejected"?) for which I need to add a corresponding plugin with
yarn add @config-plugins/react-native-ble-plx expo-dev-client
and and the corresponding entry under expo.plugins
in my app.json
.
Do I have that right? Will those steps then give me access to platform Bluetooth (though not in Expo Go or Simulator)?
Upvotes: 11
Views: 11283
Reputation: 705
See the Getting Started guide for details on how to set up EAS build with expo-dev-client
. Here is a summary:
# Create the project
npx create-expo-app my-app
cd my-app
expo install expo-dev-client
# Install EAS
npm install -g eas-cli
# Configure EAS (follow the instructions)
eas build:configure
Then see the @config-plugins/react-native-ble-plx for instructions to install the plugin:
expo install react-native-ble-plx @config-plugins/react-native-ble-plx
Add the following entry to your app.json
:
{
"expo": {
"plugins": ["@config-plugins/react-native-ble-plx"]
}
}
You can build the development version of your app with the following command (this will include the react-native-ble-plx
plugin you added earlier in the build):
eas build --profile development --platform ios
Finally you can start the dev client to work on your app:
npx expo start --dev-client
Upvotes: 10