question

BrianKramer-3128 avatar image
0 Votes"
BrianKramer-3128 asked KyleWang-MSFT answered

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

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

Is there examples or library?

dotnet-xamarin
· 2
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.

@BrianKramer-3128 Not clear your need, can you elaborate on what you are trying to achieve?

0 Votes 0 ·

For ios14.5. So admob can deliver personalized ads. I believe we need to request permission to access the advertising identifier.

0 Votes 0 ·

1 Answer

KyleWang-MSFT avatar image
0 Votes"
KyleWang-MSFT answered

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.

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.