Problem with permissions in iOS & iOS Simulator

I’m working on this Expo-managed App, where I implement a functionality using react-native-ble-plx.

The workflow consisted of installing and generating everything related to the Expo Dev Client, in order to implement community libraries within the project.

When configuring permissions using some handlers like expo-permissions (I know it’s deprecated), PermissionAndroid, and react-native-permissions; the app works without any issues on Android (we even distributed it on the Google Play Store).

However, when launching the project on the iOS Simulator, while the Application is being built, a critical error occurs: No Permission Handler Detected, check that you added at least one permission handler in your package.json reactNativePermissionsIOS config.

IMPORTANT: THE APP IS NOT EJECTED YET (I WANT TO AVOID THAT).

I’m not sure if it’s necessary to eject the App since it works great on Android without ejecting.

package.json:

{
  "name": "reactbase",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    ...
  },
  "dependencies": {
   ...
  },
  "devDependencies": {
    "@babel/core": "^7.19.3"
  },
  "private": true,
  "reactNativePermissionsIOS": [
    "AppTrackingTransparency",
    "BluetoothPeripheral",
    "Calendars",
    "Camera",
    "Contacts",
    "FaceID",
    "LocationAccuracy",
    "LocationAlways",
    "LocationWhenInUse",
    "MediaLibrary",
    "Microphone",
    "Motion",
    "Notifications",
    "PhotoLibrary",
    "PhotoLibraryAddOnly",
    "Reminders",
    "Siri",
    "SpeechRecognition",
    "StoreKit"
  ]
}

app.config.js :

export default ({ config }) => ({
  ...config,

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

  extra: {
    enviroment: process.env.APP_ENV,
  },

  ios: {
    supportsTablet: true,
    bundleIdentifier: "cohasa.client.app",

    infoPlist: {
      NSPhotoLibraryUsageDescription:
        "This app needs access to your photo library.",
      NSCameraUsageDescription: "This app needs access to your camera.",
      NSLocationWhenInUseUsageDescription:
        "This app needs access to your location when in use.",
      NSLocationAlwaysUsageDescription:
        "This app needs access to your location always.",
      NSBluetoothAlwaysUsageDescription:
        "This app needs access to your Bluetooth devices.",
      NSBluetoothPeripheralUsageDescription:
        "This app needs to connect to Bluetooth devices.",
    },
  },

  android: {
    package: "cohasa.client.app",
    versionCode: 2,
    permissions: [
      "android.permission.ACCESS_FINE_LOCATION",
      "android.permission.BLUETOOTH_SCAN",
      "android.permission.BLUETOOTH_CONNECT",
    ],
  },
});

Error in iOS Simulator:

Solved, Just add the PermissionsIOS array in package.json

Then, you have to add the post install scripts in your package.json

That post install script have to make the cd ios && pods install.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.