zoontek / react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.
MIT License
4.04k stars 828 forks source link

Motion permission request not works on iPhone 13 Pro #884

Closed kostrzewskij closed 3 months ago

kostrzewskij commented 3 months ago

Before submitting a new issue

Bug summary

I have an issue with motion permission request on iPhone 13 Pro. When I request on the permission on iPhone 6s everything works fine and I can see permission request dialog. On iPhone 13 Pro it not displays permission request dialog. Bellow I attach my package.json, App.tsx and app.json

{
  "name": "app",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "ios:device": "expo run:ios --device",
    "web": "expo start --web",
    "lint": "eslint .",
    "prebuild": "expo prebuild",
    "prebuild:clean": "expo prebuild --clean",
    "eject": "expo eject",
    "clean": "react-native-clean-project",
    "clean-build:ios": "rm -rf node_modules && rm -rf ios && yarn install && yarn prebuild:clean && cp -r ios_ci_scripts ios/ci_scripts && yarn ios"
  },
  "dependencies": {
    "expo": "~51.0.14",
    "expo-build-properties": "~0.12.3",
    "expo-device": "^6.0.2",
    "expo-font": "~12.0.6",
    "expo-location": "~17.0.1",
    "expo-status-bar": "~1.12.1",
    "react": "18.2.0",
    "react-native": "0.74.2",
    "react-native-permissions": "^4.1.5"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/convict": "^6.1.6",
    "@types/react": "~18.2.45",
    "eas-cli": "^9.0.8",
    "eslint": "^8.57.0",
    "eslint-config-universe": "^12.0.0",
    "prettier": "^3.2.5",
    "ts-node": "^10.9.2",
    "typescript": "^5.1.3"
  },
  "private": true
}

App.tsx:

import { PERMISSIONS, request } from 'react-native-permissions';
import { Text } from 'react-native';

export default function App() {
  request(PERMISSIONS.IOS.MOTION);

  return <Text>some text</Text>;
}

app.json

{
  "expo": {
    "name": "app",
    "slug": "app",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "infoPlist": {
        "NSMotionUsageDescription": "App requires NSMotionUsageDescription"
      },
      "bundleIdentifier": "app"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "package": "app"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "minSdkVersion": 26,
            "kotlinVersion": "1.7.10",
            "compileSdkVersion": 33,
            "targetSdkVersion": 33
          }
        }
      ],
      [
        "react-native-permissions",
        {
          "iosPermissions": [
            "LocationAccuracy",
            "LocationAlways",
            "Motion"
          ]
        }
      ]
    ]
  }
}

Library version

4.1.5

Environment info

System:
  OS: macOS 13.2.1
  CPU: (8) arm64 Apple M1
  Memory: 195.83 MB / 16.00 GB
  Shell:
    version: 5.8.1
    path: /bin/zsh
Binaries:
  Node:
    version: 20.11.1
    path: ~/.nvm/versions/node/v20.11.1/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: ~/.nvm/versions/node/v20.11.1/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.19
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.2
    wanted: 0.74.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

  1. Install app on real device
  2. Open app on device

It should show permission dialog on app open

Reproducible sample code

{
  "name": "app",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "ios:device": "expo run:ios --device",
    "web": "expo start --web",
    "lint": "eslint .",
    "prebuild": "expo prebuild",
    "prebuild:clean": "expo prebuild --clean",
    "eject": "expo eject",
    "clean": "react-native-clean-project",
    "clean-build:ios": "rm -rf node_modules && rm -rf ios && yarn install && yarn prebuild:clean && cp -r ios_ci_scripts ios/ci_scripts && yarn ios"
  },
  "dependencies": {
    "expo": "~51.0.14",
    "expo-build-properties": "~0.12.3",
    "expo-device": "^6.0.2",
    "expo-font": "~12.0.6",
    "expo-location": "~17.0.1",
    "expo-status-bar": "~1.12.1",
    "react": "18.2.0",
    "react-native": "0.74.2",
    "react-native-permissions": "^4.1.5"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/convict": "^6.1.6",
    "@types/react": "~18.2.45",
    "eas-cli": "^9.0.8",
    "eslint": "^8.57.0",
    "eslint-config-universe": "^12.0.0",
    "prettier": "^3.2.5",
    "ts-node": "^10.9.2",
    "typescript": "^5.1.3"
  },
  "private": true
}

App.tsx:

import { PERMISSIONS, request } from 'react-native-permissions';
import { Text } from 'react-native';

export default function App() {
  request(PERMISSIONS.IOS.MOTION);

  return <Text>some text</Text>;
}

app.json

{
  "expo": {
    "name": "app",
    "slug": "app",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "infoPlist": {
        "NSMotionUsageDescription": "App requires NSMotionUsageDescription"
      },
      "bundleIdentifier": "app"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "package": "app"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "minSdkVersion": 26,
            "kotlinVersion": "1.7.10",
            "compileSdkVersion": 33,
            "targetSdkVersion": 33
          }
        }
      ],
      [
        "react-native-permissions",
        {
          "iosPermissions": [
            "LocationAccuracy",
            "LocationAlways",
            "Motion"
          ]
        }
      ]
    ]
  }
}
zoontek commented 3 months ago

@kostrzewskij What does the request promise resolves?

kostrzewskij commented 3 months ago

It resolves blocked

kostrzewskij commented 3 months ago

And it is blocked even if I remove app and install it from the scratch.

zoontek commented 3 months ago

So, no issue with the library. See https://github.com/zoontek/react-native-permissions/issues/767#issuecomment-1522800860

kostrzewskij commented 3 months ago

I found the solution. Newer versions of iOS remember permissions state even if i uninstall app and install it again. https://stackoverflow.com/questions/48416987/iphone-remembers-location-permissions-after-uninstalling