How do you request consent to use ad identifier for personalized ads in xamarin.forms?

Brian Kramer 66 Reputation points
2021-06-12T20:48:46.287+00:00

How do you request consent to use ad identifier for personalized ads in xamarin.forms?

Is there examples or library?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,354 questions
{count} votes

Accepted answer
  1. Kyle Wang 5,531 Reputation points Microsoft Vendor
    2021-06-15T08:55:57.337+00:00

    Hi BrianKramer-3128,

    Welcome to our Microsoft Q&A platform!

    To request the permission, your app must support App Tracking Transparency.

    First, you need to create a new string key NSUserTrackingUsageDescription in the Info.plist file.

    Then we can display a system-permission alert request via DenpendencyService.

    1.Create a interface

    public interface IAdvertisingService  
    {  
        void RequestPermission();  
    }  
    

    2.Call the method RequestTrackingAuthorizationAsync which in AppTrackingTransparency framework

    [assembly: Dependency(typeof(AdvertisingService))]  
    namespace Demo.iOS  
    {  
        class AdvertisingService : IAdvertisingService  
        {  
            public void RequestPermission()  
            {  
                AppTrackingTransparency.ATTrackingManager.RequestTrackingAuthorizationAsync();  
            }  
        }  
    }  
    

    3.Call RequestPermission

    DependencyService.Get<IAdvertisingService>().RequestPermission();  
    

    About advertising in iOS, you can refer to the documentation AdSupport.

    Regards,
    Kyle


    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Brian Kramer 66 Reputation points
    2022-10-26T17:30:11.953+00:00

    how do you perform equivalent for android?

    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.