swiftfacebookfacebook-audience-network

setAdvertiserTrackingEnabled is not found in Settings Class of FBSDK?


I am trying to make setAdvertiserTrackingEnabled to true as mentioned in Facebook Advertiser Tracking Enabled like this

// Set AdvertiserTrackingEnabled to true if a device provides consent
Settings.setAdvertiserTrackingEnabled(true)

but I cannot found this method in the FBSDKSettings class.

Error by Xcode

{Type 'Settings' has no member 'setAdvertiserTrackingEnabled'}

Facebook Doc Link https://developers.facebook.com/docs/app-events/guides/advertising-tracking-enabled/


Solution

  • The Facebook documentation is not yet updated to match the new changes in version 11 (you can notice the second image in the iOS App Event setup contains a screenshot of version 5.10.0)

    If you installed FBAudienceNetwork using cocoapods in Xcode, you can inspect and deduce that Settings class was renamed to FBAdSettings. To validate this, you can find the method you mentioned in the following directory: Pods > Pods > FBAudienceNetwork > FBAdSettings.h > +setAdvertiserTrackingEnabled

    Hence, you should change your code to the following:

    FBAdSettings.setAdvertiserTrackingEnabled(true)