How to set SetAdvertiserTrackingEnabled with IronSource Unity?

3.1k Views Asked by At

I am implementing IronSource Facebook Audience Network mediation for a Unity game. In the docs it mentions setting SetAdvertiserTrackingEnabled in step 9. Sorry if this sounds stupid, but how do I do this if I'm using IronSource mediation and not the actual Audience Network SDK? Am I missing something here?

Ironsource integration doc: https://developers.ironsrc.com/ironsource-mobile/unity/facebook-mediation-guide/#step-9

2

There are 2 best solutions below

0
On BEST ANSWER

I am not really familiar with Objective-C but I did it according to FAN recommendations and added a C# script

using UnityEngine;
using System.Runtime.InteropServices;

#if UNITY_IOS

namespace AudienceNetwork
{
public static class AdSettings
{
[DllImport("__Internal")] 
private static extern void FBAdSettingsBridgeSetAdvertiserTrackingEnabled(bool advertiserTrackingEnabled);

public static void SetAdvertiserTrackingEnabled(bool advertiserTrackingEnabled)
{
FBAdSettingsBridgeSetAdvertiserTrackingEnabled(advertiserTrackingEnabled);
}
}
}

#endif

So after I can set the FAN flag with simple:

AudienceNetwork.AdSettings.SetAdvertiserTrackingEnabled(true);

With iOS Support Package, I did also a simple script to set it according to current IDFA/ATT settings in iOS Preferences (user can change it anytime).

using Unity.Advertisement.IosSupport;

public void iOS_SetFanFlag()
{
    bool setFanFlag;

    if ((int)ATTrackingStatusBinding.GetAuthorizationTrackingStatus() == 3)
       setFanFlag = true; //If==3, App is AUTHORIZED in settings
    else setFanFlag = false;  //DENIED, RESTRICTED or NOT DETERMINED (==2,1,0)
    
    AudienceNetwork.AdSettings.SetAdvertiserTrackingEnabled(setFanFlag);

}

Case is - this has to be set BEFORE initialization of IronSource and I am not sure how to check/test if it works correctly.

0
On

The easiest way is to do the following:

  1. Open the Assets/IronSource/Plugins/iOS/iOSBridge.m

  2. Import FBAdSettings

     #import "iOSBridge.h"
     #import <FBAudienceNetwork/FBAdSettings.h>
     #import <UIKit/UIKit.h>
    
  3. Call setAdvertiserTrackingEnabled before initlize IronSource

     - (instancetype)init {
         [FBAdSettings setAdvertiserTrackingEnabled:YES];
         if(self = [super init]){
             [IronSource setRewardedVideoDelegate:self];