zoontek / react-native-permissions

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

APP_TRACKING_TRANSPARENCY is constantly unavailable, even on device #576

Closed haveamission closed 3 years ago

haveamission commented 3 years ago

I have installed the relevant pods, I have the latest version of React Native Permissions, and I am trying the following code:

    let permission;
    if(Platform.OS === "ios") {
    permission = await request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY);
    }
    console.log("IOS PERMS");
    console.log(permission);

I have also created this in my info.plist:

  <key>NSUserTrackingUsageDescription</key>
  <string>App would like to access IDFA for tracking purpose</string>

I get:

"unavailable"

Are there any other steps that need to happen here, or is this a bug?

zoontek commented 3 years ago

@haveamission Did you checked https://github.com/zoontek/react-native-permissions/issues/541#issuecomment-731221451 ?

haveamission commented 3 years ago

@zoontek Yeah, I checked that setting and it is enabled on my phone

zoontek commented 3 years ago

Could you fill the rest of the issue template ? I need more infos (device, iOS version, etc). Thanks!

haveamission commented 3 years ago

@zoontek Here you go:

Summary

I try to request the App Tracking Transparency, and get unavailable

Environment info

react-native info output:

System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 598.84 MB / 16.00 GB
    Shell: 5.7.1 - /usr/local/bin/zsh
  Binaries:
    Node: 14.6.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.6 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.8 - /usr/bin/javac
    Python: 2.7.16 - /usr/local/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: Not Found
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 3.0.1

Steps to reproduce

Run this function from my app login page:

  async requestPermission() {
    let permission;
    if(Platform.OS === "ios") {
    permission = await request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY);
    }
    console.log("iOS PERMS");
    console.log(permission);
    return permission;
  }

I get:

iOS PERMS
unavailable

Describe what you expected to happen:

I get a prompt for app tracking

It happens in both the simulator as well as on my iPhone 12 Pro - running iOS 14.4.1

haveamission commented 3 years ago

Could any library be causing a conflict here? I have Appsflyer installed as well

zoontek commented 3 years ago

@haveamission Could you reproduce it with the app from the /example directory?

chrispaynter commented 3 years ago

I tried the example app on my iPhone (running 14.4.1), with the "Allow Apps to Request to Track" setting enabled and at first launch the APP_TRACKING_TRANSPARENCY permission is set to blocked and cannot be pressed.

There is also no individual setting for allowing tracking in the app's own settings themselves.

image

However, does work on the simulator for me.

image

I'd go as far as to say that with the differing experiences I'm reading around the web on this, it's not worth testing for ATT on a device less than 14.5 -- we'll just do the upgrade to the beta.

zoontek commented 3 years ago

iOS 14.5 is out soon, ATT is supposed to work correctly after.

chrispaynter commented 3 years ago

Let's hope. After upgrading to 14.5 betas we still have testers having issues with getting the dialogue to show up. Sometimes the check box to allow apps to track is greyed out. Some devices are ok, others aren't.

All in all, it's a bit of a dogs breakfast, but we're proceeding with a view that the devices it does pass testing on will represent all devices at some point.

zoontek commented 3 years ago

It might happen because those users don't allow apps to track them? https://stackoverflow.com/questions/62817164/idfa-ios14-returns-denied-without-displaying-auth-popup/62840480#62840480

It this switch is off, the request popup won't show up.

afonso-tsx commented 3 years ago

I'm having the same issue on iOS 14.3, and the tracking switch is ON in my device.

chrispaynter commented 3 years ago

We've already covered that one @zoontek, it seems like the problem surfaces in two main symptoms.

1) Even though allow to track is enabled, the device doesn't respond to ATT requests (i.e blocked) 2) The allow to track switch in settings is often greyed out, requires sign in and out of iCloud to reenable.

Maybe there's others I haven't seen yet.

ccdwyer commented 3 years ago

I'm seeing this as well. Looks like it's a common issue: https://developer.apple.com/forums/thread/673760?page=2

zoontek commented 3 years ago

Unfortunately I don't think this is an issue with the react-native-permissions, but more with iOS / the SDK. Could you all try with iOS 14.5 + the latest Xcode version?

lucasrocha7111 commented 3 years ago

Hello, have you changed the podfile?

Is needed to add this line on pod file: pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"

As is showed on documentation here: https://www.npmjs.com/package/react-native-permissions#ios

After that you need build again and done :)

lucasrocha7111 commented 3 years ago

Hello, have you changed de podfile?

Is needed to add this line on pod file: pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"

As is showed on documentation here: https://www.npmjs.com/package/react-native-permissions#ios

After that you need build again and done :)

At least worked fine on simulator.

BrandonCao commented 3 years ago

Doesn't this only take effect for iOS 14.5? Could be the reason it's blocked.

zoontek commented 3 years ago

Is this still happening for you on iOS > 14.5?

zoontek commented 3 years ago

I'm closing this, for a solution check this great comment: https://github.com/zoontek/react-native-permissions/issues/541#issuecomment-834397198

RaphaelHadjadj commented 3 years ago

It's still happening, on a simulator (iPhone 12 iOS 14.5) and a physical device (iPhone XS iOS 14.6). I installed react-native-tracking-transparency and it worked directly on both ! So it's probably related to the package.

ezeaguerre commented 3 years ago

@RaphaelHadjadj same thing here, I ended up installing react-native-tracking-transparency and all worked flawlessly!

anishsundarjee commented 2 years ago

I am requesting for app tracking transparency permission on button click only if user is of iOS version 14.5 and above. this feature was working as expected for me, till iOS version 15.0.0

but as of 15.0.1 when checking for permission APP_TRACKING_TRANSPARENCY it gives me result as UNAVAILABLE am using Xcode 12.5.1, react-native : 0.64.1, "react": "16.13.1", "react-native-permissions": "^3.0.5"

zoontek commented 2 years ago

@anishsundarjee https://github.com/zoontek/react-native-permissions/issues/648

ShepSims commented 1 year ago

Worth noting that this request fails if you don't make sure the application's state is "active" and if it is "backgrounded" or "inactive" it can return unavailable and then never be presented again.

To make sure the call gets made for the first time in the "active" state, wrap the request in a listener for state change like so:


const handleAppStateChange = async (nextAppState) => {
    if (nextAppState == 'active') {
      request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY)
        .then(async (result) => {
          if (result == RESULTS.GRANTED) {
            // send some kind of tracking analytics
          } else {
           // Not allowed to send tracking analytics
          }
        })
        .catch((error) => {
          console.log('error in request tracking permissions: ', error);
        });
    }
zoontek commented 1 year ago

@ShepSims Not needed anymore since 3.7.1: https://github.com/zoontek/react-native-permissions/releases/tag/3.7.1