react-native-permissions icon indicating copy to clipboard operation
react-native-permissions copied to clipboard

Request APP_TRACKING_TRANSPARENCY always return 'blocked' before user accept request

Open Ge0ffreyS opened this issue 1 year ago • 3 comments

Before submitting a new issue

  • [X] I tested using the latest release of the library, as maybe the bug has been already fixed.
  • [X] I checked for possible duplicate issues, with possible answers.

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>

Ge0ffreyS avatar Mar 13 '24 14:03 Ge0ffreyS

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

Vepsur avatar Mar 20 '24 12:03 Vepsur

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

krizzu avatar Mar 27 '24 12:03 krizzu

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);
    }
  }

Rebsos avatar Apr 12 '24 19:04 Rebsos

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

Mihai-github avatar May 03 '24 12:05 Mihai-github

Should be fixed now in iOS 17.5

dylancom avatar May 15 '24 14:05 dylancom

Should be fixed now in iOS 17.5

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

Ge0ffreyS avatar May 15 '24 14:05 Ge0ffreyS