question

Eric-8805 avatar image
1 Vote"
Eric-8805 asked RobCaplan edited

Xamarin iOS app does not prompt the user about App Tracking Transparency consent

I've been assigned the task to prompt users of a Xamarin iOS app about giving consent to ATT (App Tracking Transparency). I have very limited experience working with Xamarin and I am finding very little on this topic so some help would be much appreciated.

What I've done so far from the information I've been able to piece together:

  • Added the property "NSUserTrackingUsageDescription" to plist and assigned it a string value

  • Tried triggering the prompt by using either AppTrackingTransparency.ATTrackingManager.RequestTrackingAuthorization or AppTrackingTransparency.ATTrackingManager.RequestTrackingAuthorizationAsync

  • Tried triggering the prompt from both AppDelegate startup and from a click event

When the code reaches either method it just skips over it and continues. For example, this is a random click event where it just skips over the method:

 button.Clicked += async (sender, args) =>
 {
  AppTrackingTransparency.ATTrackingManager.RequestTrackingAuthorization((result) =>
  {
  switch (result)
  {
  case AppTrackingTransparency.ATTrackingManagerAuthorizationStatus.NotDetermined:
  break;
  case AppTrackingTransparency.ATTrackingManagerAuthorizationStatus.Restricted:
  break;
  case AppTrackingTransparency.ATTrackingManagerAuthorizationStatus.Denied:
  break;
  case AppTrackingTransparency.ATTrackingManagerAuthorizationStatus.Authorized:
  break;
  default:
  break;
  }
  });
  var status = AppTrackingTransparency.ATTrackingManager.TrackingAuthorizationStatus;
 };



dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered Eric-8805 commented

Hello,​

Welcome to our Microsoft Q&A platform!

I tested the function code on a physical device and a simulator, both work fine. To test the RequestTrackingAuthorization method, you need to enable the Allow Apps to Request to Track option on the device as the following picture shown:

![43243-f63953e3-0cd5-4bdb-9d48-65cbbcda8e44.jpg

And the App Tracking Transparency framework is only supported in iOS 14+, please make sure you've updated the Xcode to the 14+ version and test the code in the iOS 14 device.

Best Regards,

Jarvan Zhang



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



image.png (52.7 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I've run both a simulator using iPhone 11 Pro Max, iOS 14.2 and a simulator using iPhone 8, iOS 14.2. Same thing on both, the code just silently skips the RequestTrackingAuthorization code. No crash, just skips.

And I've made sure to set Allow Apps to Request to Track to true on both emulators. And Xcode is updated to the latest version.

The debug logs aren't showing any errors. I'm at a total loss as to what I'm doing wrong :/

0 Votes 0 ·
Eric-8805 avatar image
0 Votes"
Eric-8805 answered

Turns out I had to clear the bin and obj folder of old files and then everything worked as expected. When in doubt, always clear the bin and obj folders it seems.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Tepco avatar image
0 Votes"
Tepco answered

Hello! I'm hoping somebody can help me with my dilemma as I'm wrestling with something similar. AdMob told me to add SKAdNetworkIdentifier to my Xamarin iOS app info.plist and I did. Test ads show up fine in my app and I also registered my iPad as a test device so I can see real ads in debug mode; no problems there. Everything works just fine and the latest release has been approved by the App Store. The problem is that when I load my app onto my iPad there are no ads showing. This is also the case with a friend's iPad and my nephew's iPhone. Do I also have to add NSUserTrackingUsageDescription to the app and, if this is the case, how would I prompt the user? I'm at wit's end......😒

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.