I use facebook ads in my app and I’m trying to implement the requestTrackingAuthorization,
I’m using the latest FB SDK "swift version" and I can not find the code snippet provided by FB guide
import FBSDKCoreKit
import FBAudienceNetwork
// Set the flag as true
FBAdSettings.setAdvertiserTrackingEnabled(true)
// Set the flag as false
FBAdSettings.setAdvertiserTrackingEnabled(false)
what I found instead is:
Settings.isAdvertiserIDCollectionEnabled = Bool
and I’m not sure if it the same or not, I saw this question and none of the solutions worked, my code ended up like this:
import FBAudienceNetwork
import FBSDKCoreKit
ATTrackingManager.requestTrackingAuthorization { status in
switch status {
case .notDetermined:
break
case .restricted:
Settings.isAdvertiserIDCollectionEnabled = false
Settings.isAutoLogAppEventsEnabled = false
case .denied:
Settings.isAdvertiserIDCollectionEnabled = false
Settings.isAutoLogAppEventsEnabled = false
case .authorized:
Settings.isAdvertiserIDCollectionEnabled = true
Settings.isAutoLogAppEventsEnabled = true
@unknown default:
Settings.isAdvertiserIDCollectionEnabled = false
Settings.isAutoLogAppEventsEnabled = false
}
}
so:
1- why I can not find setAdvertiserTrackingEnabled in FBAdSettings neither Settings
2- is isAdvertiserIDCollectionEnabled same as setAdvertiserTrackingEnabled ?
2
Answers
In Objective-C
In Swift
For anybody trying to implement this without the need of FBAudienceNetwork
isAdvertiserTrackingEnabled
is now insideshared
(swift) orsharedSettings
(objective c) ofFBSDKSettings
.In my case, in order to implement it on a react native app, I needed:
For swift it would be: