Issue
I am in the process of updating my app and with Apple changing the Privacy requirements(I do like this), I believe I need to add App tracking permissions into my app. This is because I use a webview that goes to a third party website that grabs the device IP address and puts a cookie in the view. I am struggling with how to do this in Uno. I know it uses the Xamarin platform underneath- but I am not really understanding how to do this. There are no ads anywhere in the app. I have only been able to find a few examples- so what I am putting below is based off of them.
I see that I need to add NSUserTrackingUsageDescription to my info.plist. I see that I need to use AttTrackingManager. So- first- how do I import AttTrackingManager into my project in Visual Studio? I checked in Nuget and did not see it. From what I can tell- I need to check for the value in my OnLoaded, and depending on the value I need to either zero out the device ID or do nothing. Also- do I need to check this value anytime my app accesses the webview- User goes to a different page in the app and comes back to the webview(I would think I need to check it)?
Are my statements above correct? Is the best way to implement the parts in the code using something like this:
#if __IOS__
using AttTrackingManager?
#endif
private void OnLoaded(object sender, RoutedEventArgs e)
{
#if __IOS__
try
{
ATTrackingManager.RequestTrackingAuthorization((status) => {
if (status == ATTrackingManagerAuthorizationStatus.Authorized)
{
//Proceed as I currently due
}
else if (status == ATTrackingManagerAuthorizationStatus.Denied)
{
//Not sure what to do here
}
});
}
catch (Exception e)
{
}
#endif
}
Solution
Your approach seems sound. Let me clarify some of your interrogations.
1- You are looking for a nuget but you don't need to. ATTrackingManager is part of the iOS SDK (in the AppTrackingTransparency namespace), as long as you target iOS14.5 as a compilation target you will have access to it. The Xamarin.iOS bits are built-in VisualStudio, so just make sure your version is high enough.
2- You need to add a NSUserTrackingUsageDescription in info.plist as you mentioned. This will be displayed in the popup.
3- In your code, to prompt the user with the native popup you need something like this.
ATTrackingManager.RequestTrackingAuthorization(( status) => {
if(status == ATTrackingManagerAuthorizationStatus.Authorized)
{
// Do something if needed.
}
else if (status == ATTrackingManagerAuthorizationStatus.Denied)
{
// Do something if needed.
}
});
Depending on why you are required to show the popup you probably don't even need to do anything with the result.
This AppTransparency permission let's you retrieve a IDFA, which is generally used to track users accross different apps or services. Unless the permission is Authorized, the IDFA will always be returned as a series of zeros.
My guess is most people will request this permission to comply with an advertising sdk or a facebook sdk or a social login sdk. Regardless if the user authrizes tracking or not should be transparent to the developer, the SDK will keep working but will acquire IDFAs with zeros instead of real ones.
When to request the permission is up to you. You can do it as early as possible or wait a little until the user is engaged with the app and sees value in the tracking. Just know that while the authorization is undefined, the IDFA will be zeros just as if the permission was denied.
Answered By - matfillion
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.