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.
<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.
FacebookSdk.setAutoLogAppEventsEnabled(true);
iOS
Open the application's .plist as code in Xcode and add the following XML to the property dictionary.
<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
Settings.isAutoLogAppEventsEnabled = true
Objective-C
[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.
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
<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.
<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.
<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.
FacebookSdk.setAutoInitEnabled(true);
2FacebookSdk.fullyInitialize();
iOS
Open the application's .plist as code in Xcode and add the following XML to the property dictionary.
<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
Settings.isAutoInitEnabled = true
2ApplicationDelegate.initializeSDK(nil)
Objective-C
[FBSDKSettings setAutoInitEnabled: YES ];
2[FBSDKApplicationDelegate initializeSDK:nil];
Limited Data Use (CCPA)
|
Tracking Options |
Implementation |
|---|---|
|
Facebook SDK for iOS (Objective C) |
With Objective C, use To explicitly not enable Limited Data Use (LDU) mode, use:
CODE
To enable LDU with geolocation, use:
CODE
To enable LDU for users and specify user geography, use:
CODE
|
|
Facebook SDK for iOS (Swift) |
With Swift, use To explicitly not enable LDU mode, use:
CODE
To enable LDU for users with geolocation, use:
CODE
To enable LDU for users and specify user geography, use:
CODE
|
|
Facebook SDK for Android |
Use the To explicitly not enable LDU mode, use:
CODE
To enable LDU for users with geolocation, use:
CODE
To enable LDU for users with a specified geography, use:
CODE
|
|
Unity SDK |
To explicitly not enable LDU mode, send an event with:
CODE
To enable LDU for users with geolocation, send an event with:
CODE
To enable LDU for users and specify user geography, send an event with:
CODE
|
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
Swift:
CODE
C#:
CODE
|
|
Do Not Track |
Objective-C:
CODE
Swift
CODE
C#:
CODE
|