zoontek / react-native-permissions

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

Request APP_TRACKING_TRANSPARENCY always return 'blocked' before user accept request #857

Closed Geoffrey63 closed 6 months ago

Geoffrey63 commented 8 months ago

Before submitting a new issue

Bug summary

Tested in the Example project from this repo : clicking on "Request" to request the PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY permission show the Snack with "blocked" directly after clicking the button and doesn't wait for user to answer the system permission pop-up. Then clicking on "Allow" has no effect.

Tested equally inside our app and the behavior is identical.

Library version

4.1.4

Environment info

System:
  OS: macOS 14.3
  CPU: (10) arm64 Apple M1 Pro
  Memory: 218.86 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 19.9.0
    path: /var/folders/s9/k2twkc7n6xjg_rldxb1qtr_9568bbk/T/yarn--1710338064745-0.30628516454972465/node
  Yarn:
    version: 1.22.19
    path: /var/folders/s9/k2twkc7n6xjg_rldxb1qtr_9568bbk/T/yarn--1710338064745-0.30628516454972465/yarn
  npm:
    version: 9.6.3
    path: ~/.nvm/versions/node/v19.9.0/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/gesoubr1/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.5
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/gesoubr1/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.4
    wanted: 0.73.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Xcode : 15.3

Steps to reproduce

  1. Launch the Example project from this repo on iOS (iOS 17.4, Xcode 15.3)
  2. Click on "Request" below the APP_TRACKING_TRANSPARENCY permissions => System permission popup is displayed but Snack shows immediately "blocked" without waiting for the user choice

Reproducible sample code

Code from the Example (App.tsx, l.98) : 

<Button
  icon="help-circle-outline"
  mode="contained"
  onPress={() => {
    RNPermissions.request(item)
      .then((status) => {
        showSnackbar(`request(${name})`, status);
      })
      .catch((error) => {
        console.error(error);
      });
  }}
>
  Request
</Button>
Vepsur commented 8 months ago

I was having the same issue, and all that I needed to do was globally turn on tracking in my iPhone settings

krizzu commented 7 months ago

Seems like OS issue https://forums.developer.apple.com/forums/thread/746432

Rebsos commented 7 months ago

It's still not fixed by Apple, so I used while + check in redux-saga:

  let result = yield call(check, PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY);
  if (result === RESULTS.DENIED) {                                  // The permission has not been requested, so request it.
    /*
      There is a bug in iOS 17.4 request function. It does not wait for the user to make a decision
      and returns immediately "blocked". Usually it should wait and return the decision of the user.
      The check function works correctly. Therefore, we have to loop and check until the user has
      made a decision (denied or granted). Source:
      https://github.com/zoontek/react-native-permissions/issues/857
      https://forums.developer.apple.com/forums/thread/746432
    */
    yield call(request, PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY); // Bug in 17.4. Don't use result, because it is always "blocked"
    while (result === RESULTS.DENIED) {
      yield delay(5000);
      result = yield call(check, PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY);
    }
  }
Mihai-github commented 6 months ago

Does anybody experience this behavior but with unavailable? For me on iOS 17.x.x I have this.

dylancom commented 6 months ago

Should be fixed now in iOS 17.5

Geoffrey63 commented 6 months ago

Should be fixed now in iOS 17.5

Yes, tested on my apps, it has been fixed in iOS 17.5.