Integrating Consent with Facebook Outside of TCF for Mobile App Consent

This article is related to users that need to action consent manually outside of the IAB TCF framework.

App Events

Delaying Automatic Event Collection

In order to meet compliance under GDPR to collect a user’s consent, you will need to delay the transmission of data from the SDK until a User has had the opportunity to go through an in-app consent flow. The Facebook SDK has to be v5.0 or higher.

Android

Set the AutoLogAppEventsEnabled flag to false in your AndroidManifest.xml file.

CODE
<application>
2
3  ...
4
5  <meta-data android:name='com.facebook.sdk.AutoLogAppEventsEnabled'
6
7           android:value='false'/>
8
9  ...
10
11</application>

Then, re-enable auto-logging after an end User provides consent by calling the setAutoLogAppEventsEnabled() method of the FacebookSdk class and set it to true.

CODE
FacebookSdk.setAutoLogAppEventsEnabled(true);

iOS

Open the application's .plist as code in Xcode and add the following XML to the property dictionary.

CODE
<key>FacebookAutoLogAppEventsEnabled</key><false/>

hen, re-enable auto-logging after an end-user provides consent by calling the setAutoLogAppEventsEnabledmethod of the FBSDKSettings class and set it to true for Swift or YES for Objective-C.

Swift

CODE
Settings.isAutoLogAppEventsEnabled = true

Objective-C

CODE
[FBSDKSettings setAutoLogAppEventsEnabled:YES];

Disabling Automatic Event Collection

You can also disable automatic event logging entirely to stop transmitting any data to Facebook when an app is opened.

Note:

If you leave automatic event logging disabled, you are no longer tracking app install and app launch events. Add additional code manually to log these events.

Android

Add the following line to your AndroidManifest.xml file

CODE
<application>
  ...
  <meta-data android:name='com.facebook.sdk.AutoLogAppEventsEnabled'
           android:value='false'/>
  ...
</application>

Open the application's .plist as code in Xcode and add the following XML to the property dictionary.

CODE
<key>FacebookAutoLogAppEventsEnabled</key>
<false/>

Disabling Automatic SDK Initialization

The Facebook SDK automatically initializes when the app is opened. When the SDK is initializing, it fetches app settings from Facebook. If you want to block all network requests to Facebook, you can disable automatic initialization.

Android

Set the AutoInitEnabled flag to false in your AndroidManifest.xml file.

CODE
<application>
2  ...
3  <meta-data android:name="com.facebook.sdk.AutoInitEnabled"
4           android:value="false"/>
5  ...
6</application>

Then, re-enable automatic initialization after an end user provides consent by calling the setAutoInitEnabled() method of the FacebookSdk class and setting it to true.

CODE
FacebookSdk.setAutoInitEnabled(true);
2FacebookSdk.fullyInitialize();

iOS

Open the application's .plist as code in Xcode and add the following XML to the property dictionary.

CODE
<key>FacebookAutoInitEnabled</key>
2<false/>

Then, re-enable automatic initialization after an end user provides consent by calling the setAutoInitEnabled method of the FBSDKSettings class and setting it to true for Swift or YES for Objective-C.

Swift

CODE
Settings.isAutoInitEnabled = true
2ApplicationDelegate.initializeSDK(nil)

Objective-C

CODE
[FBSDKSettings setAutoInitEnabled: YES ];
2[FBSDKApplicationDelegate initializeSDK:nil];

Limited Data Use (CCPA)

Tracking Options

Implementation

Facebook SDK for iOS (Objective C)

With Objective C, use FBSDKSettings setDataProcessingOptions.

To explicitly not enable Limited Data Use (LDU) mode, use:

CODE
[FBSDKSettings setDataProcessingOptions:@[]];

To enable LDU with geolocation, use:

CODE
[FBSDKSettings setDataProcessingOptions:@[@"LDU"] country:0 state:0];

To enable LDU for users and specify user geography, use:

CODE
[FBSDKSettings setDataProcessingOptions:@[@"LDU"] country:1 state:1000];

Facebook SDK for iOS (Swift)

With Swift, use setDataProcessingOptions.

To explicitly not enable LDU mode, use:

CODE
Settings.setDataProcessingOptions(modes: [])

To enable LDU for users with geolocation, use:

CODE
Settings.setDataProcessingOptions(modes: ["LDU"], country: 0, state: 0)

To enable LDU for users and specify user geography, use:

CODE
Settings.setDataProcessingOptions(modes: ["LDU"], country: 1, state: 1000)

Facebook SDK for Android

Use the setDataProcessingOptions method.

To explicitly not enable LDU mode, use:

CODE
FacebookSdk.setDataProcessingOptions(new String[] {});

To enable LDU for users with geolocation, use:

CODE
FacebookSdk.setDataProcessingOptions(new String[] {"LDU"}, 0, 0);

To enable LDU for users with a specified geography, use:

CODE
FacebookSdk.setDataProcessingOptions(new String[] {"LDU"}, 1, 1000);

Unity SDK

To explicitly not enable LDU mode, send an event with:

CODE
FB.Mobile.SetDataProcessingOptions(new string[] {});

To enable LDU for users with geolocation, send an event with:

CODE
FB.Mobile.SetDataProcessingOptions(new string[] {"LDU"}, 0, 0);

To enable LDU for users and specify user geography, send an event with:

CODE
FB.Mobile.SetDataProcessingOptions(new string[] {"LDU"}, 1, 1000);

Advertising Tracking (iOS Only)

Starting with iOS 14, you will need to set AdvertiserTrackingEnabled and log each time you give a device permission to share data with Facebook. Use the Advertiser Tracking Enabled parameter to indicate whether Facebook should use event data for ads in line with your own legal obligations, platform terms and commitments you’ve made to your users.

If a device provides consent, call the setAdvertiserTrackingEnabled method of the FBSDKSettings class and set it to YES for Objective-C or true for Swift. If a device does not allow tracking, set setAdvertiserTrackingEnabled to NO for Objective-C or false for Swift. The method will return a boolean value to indicate whether the method is set successfully or not.

Tracking Options

Implementation

Allow Tracking

Objective-C:

CODE
// Set AdvertiserTrackingEnabled to YES if a device provides consent
[FBSDKSettings setAdvertiserTrackingEnabled:YES];

Swift:

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

C#:

CODE
// Set AdvertiserTrackingEnabled to true if a device provides consent
FB.Mobile.SetAdvertiserTrackingEnabled(true)

Do Not Track

Objective-C:

CODE
// Set AdvertiserTrackingEnabled to NO if a device does not provide consent
[FBSDKSettings setAdvertiserTrackingEnabled:NO];

Swift

CODE
// Set AdvertiserTrackingEnabled to false if a device does not provide consent
Settings.setAdvertiserTrackingEnabled(false)

C#:

CODE
// Set AdvertiserTrackingEnabled to false if a device does not provide consent
FB.Mobile.SetAdvertiserTrackingEnabled(false)