Skip to content
aliberski edited this page Jan 9, 2025 · 1 revision

Example

// app.json

{
  "expo": {
    "plugins": [
      [
        "react-native-ble-plx",
        {
          "isBackgroundEnabled": true,
          "modes": ["peripheral", "central"],
          "bluetoothAlwaysPermission": "Allow $(PRODUCT_NAME) to connect to bluetooth devices"
        }
      ]
    ]
  }
}

Legacy Expo (SDK < 43)

  1. Make sure your Expo project is ejected (formerly: detached). You can read how to do it here. (only for Expo SDK < 43)
  2. Follow steps for iOS/Android.

Localize NSBluetoothAlwaysUsageDescription in iOS

Expo allows translating metadata by adding "CFBundleAllowMixedLocalizations": true. We can localize the bluetooth permission message in a following way:

// app.json

{
   "expo": {
      "plugins": [
         [
            "react-native-ble-plx",
            {
               "isBackgroundEnabled": true,
               "modes": [
                  "peripheral",
                  "central"
               ]
            }
         ]
      ],
      "ios": {
         "infoPlist": {
            "CFBundleAllowMixedLocalizations": true
         }
      },
      "locales":  {
         "en": "./en.json",
         "de": "./de.json"
      }
   }
}
// en.json

{
  "NSBluetoothAlwaysUsageDescription": "We need Bluetooth to connect to devices."
}
// de.json

{
  "NSBluetoothAlwaysUsageDescription": "Wir benötigen Bluetooth, um eine Verbindung zu Geräten herzustellen."
}