Abdulaziz ALSIKH
Abdulaziz ALSIKH

Reputation: 11

Facebook SDK set advertiser tracking enabled is not exist iOS14

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 ?

Upvotes: 1

Views: 12473

Answers (2)

Alan Fernandez
Alan Fernandez

Reputation: 1

For anybody trying to implement this without the need of FBAudienceNetwork isAdvertiserTrackingEnabled is now inside shared (swift) or sharedSettings (objective c) of FBSDKSettings. In my case, in order to implement it on a react native app, I needed:

#import <FBSDKCoreKit/FBSDKSettings.h>
...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [FBSDKSettings.sharedSettings setAdvertiserTrackingEnabled:YES];
}

For swift it would be:

Settings.shared.isAdvertiserTrackingEnabled = true

Upvotes: 0

DJTano
DJTano

Reputation: 1404

  1. You have to import the FBAudienceNetwork library

In Objective-C

#include <FBAudienceNetwork/FBAdSettings.h>

In Swift

import FBAudienceNetwork
  1. They are not the same, according to the FB Documentation

isAdvertiserIDCollectionEnabled : Controls the access to IDFA If not explicitly set, the default is true

setAdvertiserTrackingEnabled : This allows you to inform Audience Network whether to use the data to deliver personalized ads

Upvotes: 2

Related Questions