deniza / app_tracking_transparency

A Flutter plugin to show ios 14+ tracking authorization dialog.
https://pub.dev/packages/app_tracking_transparency/
MIT License
83 stars 28 forks source link

Replaced ocurrences of ios 14 to 14.5 (because apple enforcement starts at 14.5) #6

Closed j05u3 closed 3 years ago

j05u3 commented 3 years ago

I haven't tested it yet. I will update this thread when I do it.

untp commented 3 years ago

What if I want to request tracking authorization on iOS versions between 14.0-14.5? API is available for 14.0+. In 14.5, it is just required to requesting tracking authorization. If you don't want to request tracking authorization on iOS versions between 14.0 and 14.5, you can check with Platform.operatingSystemVersion. This library is a wrapper for app tracking transparency API and ATT API is available for iOS 14.0+. So this library should support versions between 14.0-14.5.

EDIT: I tested this PR on Xcode 12.5 (beta) with iOS 14.4 and 14.5 simulators. On iOS 14.4, trackingAuthorizationStatus returns notSupported and getAdvertisingIdentifier() returns a string with all zeros. On iOS 14.5, it asks permission, if accepted it returns authorized and UUID ~is valid~ is all zeros (because it is simulator). (Default behavior) ~iOS 14.4 needs a permission dialog for tracking. We can't get UUID without permission. So, permission must be requested on iOS 14.0+, not 14.5+.~

j05u3 commented 3 years ago

On iOS 14.4, trackingAuthorizationStatus returns notSupported and getAdvertisingIdentifier() returns a string with all zeros.

Thanks so much for testing it. I really didn't expect the getAdvertisingIdentifier() to return a string with all zeros on iOS 14.4

j05u3 commented 3 years ago

Also I didn't know you could ask for ATT permission (I mean actually show the dialog) in pre 14.5 iOS devices.

And also I think you are right, if the ATT library is available, then this flutter library should at least give us the chance to try to use it.

Thanks for checking it out, I will proceed to close this PR.

j05u3 commented 3 years ago

I am still wondering if the behavior is the same on real devices.

Here it says that the emulator should always receive zeroes (which is wrong per your tests in 14.5), so what else is different from the documentation?

From that article I understand that starting from 14.5+ on real devices the advertisingidentifier will be all zeroes unless the permission was requested and accepted.

I am still wondering if you can ask for the permission on real devices on 14.x versions prior to 14.5. I am guessing you can, so when the user updates to 14.5 if the permission was previously given we would get a non-zeroes advertisingidentifier

untp commented 3 years ago

Oh, my bad. It was a mistake. UUID is always all zeroes on simulator. And you should reopen this PR.

I tested on simulators because I don't have a real device. But I found a real device testing platform called BrowserStack, and they have a free unlimited plan on open-source projects. I tested your PR and current stable version on BrowserStack.

We can show a dialog 14.0+ but it is not needed for UUID on 14.0-14.5.

Here are the results: (all tests (except last) performed on iOS 14.0, (I didn't test on 14.5, because BrowserStack doesn't support 14.5))

Your PR

No dialogs (because the PR requests on 14.5+) and we can get UUID.

Show image ![pr-14 0](https://user-images.githubusercontent.com/54450843/112768318-39ed2f80-9024-11eb-9db2-2b1034d05633.jpeg)

Stable version - Tap Allow (on custom dialog) and Allow (on system dialog)

We can get UUID.

Show image ![orig-14 0-allow-allow](https://user-images.githubusercontent.com/54450843/112768544-28585780-9025-11eb-992d-0f148de349e3.jpeg)

Stable version - Tap Allow (on custom dialog) and Deny (on system dialog)

We can't get UUID. Because we tapped "Ask app not to track" on system dialog.

Show image ![orig-14 0-allow-deny](https://user-images.githubusercontent.com/54450843/112768630-8b49ee80-9025-11eb-94a7-c05eafb52cf5.jpeg)

Stable version - Tap Decide later (on custom dialog)

We can get UUID. This is strange. You can actually get UUID without dialogs.

Show image ![orig-14 0-decidelater](https://user-images.githubusercontent.com/54450843/112768634-8dac4880-9025-11eb-8517-afc27369a5c1.jpeg)

Stable version - Tap Decide later (on custom dialog), then close app and then tap Allow (on custom dialog) and Allow (on system dialog)

This is for testing that can we get same UUID after system dialog.

Show image (after tapping decide later) ![orig-14 0-decidelater-seq](https://user-images.githubusercontent.com/54450843/112768772-54c0a380-9026-11eb-82e9-55c8c6de4bbd.jpeg)
Show image (app restarted and tapped allow then allow) ![orig-14 0-allow-allow-seq](https://user-images.githubusercontent.com/54450843/112768776-5722fd80-9026-11eb-8170-c9deb4b4b612.jpeg)

Stable version - Tap Decide later (on custom dialog), then close app and then tap Allow (on custom dialog) and Deny (on system dialog)

That is awful. We have UUID before dialog, after denying system dialog we can't have UUID.

Show image (after tapping decide later) ![orig-14 0-decidelater-seq2](https://user-images.githubusercontent.com/54450843/112769008-87b76700-9027-11eb-966f-0bb8c67573e9.jpeg)
Show image (app restarted and tapped allow then Ask app not to track) ![orig-14 0-allow-deny-seq2](https://user-images.githubusercontent.com/54450843/112769011-89812a80-9027-11eb-8cdc-6085323ee298.jpeg)

Stable version on iOS 13.0

No dialogs and UUID is available.

Show image ![orig-13 0](https://user-images.githubusercontent.com/54450843/112769059-c6e5b800-9027-11eb-9021-ce4d7f3df006.jpeg)
untp commented 3 years ago

I think this PR should change a bit. Since we can show ATT system dialog on 14.0-14.5, this library should support it. However, we should add a bool parameter (maybe requestIfRequired) to library functions for requesting dialog on 14.0+ or 14.5+. If the parameter is true, it will request on 14.5+; else, it will request on 14.0+.

EDIT: But this parameter is will not be useful after a few months. Because users will upgrade their OS. So instead of changing this library, we can add this information to README.md.

On iOS >=14.0 <14.5, tracking authorization request dialog isn't required to getting advertising ID. If you don't want to request a dialog on 14.0-14.5, you should wrap your function calls like this: (with device_info and version packages) if (Platform.isIOS && Version.parse((await DeviceInfoPlugin().iosInfo).systemVersion) >= Version(14, 5, 0))

I used device_info package, because Platform.operatingSystemVersion returns macOS version on iOS simulators. Device Info Plugin returns iOS version on real devices and simulators.

j05u3 commented 3 years ago

@untp thank you so much for testing it in real devices. I agree with you, we should just check for iOS version for deciding whether to show the dialog or not.