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

Eric 6 Reputation points
2020-11-26T13:42:00.747+00:00

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;
};
Developer technologies .NET Xamarin
0 comments No comments
{count} vote

3 answers

Sort by: Most helpful
  1. JarvanZhang 23,971 Reputation points
    2020-11-27T07:40:08.027+00:00

    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.


  2. Eric 6 Reputation points
    2020-11-29T08:24:06.957+00:00

    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.

    0 comments No comments

  3. tparonis@verizon.net 1 Reputation point
    2021-04-17T20:18:23.517+00:00

    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......😒

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.