Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popup not displayed above IOS 15.4+ #32

Open
ThebaultLouis opened this issue May 30, 2022 · 20 comments
Open

Popup not displayed above IOS 15.4+ #32

ThebaultLouis opened this issue May 30, 2022 · 20 comments

Comments

@ThebaultLouis
Copy link

I need to request permission to collect data with the app tracking transparency dialog.
The dialog shows up in my simulator (iphone 13 ios 15.2) but not on real devices (iphone 13 on 15.4 and iphone 13 on 15.5)

I implemented the package with the following code

 @override
  void initState() {
    super.initState();

    WidgetsFlutterBinding.ensureInitialized()
        .addPostFrameCallback((_) => AppTrackingTransparency.requestTrackingAuthorization());
  }
@juri180
Copy link

juri180 commented Jun 10, 2022

Same here. The permission dialog is shown on Simulator with iOS 15.5, but not on a real device with iOS 15.5. On the real device AppTrackingTransparency.requestTrackingAuthorization(); always returns status denied immediately, without showing the dialog.

For test purposes I disabled all my other dialogs and added a delay to the permission dialog – no luck.
I also tried to implement it myself and tried all the different suggestions of this Stackoverflow thread, but couldn't fix it.

Any help would be highly appreciated. Thank you!

@ThebaultLouis
Copy link
Author

ThebaultLouis commented Jun 11, 2022

What I did was to wait 2 seconds before asking for the permission and I don't know why it worked suddently.
Apple accepted my submission after this change

