SimpleApp
SimpleApp

Reputation: 546

iOS 14 Advertising tracking and Facebook SDK 13.2

Hi I was wondering what is the correct way to do this. Facebook documentation is kind of misleading. On Meta for developers website on the page titled Advertising Tracking Enabled they say you should use snippet

Settings.shared.isAdvertiserTrackingEnabled = true

But on the Get Started – iOS near the bottom of the document there is title Get Device Consent. There they also mention

Settings.shared.isAutoLogAppEventsEnabled = false
Settings.shared.isAdvertiserIDCollectionEnabled = true
  1. So should I also set these two to false if the user declines to share data?

  2. Also if I edit my Info.plist file and add lines

    FacebookAutoLogAppEventsEnabled FacebookAdvertiserIDCollectionEnabled

as the Getting started advises won't this be disabled every time I launch the app? I would be overwritten to true only one time when iOS native AppTracking dialog would show up and user would click Allow. Am I right?

Thanks

Upvotes: 2

Views: 2402

Answers (1)

Dundin
Dundin

Reputation: 11

I also exactly had the same question when I was integrating Facebook SDK. I ended up solving problem like this.

  1. initialize Facebook SDK with everything false
func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
... 
   // initialize Facebook SDK 
   ApplicationDelegate.shared.application(application, 
   didFinishLaunchingWithOptions: launchOptions)
   Settings.isAutoLogAppEventsEnabled = false
   Settings.setAdvertiserTrackingEnabled(false)
   Settings.isAdvertiserIDCollectionEnabled = false
} 

  1. Update Facebook SDK Setting after showing prompt
ATTrackingManager.requestTrackingAuthorization { [weak self] status in
   let isConsented = status == .authorized
   Settings.isAutoLogAppEventsEnabled = isConsented
   Settings.setAdvertiserTrackingEnabled(isConsented)
   Settings.isAdvertiserIDCollectionEnabled = isConsented
}
  1. Like you said prompt will appear only once, I check the authorization status every time when app becomes active. (I used didBecomeActiveNotification)
func checkATTStatus() {
        log.debug("current ATT status: \(ATTrackingManager.trackingAuthorizationStatus)")
        let isConsented = ATTrackingManager.trackingAuthorizationStatus == .authorized
        Settings.isAutoLogAppEventsEnabled = isConsented
        Settings.setAdvertiserTrackingEnabled(isConsented)
        Settings.isAdvertiserIDCollectionEnabled = isConsented
    }

I'm not 100% sure about this because I am still in testing stage (also Facebook's test event page is not working properly).

Please correct me if I am wrong.

Upvotes: 1

Related Questions