-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1105 from dotintent/feature/add_expo_plugin
feat: add expo config plugin
- Loading branch information
Showing
19 changed files
with
7,633 additions
and
3,876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/**/node_modules/* | ||
node_modules/ | ||
docs/** | ||
lib/** | ||
plugin/build | ||
lib/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Outputs | ||
plugin/build | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ It does NOT support: | |
3. [Documentation & Support](#documentation--support) | ||
4. [Configuration & Installation](#configuration--installation) | ||
5. [Troubleshooting](#troubleshooting) | ||
6. [Contributions](#contributions) | ||
|
||
## Compatibility | ||
|
||
|
@@ -79,7 +80,51 @@ Contact us at [intent](https://withintent.com/contact-us/?utm_source=github&utm_ | |
|
||
### Expo SDK 43+ | ||
|
||
1. A custom expo-dev-client can now be built along with config plugins to avoid the need to eject from Expo. Learn how to integrate react-native-ble-plx with Expo [here](https://expo.canny.io/feature-requests/p/bluetooth-1). (only for expo SDK 43+) | ||
> Tested against Expo SDK 49 | ||
> This package cannot be used in the "Expo Go" app because [it requires custom native code](https://docs.expo.io/workflow/customizing/). | ||
> First install the package with yarn, npm, or [`npx expo install`](https://docs.expo.io/workflow/expo-cli/#expo-install). | ||
After installing this npm package, add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`: | ||
|
||
```json | ||
{ | ||
"expo": { | ||
"plugins": ["react-native-ble-plx"] | ||
} | ||
} | ||
``` | ||
|
||
Next, rebuild your app as described in the ["Adding custom native code"](https://docs.expo.io/workflow/customizing/) guide. | ||
|
||
## API | ||
|
||
The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and `prebuild`) the native app. If no extra properties are added, defaults will be used. | ||
|
||
- `isBackgroundEnabled` (_boolean_): Enable background BLE support on Android. Adds `<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>` to the `AndroidManifest.xml`. Default `false`. | ||
- `neverForLocation` (_boolean_): Set to true only if you can strongly assert that your app never derives physical location from Bluetooth scan results. The location permission will be still required on older Android devices. Note, that some BLE beacons are filtered from the scan results. Android SDK 31+. Default `false`. _WARNING: This parameter is experimental and BLE might not work. Make sure to test before releasing to production._ | ||
- `modes` (_string[]_): Adds iOS `UIBackgroundModes` to the `Info.plist`. Options are: `peripheral`, and `central`. Defaults to undefined. | ||
- `bluetoothAlwaysPermission` (_string | false_): Sets the iOS `NSBluetoothAlwaysUsageDescription` permission message to the `Info.plist`. Setting `false` will skip adding the permission. Defaults to `Allow $(PRODUCT_NAME) to connect to bluetooth devices`. | ||
|
||
> Expo SDK 48 supports iOS 13+ which means `NSBluetoothPeripheralUsageDescription` is fully deprecated. It is no longer setup in `@config-plugins/[email protected]` and greater. | ||
#### Example | ||
|
||
```json | ||
{ | ||
"expo": { | ||
"plugins": [ | ||
[ | ||
"@config-plugins/react-native-ble-plx", | ||
{ | ||
"isBackgroundEnabled": true, | ||
"modes": ["peripheral", "central"], | ||
"bluetoothAlwaysPermission": "Allow $(PRODUCT_NAME) to connect to bluetooth devices" | ||
} | ||
] | ||
] | ||
} | ||
} | ||
``` | ||
|
||
### Legacy Expo (SDK < 43) | ||
|
||
|
@@ -162,3 +207,7 @@ Contact us at [intent](https://withintent.com/contact-us/?utm_source=github&utm_ | |
With `neverForLocation` flag active, you no longer need to ask for `ACCESS_FINE_LOCATION` in your app | ||
|
||
## Troubleshooting | ||
|
||
## Contributions | ||
|
||
- Special thanks to @EvanBacon for supporting the expo config plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./plugin/build/withBLE') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
roots: ['<rootDir>/__tests__'], | ||
preset: 'react-native' | ||
} |
Oops, something went wrong.