@override
  void initState() {
    super.initState();

    WidgetsFlutterBinding.ensureInitialized()
        .addPostFrameCallback((_) async {
          await Future.delayed(const Duration(milliseconds: 2000));
          await AppTrackingTransparency.requestTrackingAuthorization()
        );
  }

@juri180
Copy link

juri180 commented Jun 13, 2022

@ThebaultLouis Thanks for your response. I tried this approach already and it didn't work, but now it does. My second problem was the I wasn't aware of the iOS setting "allow tracking permission requests". On my test device, this setting was set to false, so all request immediately returned denied.

@marcellocamara
Copy link

Any fix around it ? @deniza

I don't think wait 2 seconds for a long time will be healthy

@FernandoUFS
Copy link

I have the same issue here, and apple isn't approving my application because of that. My device has "allow tracking permission requests" enabled, but nothing I do make it works. I tried delay request, I removed other requests (like notification permissions). The request is just not shown.

@deniza
Copy link
Owner

deniza commented Jun 17, 2022

Did you tried to call AppTrackingTransparency.trackingAuthorizationStatus? What do you get when you call it?

@marcellocamara
Copy link

Did you tried to call AppTrackingTransparency.trackingAuthorizationStatus? What do you get when you call it?

@deniza I don't have an iPhone here to test it, but if you could, will be greatful. On the simulator the issue doesn't appears. I know a serie of big companies that use this package and they are at the mercy of this problem.

To simulate this problem I think it just you ask for the tracking dialog on the first step of your app... Maybe for those who fetch some data first are not going through this issue (talking this because to fix this issue we force wait 2 seconds to call the tracking dialog).

We had publishing problems because of this, and I think the numbers of people will increase.

@GoldenSoju
Copy link

GoldenSoju commented Jul 26, 2022

My app also got rejected because of that error. I saw that the ATT permission dialog got dismissed because of another permission dialog.

I saw that ATTrackingManager has an async function. And I was hoping I could force wait for the function.

class func requestTrackingAuthorization() async -> ATTrackingManager.AuthorizationStatus

But using an async function in the method channel on iOS-side makes the app crash and I couldn't find a way to solve that. Could be a limitation of the method channel.

@FernandoUFS
Copy link

I find that after aprove or deny this permission manually on the iPhone settings the permission request is not shown anymore. Even if I uninstall completely the app and install it again the option I chose before remains checked. I used two other iPhones and the dialog showed up as expected. Maybe the problem isn't the plugin but iOS doing this.

@thanglq-teraark
Copy link

thanglq-teraark commented Aug 8, 2022

My app also got rejected due to this issue. Any update ?

@deniza
Copy link
Owner

deniza commented Aug 9, 2022

I highly recommend showing an explainer dialog before requesting tracking authorization. Please check the sample project. This is the officially recommended (by google) way which leads far better acceptance rates, hence more ads revenue.

I tested the package on various ios versions (15.x and upcoming 16 beta). Everything seems to work fine. (I am using explainer dialog approach)

@b099l3
Copy link

b099l3 commented Aug 12, 2022

I had a similar problem, showing on the simulator not on any iOS 15 device.

Solved it by checking the global setting in:
Settings App > Privacy > Tracking > Set to enabled

I dont remember setting this at all on my device

After that the popup started showing, didn't need todo any delays

@PieterWvdV
Copy link

I highly recommend showing an explainer dialog before requesting tracking authorization. Please check the sample project. This is the officially recommended (by google) way which leads far better acceptance rates, hence more ads revenue.

I tested the package on various ios versions (15.x and upcoming 16 beta). Everything seems to work fine. (I am using explainer dialog approach)

I Already have another few dialogs which I am awaiting before I show the ATT dialog. Still it is not displaying.
I have tried the delays with no success

@sparkmobi
Copy link

Any Updates? i am getting the same apple rejection

@bypass112
Copy link

Hi please make sure you have "Allow Apps to Request to Track" enabled on device and make sure the app is properly mounted on the native side. I would recommend requesting the dialog in an initState of a screen, maybe the first one. zoontek/react-native-permissions#648 (comment) this explains more about it

@KKimj
Copy link

KKimj commented Jan 6, 2023

Hello
Here is simple solution to handle this issue.

if (authorizationStatus == TrackingStatus.notDetermined) {...}
-> while (authorizationStatus == TrackingStatus.notDetermined) {...}

Avoid infinite loop, Add int timeoutCount variable.

After

TrackingStatus authorizationStatus =
        await AppTrackingTransparency.trackingAuthorizationStatus;
    int timeoutCount = 0;
    while (authorizationStatus == TrackingStatus.notDetermined &&
        timeoutCount < 10) { // Adjust yourself.. maybe up to ~50
      authorizationStatus =
          await AppTrackingTransparency.requestTrackingAuthorization();
      await Future.delayed(const Duration(milliseconds: 200));
      timeoutCount++;
    }

Before

TrackingStatus authorizationStatus =
        await AppTrackingTransparency.trackingAuthorizationStatus;
    if (authorizationStatus == TrackingStatus.notDetermined) {
      authorizationStatus =
          await AppTrackingTransparency.requestTrackingAuthorization();
    }

This is the demonstration screenshot video.

2023-01-06.1.52.43.mov

Thanks!

@mkbsugita
Copy link

iOS 16.4 can't open.
iOS 16.1.1 can open
Why? But I build on Xcode 14.1. Xcode version is necessary?

README says using XCode 12 and run your app on an ios 14 device. only.

@Zaveri21
Copy link

@luminkhant i was facing this same issue. I added bellow code in appDelegate.swift file and Authorisation default alert showing in iOS 16+

func applicationDidBecomeActive(_ application: UIApplication) {
    if #available(iOS 14, *) {
        ATTrackingManager.requestTrackingAuthorization { status in
            switch status {
            case .authorized:
                // Tracking authorization dialog was shown
                // and we are authorized
                print("Authorized")
            case .denied:
                // Tracking authorization dialog was
                // shown and permission is denied
                print("Denied")
            case .notDetermined:
                // Tracking authorization dialog has not been shown
                print("Not Determined")
            case .restricted:
                print("Restricted")
            @unknown default:
                print("Unknown")
            }
        }
    }
}

@mkbsugita
Copy link

mkbsugita commented Jun 13, 2023

@Zaveri21
Thank you for your information.

I hope you to make pull-request for it.
https://github.com/deniza/app_tracking_transparency/blob/master/ios/Classes/SwiftAppTrackingTransparencyPlugin.swift

@yanqiuLove
Copy link

我的项目是Flutter创建的,iOS端语言使用的是OC,针对该问题我的解决方案如下:
在AppDelegate.m文件中加入以下代码:

#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/ASIdentifierManager.h>
- (void)applicationDidBecomeActive:(UIApplication *)application { if (@available(iOS 14, *)) { // iOS14及以上版本先请求权限 [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { // 获取到权限后使用老方法获取idfa if (status == ATTrackingManagerAuthorizationStatusAuthorized) { NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString]; NSLog(@"%@",idfa); } else { NSLog(@"请在设置-隐私-跟踪中允许App请求跟踪"); } }]; } else { // iOS14以下版本使用老方法 // 判断在设置-隐私里是否打开了广告跟踪 if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) { NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString]; NSLog(@"%@",idfa); } else { NSLog(@"请在设置-隐私-广告中打开广告跟踪功能"); } } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests