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/
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)
Now the class for Facebook(Meta) Advertising is changed from Settings
class to FBAdSettings
class in new updated versions of the Facebook(Meta) and also there is a new library is defined for it which FBAudienceNetwork
.
So to resolve this please install FBAudienceNetwork
first and then write:-
FBAdSettings.setAdvertiserTrackingEnabled(true)
If anyone is getting issues with Facebook(Meta) updated SDK code so some of the changes I am listing here, please check those:-
1). Instance member 'logEvent' cannot be used on type 'AppEvents'; did you mean to use a value of this type instead?
Solution :- Instead of using AppEvents.logEvent
use AppEvents.shared.logEvent
.
2). Cannot convert value of type 'String' to expected dictionary key type 'AppEvents.ParameterName'
Solution :- Instead of using AppEvents.ParameterName.registrationMethod.rawValue
as a parameter key use AppEvents.ParameterName.registrationMethod
. Means remove "rawValue" from the parameter keys of parameters provided by Facebook.
Along with this if you get error Cannot convert '[String : Any]' to expected argument type '[AppEvents.ParameterName : Any]'
, then please remove .rawValue
from every key of the dictionary declared for parameters which you want to share with Facebook(Meta) SDK AppEvent.
3). Instance member 'activateApp' cannot be used on type 'AppEvents'; did you mean to use a value of this type instead?
Solution:- Just add "Shared" before "activateApp()". Like,
AppEvents.shared.activateApp()
4). Instance member 'logPurchase' cannot be used on type 'AppEvents'; did you mean to use a value of this type instead?
Solution:- There is a change in log purchase event which is AppEvents class is now singleton class in Facebook(Meta) SDK so we have to add "Shared" with every function we want to call from Facebook(Meta) SDK class so, log purchase method will be called as:-
AppEvents.shared.logPurchase(amount: amount, currency: “GBP”)
Note:- From Facebook(Meta) SDK version 13.0 it is mandatory to add client_token in info.plist with appId and AppName, because it will be required for all calls to the Graph API.
//Code for info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbAPP-ID</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>APP-ID</string>
<key>FacebookClientToken</key>
<string>CLIENT-TOKEN</string>
<key>FacebookDisplayName</key>
<string>APP-NAME</string>
I Hope this will help !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With