Welcome to the Axeptio iOS SDK Samples project. This repository provides a comprehensive guide on how to integrate the Axeptio iOS SDK into your mobile applications. It showcases two distinct modules: one for Swift using Swift Package Manager and one for Objective-C using CocoaPods. Below you'll find detailed instructions and code examples to help you integrate and configure the SDK within your iOS app.
- GitHub Access Token Documentation
- Requirements
- SDK Version
- Clone the repository
- Adding the SDK
- Initializing the SDK
- Widget Environment Configuration (SDK 2.1.0+)
- Cookie Duration Management (SDK 2.1.0+)
- Set up the SDK UI
- Additional Configuration: Show Popup When Returning from Background
- Axeptio SDK and App Tracking Transparency (ATT) Integration
- Responsibilities Mobile App vs SDK
- Retrieving Stored Consents
- Show Consent Popup on Demand
- Clearing Consent from
UserDefaults - Sharing Consent with Webviews
- TCF Vendor Management APIs
- Events Overview
- Event Descriptions
- Event source for KPI tracking
- Google Consent Mode v2 Integration with Axeptio SDK
- Google AdMob Integration with Axeptio SDK
When setting up your project or accessing certain GitHub services, you may be prompted to create a GitHub Access Token. However, it's important to note that generating a GitHub access token requires a valid GitHub account and the enabling of two-factor authentication (2FA).
As a developer, you may not be immediately aware of these requirements, which could lead to confusion or authentication issues. To streamline the process, we recommend reviewing the official GitHub Access Token Documentation for detailed instructions on how to create a token. This guide will also clarify prerequisites such as the need for a validated GitHub account and the necessity of enabling 2FA.
By following these instructions, you'll be able to generate a GitHub Access Token smoothly, reducing any onboarding friction and avoiding potential authentication problems down the line.
The Axeptio iOS SDK is distributed as a pre-compiled binary package, delivered as an XCFramework. It supports iOS versions >= 18.
This SDK follows Apple's iOS support lifecycle and only supports iOS versions that receive active security updates from Apple. As of September 2025, this includes iOS 18 and iOS 26. For the latest iOS support status, see: https://endoflife.date/ios
Before starting, make sure you have:
- iOS >= 18 (Apple-supported versions only)
- Xcode >= 16 (required for iOS 18 development)
- CocoaPods or Swift Package Manager for dependency management.
Note: Please be aware that it is not possible to test a custom banner without an active and valid Axeptio plan. A valid Axeptio plan is required to configure and preview custom consent banners during development.
Ensure the following keys are added to your Info.plist file to comply with app tracking and security policies:
<key>NSUserTrackingUsageDescription</key>
<string>Your data will be used to deliver personalized ads to you.</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>This sample app demonstrates the Axeptio iOS SDK. Current version: 2.1.2
For release notes and changelog, see:
To get started, clone the repository to your local machine:
git clone https://github.com/axeptio/sample-app-iosThe package can be added to your project using either CocoaPods or Swift Package Manager. Both dependency managers for iOS and are supported by the Axeptio SDK.
If your project uses CocoaPods, you can easily add the Axeptio SDK by following these steps:
- Xcode version 16 or later
- CocoaPods version compatible with XCFrameworks (latest version recommended), if you haven' already, install the latest version of CocoaPods
- Open your
Podfilein the root directory of your project
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '18.0'
use_frameworks!
target 'MyApp' do
pod 'AxeptioIOSSDK'
end- run the following command to install the dependency:
pod installTo integrate the Axeptio iOS SDK into your Xcode project using Swift Package Manager, follow these steps:
- Open your Xcode project.
- In the Project Navigator, select your project
- Under the PROJECT section, navigate to the Package Dependencies tab
- Click the + button to add a new package dependency
- In the search bar, paste the following package URL:
https://github.com/axeptio/axeptio-ios-sdk - Select the AxeptioIOSSDK package from the list of available packages
- Click Add Package.
- In the Choose Package Products screen, confirm the selection and click Add Package to complete the integration
To initialize the Axeptio SDK in your iOS project, import the AxeptioSDK module into your AppDelegate and initialize the SDK with the appropriate configuration.
In AppDelegate:
import UIKit
import AxeptioSDK
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Basic initialization
Axeptio.shared.initialize(
targetService: .publisherTcf, // or .brands
clientId: "your-client-id",
cookiesVersion: "your-cookies-version",
token: "your-token" // optional
)
return true
}
}With widget environment and cookie duration (SDK 2.1.0+):
Axeptio.shared.initialize(
targetService: .publisherTcf,
clientId: "your-client-id",
cookiesVersion: "your-cookies-version",
token: "your-token",
widgetType: .production, // .production, .staging, or .pr
widgetPR: nil, // PR hash when using .pr
cookiesDurationDays: 190, // Default: 190 days
shouldUpdateCookiesDuration: false // Default: false
)Then in your ViewController:
import UIKit
import AxeptioSDK
class ViewController: UIViewController, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Register the cell identifier for UserDefaultsCell
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UserDefaultsCell")
// Call setupUI to show the consent popup when appropriate
Axeptio.shared.setupUI()
}
// UITableViewDataSource methods
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "UserDefaultsCell", for: indexPath)
cell.textLabel?.text = "UserDefaults Button"
return cell
}
}#import "AppDelegate.h"
@import AxeptioSDK;
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
AxeptioService targetService = AxeptioServiceBrands; // or AxeptioServicePublisherTcf
// Basic initialization
[Axeptio.shared initializeWithTargetService:targetService
clientId:@"your-client-id"
cookiesVersion:@"your-cookies-version"];
// With token
[Axeptio.shared initializeWithTargetService:targetService
clientId:@"your-client-id"
cookiesVersion:@"your-cookies-version"
token:@"your-token"];
return YES;
}Note: SDK 2.1.0+ parameters (widgetType, widgetPR, cookiesDurationDays, shouldUpdateCookiesDuration) are available in the Swift API. For Objective-C projects, refer to the SDK's Objective-C bridging headers for the complete API.
The SDK supports three widget environments for development and testing:
- Production (
.production) - Default production widget - Staging (
.staging) - Staging environment for testing - PR (
.pr) - Test specific PR deployments
Production Environment (default):
Axeptio.shared.initialize(
targetService: .publisherTcf,
clientId: "your-client-id",
cookiesVersion: "your-version",
widgetType: .production
)Staging Environment:
Axeptio.shared.initialize(
targetService: .publisherTcf,
clientId: "your-client-id",
cookiesVersion: "your-version",
widgetType: .staging
)PR Environment (for testing specific changes):
Axeptio.shared.initialize(
targetService: .publisherTcf,
clientId: "your-client-id",
cookiesVersion: "your-version",
widgetType: .pr,
widgetPR: "59026e8d-b110-5452-afbe-6cb99c4e202a" // PR hash/version
)- Production: Live apps in production
- Staging: Pre-release testing and QA
- PR: Testing specific widget changes before they're merged to production
Control how long user consent choices persist.
cookiesDurationDays (default: 190 days)
- Sets the validity period for stored consent
- User will be prompted again when consent expires
shouldUpdateCookiesDuration (default: false)
- When
true: Duration end date is updated each time consent is saved - When
false: Duration end date is set only once at first consent
Default behavior (190 days, no updates):
Axeptio.shared.initialize(
targetService: .publisherTcf,
clientId: "your-client-id",
cookiesVersion: "your-version"
// cookiesDurationDays: 190 (default)
// shouldUpdateCookiesDuration: false (default)
)Custom duration (365 days):
Axeptio.shared.initialize(
targetService: .publisherTcf,
clientId: "your-client-id",
cookiesVersion: "your-version",
cookiesDurationDays: 365
)Update duration on each consent save:
Axeptio.shared.initialize(
targetService: .publisherTcf,
clientId: "your-client-id",
cookiesVersion: "your-version",
cookiesDurationDays: 190,
shouldUpdateCookiesDuration: true // Extends expiration on each consent save
)if let remainingDays = Axeptio.shared.getRemainingDaysForConsent() {
print("Consent expires in \(remainingDays) days")
} else {
print("No consent stored or consent has expired")
}[!IMPORTANT] The
setupUImethod should be invoked only from your main/entryUIViewController, typically once during the application launch. By calling this method, the consent notice and preference views will be displayed only if necessary and once the SDK is fully initialized.
In order to display the consent and preference views and interact with the user, ensure that the setupUI method is called from your main UIViewController. The consent popup and preferences management will be shown based on the SDK initialization and the user's consent requirements.
import UIKit
import AxeptioSDK
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Axeptio.shared.setupUI()
}
}
#import "ViewController.h"
@import AxeptioSDK;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize the UI elements required for consent display
[Axeptio.shared setupUI]; // Ensure that this is called from your main view controller
}
@endIf the consent popup is not appearing as expected, follow these steps to troubleshoot and resolve the issue:
Verify that the SDK is properly initialized in the AppDelegate.m file with the correct clientId and cookiesVersion
#import "AppDelegate.h"
@import AxeptioSDK;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
AxeptioService targetService = AxeptioServiceBrands; // Or use AxeptioServicePublisherTcf if required
// Initialize with the provided Client ID and Cookies Version
[Axeptio.shared initializeWithTargetService:targetService
clientId:@"<Your Client ID>"
cookiesVersion:@"<Your Cookies Version>"];
// Optional: Initialize with a Token from another device
[Axeptio.shared initializeWithTargetService:targetService
clientId:@"<Your Client ID>"
cookiesVersion:@"<Your Cookies Version>"
token:@"<Token>"];
return YES;
}
@endEnsure that the setupUI method is called from your main view controller (usually in viewDidLoad or a similar lifecycle method) to properly trigger the consent popup display.
#import "ViewController.h"
@import AxeptioSDK;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Call setupUI to show the consent popup when appropriate
[Axeptio.shared setupUI];
}
@endIf the consent popup is not showing, check if other views or modals are blocking it. Temporarily disable any other views that might interfere with the consent view to ensure it is not being hidden.
Add a logging statement to confirm that the SDK is triggering the popup:
[Axeptio.shared setupUI];
NSLog(@"Consent popup triggered successfully");If you are using event listeners to capture actions like the consent popup being closed, ensure that they are properly implemented and assigned.
AxeptioEventListener *axeptioEventListener = [[AxeptioEventListener alloc] init];
[axeptioEventListener setOnPopupClosedEvent:^{
NSLog(@"Consent popup closed by the user");
}];
[Axeptio.shared setEventListener:axeptioEventListener];Ensure that you are using the latest version of the Axeptio SDK. Outdated versions might contain bugs that affect the popup behavior.
To integrate the Axeptio SDK into a SwiftUI app, first, create a subclass of UIViewController to invoke the SDK's setupUI() method. This view controller will later be integrated into SwiftUI using UIViewControllerRepresentable.
import SwiftUI
import AxeptioSDK
// Custom UIViewController to handle the SDK UI
class AxeptioViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Call the setupUI method of the SDK to show the consent popup
Axeptio.shared.setupUI()
}
}Next, create a struct that conforms to the UIViewControllerRepresentable protocol to integrate the custom UIViewController into the SwiftUI view hierarchy. This struct will allow you to display the AxeptioViewController as a SwiftUI view.
// Struct to integrate AxeptioViewController into SwiftUI
struct AxeptioView: UIViewControllerRepresentable {
// Create the custom UIViewController
func makeUIViewController(context: Context) -> some UIViewController {
return AxeptioViewController()
}
// Required method, but not used in this case
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
}In SwiftUI, to properly set up the application and initialize the SDK, you'll need an entry point that implements the initialization logic in the AppDelegate. Use UIApplicationDelegateAdaptor to connect your AppDelegate to the SwiftUI app structure.
import SwiftUI
import AxeptioSDK
// AppDelegate that initializes the SDK
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
// Initialize the Axeptio SDK with the Client ID and cookies version
Axeptio.shared.initialize(clientId: "<Your Client ID>", cookiesVersion: "<Your Cookies Version>")
return true
}
}
// Main SwiftUI app structure
@main
struct YourSwiftUIApp: App {
// Bind the AppDelegate to the SwiftUI app structure
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
// Display the AxeptioView which contains the custom UIViewController
AxeptioView()
}
}
}By following these steps, the Axeptio SDK will be correctly integrated into a SwiftUI app, and the logic for displaying the consent popup will be handled inside viewDidAppear() within the custom UIViewController
The setDisplayPopUpOnEnterForeground property was added to control whether the consent popup should automatically appear when the app returns from the background.
You can set this property after the SDK has been initialized.
// Initialize the SDK as usual
AxeptioSDK.initialize(...)
// Configure the popup behavior when returning from background
AxeptioSDK.setDisplayPopUpOnEnterForeground(true)- The user is in the main app that includes the SDK.
- The user switches to another app → the main app goes to the background.
- The user returns to the main app → the app comes back to the foreground.
- If
setDisplayPopUpOnEnterForeground = true, the popup is displayed. - If
setDisplayPopUpOnEnterForeground = false, the popup is not displayed automatically.
Starting with iOS 14.5, Apple introduced the App Tracking Transparency (ATT) framework, which requires apps to request user consent before tracking their data across other apps and websites. The Axeptio SDK does not automatically handle ATT permission requests, and it is your responsibility to ask for user consent for tracking and manage how the Axeptio Consent Management Platform (CMP) interacts with the ATT permission.
This steps will show you how to:
- Request ATT permission.
- Display the Axeptio consent notice after the user has accepted the ATT permission.
- Handle cases where ATT permission is not requested or denied, and show the Axeptio CMP accordingly.
The Axeptio SDK does not ask for the user’s tracking permission using the ATT framework. It is your responsibility to request this permission, and the way in which the ATT framework and Axeptio CMP interact depends on your app's logic.
In apps targeting iOS 18.0 and above (which includes ATT framework), you must use the ATTrackingManager.requestTrackingAuthorization function to ask for tracking consent. Based on the user's response, you can choose to show the Axeptio consent notice.
- ATT Permission: Show the ATT permission dialog if the iOS version is 14 or later.
- Axeptio Consent Notice: Show the Axeptio consent notice if:
- iOS version is >= 15.
- The user accepts the ATT permission.
- Fallback: If the ATT permission cannot be displayed (e.g., restricted, iOS < 14, or user denied permission), you can still show the Axeptio CMP.
Below is the complete Swift code to handle the ATT permission and initialize the Axeptio CMP.
import UIKit
import AppTrackingTransparency
import AxeptioSDK
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Task {
await handleATTAndInitializeAxeptioCMP()
}
}
private func handleATTAndInitializeAxeptioCMP() async {
// ATT is always available since we require iOS 18+
let status = await ATTrackingManager.requestTrackingAuthorization()
let isAuthorized = (status == .authorized)
initializeAxeptioCMPUI(granted: isAuthorized)
}
private func initializeAxeptioCMPUI(granted: Bool) {
if granted {
// Initialize Axeptio CMP UI if ATT permission is granted
Axeptio.shared.setupUI()
} else {
// Handle case where user denies permission or ATT is restricted
Axeptio.shared.setUserDeniedTracking(denied: true)
}
}
}ATTrackingManager.requestTrackingAuthorization: Requests permission for tracking and returns the status.Axeptio.shared.setupUI(): Initializes and shows the consent notice once ATT permission is granted.- Fallback Handling: If ATT permission is denied or unavailable, the Axeptio CMP can still be initialized depending on your requirements (e.g., on iOS versions before 14).
- ATT framework is included in all supported iOS versions (18+).
- The app will request the ATT permission as it's always available.
- the user grants permission, you can show the Axeptio consent notice using
Axeptio.shared.setupUI().
For Objective-C, the implementation is quite similar. You’ll request ATT permission and initialize the Axeptio CMP based on the user's response.
#import <AppTrackingTransparency/AppTrackingTransparency.h>
@import AxeptioSDK;
@implementation ViewController
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// ATT is always available since we require iOS 18+
[self requestTrackingAuthorization];
}
- (void)requestTrackingAuthorization {
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
BOOL isAuthorized = (status == ATTrackingManagerAuthorizationStatusAuthorized);
[self initializeAxeptioCMPUI:isAuthorized];
}];
}
- (void)initializeAxeptioCMPUI:(BOOL)granted {
if (granted) {
// Initialize Axeptio CMP UI if ATT permission is granted
[Axeptio.shared setupUI];
} else {
// Handle case where user denies permission or ATT is restricted
[Axeptio.shared setUserDeniedTracking:false];
}
}
@endATTrackingManager.requestTrackingAuthorizationWithCompletionHandler: This method requests ATT permission and provides a callback with the status of the request.Axeptio.shared.setupUI(): This method initializes and shows the consent notice after the user has granted ATT permission.- Fallback Handling: Similar to the Swift implementation, you can still show the Axeptio CMP even if the ATT permission is not granted or not available.
- ATT Request Flow: The ATT request must be shown at an appropriate time in your app flow, typically when the user first opens the app or at a point where they can make an informed decision.
- iOS 18+: The ATT framework is included in all supported iOS versions (18+). The app will request ATT permission as it's always available.
- Data Collection Disclosure: Apple's App Store guidelines require you to disclose what data your app collects and how it uses it. Ensure your app’s privacy policy is up to date, and provide clear information on what data is being collected for tracking purposes.
The SDK introduces improved handling of the App Tracking Transparency (ATT) flow. This enhancement addresses an issue where, after modifying ATT permissions via iOS Settings, the “Reopen Cookie Banner” feature continued redirecting users to Settings instead of re-displaying the consent banner.
The SDK offers a new setup option to control whether the consent banner should be displayed even if ATT is denied on the device.
allowPopupDisplayWithRejectedDeviceTrackingPermissions: Bool- Default:
false - If set to
true, the SDK bypasses the ATT check and allows the consent popup to be displayed even if ATT tracking is denied at the OS level. This flag must be set during the Axeptio SDK setup phase.
To display the popup, the following conditions are now evaluated:
| Condition | Mandatory | Configurable |
|---|---|---|
| Network connectivity | Yes | No |
| Device ATT status is "Authorized" | No | Yes (via allowPopupDisplayWithRejectedDeviceTrackingPermissions) |
- Set to
truewhen ATT is denied on the device. - Automatically removed from local storage when ATT is later enabled, ensuring the consent banner can be displayed again.
If the user initially denies ATT and later re-enables it in iOS Settings, the app will now detect the change. Based on the allowPopupDisplayWithRejectedDeviceTrackingPermissions flag, it can choose to show the consent popup again — instead of redirecting the user to Settings.
The integration of the Axeptio SDK into your mobile application involves clear delineation of responsibilities between the mobile app and the SDK itself. Below are the distinct roles for each in handling user consent and tracking.
-
Managing App Tracking Transparency (ATT) Flow:
- The mobile app is responsible for initiating and managing the ATT authorization process on iOS 18 and later. This includes presenting the ATT request prompt at an appropriate time in the app's lifecycle.
-
Controlling the Display Sequence of ATT and CMP:
- The app must determine the appropriate sequence for displaying the ATT prompt and the Axeptio consent management platform (CMP). Specifically, the app should request ATT consent before invoking the Axeptio CMP.
-
Compliance with App Store Privacy Labels:
- The app must ensure accurate and up-to-date declarations of data collection practices according to Apple’s privacy label requirements, ensuring full transparency to users about data usage.
-
Event Handling and User Consent Updates:
- The app is responsible for handling SDK events such as user consent actions. Based on these events, the app must adjust its behavior accordingly, ensuring that user consent is respected across sessions.
-
Displaying the Consent Management Interface:
- The Axeptio SDK is responsible for rendering the user interface for the consent management platform (CMP) once triggered. It provides a customizable interface for users to give or revoke consent.
-
Storing and Managing User Consent Choices:
- The SDK securely stores and manages user consent choices, maintaining a persistent record that can be referenced throughout the app's lifecycle.
-
Sending Consent Status via APIs:
- The SDK facilitates communication of the user's consent status through APIs, allowing the app to be updated with the user’s preferences.
-
No Implicit Handling of ATT Permissions:
- The Axeptio SDK does not manage the App Tracking Transparency (ATT) permission flow. It is the host app's responsibility to request and handle ATT permissions explicitly before displaying the consent management interface. The SDK functions only once the ATT permission is granted (or bypassed due to platform restrictions).
- The Axeptio SDK does not manage the App Tracking Transparency (ATT) permission flow. It is the host app's responsibility to request and handle ATT permissions explicitly before displaying the consent management interface. The SDK functions only once the ATT permission is granted (or bypassed due to platform restrictions).
To retrieve user consent preferences stored by the Axeptio SDK, you can access the data stored in the UserDefaults. The SDK automatically stores consent information in UserDefaults, making it accessible for the app to retrieve whenever necessary.
In Swift, you can access the stored consents by using the UserDefaults API. This allows you to query specific consent keys, such as the one you previously stored when the user made their choices.
let consent = UserDefaults.standard.object(forKey: "Key")This will return the consent data associated with the provided key. Ensure that you know the specific key associated with the consent data you're trying to access.
In Objective-C, you can access the stored consents using the NSUserDefaults class. The following code demonstrates how to retrieve the consent data stored in NSUserDefaults:
id consent = [[NSUserDefaults standardUserDefaults] objectForKey:@"Key"];This will return the consent information associated with the specified key.
For a more detailed breakdown of how the Axeptio SDK handles stored consent values, including cookie management and other privacy-related data, please refer to the Axeptio SDK Documentation.
You can request the consent popup to be displayed programmatically at any point in your app’s lifecycle. This can be useful when you need to show the consent screen after a specific user action or event, rather than automatically when the app starts.
- This method will display the consent management platform (CMP) UI based on the user's current consent status.
- Make sure to trigger the consent popup at the appropriate moment to avoid interrupting the user experience.
- The consent popup can be triggered even after the app has been launched and after the consent has already been obtained, allowing you to ask for consent again if necessary.
To trigger the consent popup on demand in Swift, you can call the showConsentScreen() method on the Axeptio.shared instance:
Axeptio.shared.showConsentScreen()Similarly, in Objective-C, the same method can be invoked to show the consent screen on demand:
[Axeptio.shared showConsentScreen];A method is provided to clear the stored consent information from UserDefaults. This allows you to reset the user's consent status and remove any previously stored preferences.
- This method will remove the stored consent data, which may include preferences or other consent-related information stored in UserDefaults.
- It's useful for scenarios where the user needs to update their consent choices or when you want to reset consent state for any other reason.
- Once consent is cleared, the app may re-prompt the user for consent based on the current configuration or flow.
To clear the consent from UserDefaults in Swift, simply invoke the clearConsent() method on the shared Axeptio instance:
Axeptio.shared.clearConsent()Similarly, in Objective-C, you can call the clearConsent method on the shared Axeptio instance to remove the stored consent:
[Axeptio.shared clearConsent];This functionality is available only for the Publishers Service. It allows you to pass the consent token to webviews or external URLs to maintain consistency across platforms. You can append the axeptioToken to any URL to share the user’s consent status.
- Manual Approach: Developers can append the
axeptioTokenand query item manually to any URL using the standardURLComponentsmethod. - Automatic Approach: Use the
appendAxeptioTokenToURLfunction to automatically append the token to any URL. - Publisher's Service: This feature is available only for the Publishers service in Axeptio.
You can manually append the axeptioToken to any URL using the axeptioToken and keyAxeptioTokenQueryItem properties.
// Access the token and query item name
let axeptioToken = Axeptio.shared.axeptioToken
let keyAxeptioTokenQueryItem = Axeptio.shared.keyAxeptioTokenQueryItem
// Append the token to the URL
var urlComponents = URLComponents(string: "<Your URL>")
urlComponents?.queryItems = [
URLQueryItem(name: keyAxeptioTokenQueryItem, value: axeptioToken)
]
// Construct the updated URL with the appended token
let updatedURL = urlComponents?.url// Access the token and query item name
NSString *axeptioToken = [Axeptio.shared axeptioToken];
NSString *keyAxeptioTokenQueryItem = [Axeptio.shared keyAxeptioTokenQueryItem];
// Append the token to the URL
NSURLComponents *urlComponents = [[NSURLComponents alloc] initWithString:@"<Your URL>"];
urlComponents.queryItems = @[
[NSURLQueryItem queryItemWithName:keyAxeptioTokenQueryItem value:axeptioToken]
];
// Construct the updated URL with the appended token
NSURL *updatedURL = urlComponents.URL;Alternatively, you can use the appendAxeptioTokenToURL method to automatically append the token to the URL.
// Automatically append the consent token to the URL
let updatedURL = Axeptio.shared.appendAxeptioTokenToURL("<Your URL>", token: Axeptio.shared.axeptioToken)// Automatically append the consent token to the URL
NSURL *updatedURL = [Axeptio.shared appendAxeptioTokenToURL:@"<Your URL>" token:[Axeptio.shared axeptioToken]];The Axeptio SDK provides comprehensive APIs for managing vendor consent in TCF (Transparency and Consent Framework) mode. These APIs allow you to query individual vendor consent states, implement vendor-specific functionality, and maintain compliance with IAB TCF requirements.
Use these APIs when your app needs to:
- Query consent status for specific advertising vendors
- Implement vendor-specific features or ad serving logic
- Build custom vendor management UI components
- Debug consent collection issues in TCF mode
- Ensure compliance with specific vendor requirements
Retrieve a complete dictionary of all vendor consent states.
// Get all vendor consent states as a dictionary
let allVendorConsents = Axeptio.shared.getVendorConsents()
// Dictionary format: [vendorID: consentStatus]
// vendorID (Int): The IAB vendor ID
// consentStatus (Bool): true = consented, false = refused
for (vendorId, hasConsent) in allVendorConsents {
print("Vendor \(vendorId): \(hasConsent ? "Consented" : "Refused")")
}
// Example usage for ad serving logic
if let googleVendorConsent = allVendorConsents[755] { // Google's vendor ID
if googleVendorConsent {
// Enable Google ads
enableGoogleAds()
} else {
// Disable Google ads or show alternative content
disableGoogleAds()
}
}// Get all vendor consent states
NSDictionary<NSNumber *, NSNumber *> *allVendorConsents = [Axeptio.shared getVendorConsents];
// Iterate through all vendor consents
for (NSNumber *vendorId in allVendorConsents) {
BOOL hasConsent = [allVendorConsents[vendorId] boolValue];
NSLog(@"Vendor %@: %@", vendorId, hasConsent ? @"Consented" : @"Refused");
}
// Example usage for specific vendor
NSNumber *googleVendorId = @755; // Google's vendor ID
if (allVendorConsents[googleVendorId]) {
BOOL googleConsent = [allVendorConsents[googleVendorId] boolValue];
if (googleConsent) {
// Enable Google services
[self enableGoogleAds];
} else {
// Disable Google services
[self disableGoogleAds];
}
}Retrieve a list of vendor IDs that have been granted consent.
// Get array of vendor IDs with consent granted
let consentedVendors = Axeptio.shared.getConsentedVendors()
print("Number of consented vendors: \(consentedVendors.count)")
print("Consented vendor IDs: \(consentedVendors)")
// Check if specific vendors are consented
let criticalVendors = [755, 32, 76] // Example vendor IDs
let consentedCriticalVendors = criticalVendors.filter { consentedVendors.contains($0) }
if consentedCriticalVendors.count == criticalVendors.count {
print("All critical vendors have consent")
enablePremiumFeatures()
} else {
print("Missing consent from some critical vendors")
enableBasicFeatures()
}// Get array of consented vendor IDs
NSArray<NSNumber *> *consentedVendors = [Axeptio.shared getConsentedVendors];
NSLog(@"Number of consented vendors: %lu", (unsigned long)consentedVendors.count);
NSLog(@"Consented vendor IDs: %@", consentedVendors);
// Check for specific vendors
NSArray<NSNumber *> *criticalVendors = @[@755, @32, @76]; // Example vendor IDs
NSMutableArray<NSNumber *> *consentedCriticalVendors = [[NSMutableArray alloc] init];
for (NSNumber *vendorId in criticalVendors) {
if ([consentedVendors containsObject:vendorId]) {
[consentedCriticalVendors addObject:vendorId];
}
}
if (consentedCriticalVendors.count == criticalVendors.count) {
NSLog(@"All critical vendors have consent");
[self enablePremiumFeatures];
} else {
NSLog(@"Missing consent from some critical vendors");
[self enableBasicFeatures];
}Retrieve a list of vendor IDs that have been refused consent.
// Get array of vendor IDs with consent refused
let refusedVendors = Axeptio.shared.getRefusedVendors()
print("Number of refused vendors: \(refusedVendors.count)")
print("Refused vendor IDs: \(refusedVendors)")
// Disable services for refused vendors
for vendorId in refusedVendors {
disableVendorServices(vendorId: vendorId)
}
// Check if any essential vendors were refused
let essentialVendors = [755, 32] // Example essential vendor IDs
let refusedEssentialVendors = essentialVendors.filter { refusedVendors.contains($0) }
if !refusedEssentialVendors.isEmpty {
print("Essential vendors were refused: \(refusedEssentialVendors)")
showAlternativeContent()
}// Get array of refused vendor IDs
NSArray<NSNumber *> *refusedVendors = [Axeptio.shared getRefusedVendors];
NSLog(@"Number of refused vendors: %lu", (unsigned long)refusedVendors.count);
NSLog(@"Refused vendor IDs: %@", refusedVendors);
// Disable services for refused vendors
for (NSNumber *vendorId in refusedVendors) {
[self disableVendorServicesWithVendorId:[vendorId integerValue]];
}
// Check for essential vendors
NSArray<NSNumber *> *essentialVendors = @[@755, @32]; // Example essential vendor IDs
NSMutableArray<NSNumber *> *refusedEssentialVendors = [[NSMutableArray alloc] init];
for (NSNumber *vendorId in essentialVendors) {
if ([refusedVendors containsObject:vendorId]) {
[refusedEssentialVendors addObject:vendorId];
}
}
if (refusedEssentialVendors.count > 0) {
NSLog(@"Essential vendors were refused: %@", refusedEssentialVendors);
[self showAlternativeContent];
}Check consent status for a specific vendor ID.
// Check consent for specific vendor
let vendorId = 755 // Example: Google's vendor ID
let isConsented = Axeptio.shared.isVendorConsented(vendorId)
if isConsented {
print("Vendor \(vendorId) has consent")
enableVendorServices(vendorId: vendorId)
} else {
print("Vendor \(vendorId) was refused or not found")
disableVendorServices(vendorId: vendorId)
}
// Example usage in ad loading logic
func loadAdsForVendor(_ vendorId: Int) {
guard Axeptio.shared.isVendorConsented(vendorId) else {
print("Cannot load ads - vendor \(vendorId) consent denied")
return
}
// Proceed with ad loading
loadVendorAds(vendorId: vendorId)
}
// Check multiple vendors efficiently
let vendorsToCheck = [755, 32, 76, 81] // Multiple vendor IDs
for vendorId in vendorsToCheck {
let hasConsent = Axeptio.shared.isVendorConsented(vendorId)
print("Vendor \(vendorId): \(hasConsent ? "Consented" : "Refused")")
}// Check consent for specific vendor
NSInteger vendorId = 755; // Example: Google's vendor ID
BOOL isConsented = [Axeptio.shared isVendorConsented:vendorId];
if (isConsented) {
NSLog(@"Vendor %ld has consent", (long)vendorId);
[self enableVendorServicesWithVendorId:vendorId];
} else {
NSLog(@"Vendor %ld was refused or not found", (long)vendorId);
[self disableVendorServicesWithVendorId:vendorId];
}
// Example usage in ad loading logic
- (void)loadAdsForVendor:(NSInteger)vendorId {
if (![Axeptio.shared isVendorConsented:vendorId]) {
NSLog(@"Cannot load ads - vendor %ld consent denied", (long)vendorId);
return;
}
// Proceed with ad loading
[self loadVendorAdsWithVendorId:vendorId];
}
// Check multiple vendors
NSArray<NSNumber *> *vendorsToCheck = @[@755, @32, @76, @81]; // Multiple vendor IDs
for (NSNumber *vendorNumber in vendorsToCheck) {
NSInteger vendorId = [vendorNumber integerValue];
BOOL hasConsent = [Axeptio.shared isVendorConsented:vendorId];
NSLog(@"Vendor %ld: %@", (long)vendorId, hasConsent ? @"Consented" : @"Refused");
}Monitor vendor consent changes by combining the TCF APIs with event listeners:
// Set up event listener for consent changes
let eventListener = AxeptioEventListener()
eventListener.onConsentChanged = { [weak self] in
// Refresh vendor consent states when user changes preferences
self?.updateVendorBasedFeatures()
}
eventListener.onPopupClosedEvent = { [weak self] in
// Update UI or services after popup is closed
self?.refreshVendorStates()
}
Axeptio.shared.setEventListener(eventListener)
func updateVendorBasedFeatures() {
let consentedVendors = Axeptio.shared.getConsentedVendors()
// Update ad serving
updateAdConfiguration(consentedVendors: consentedVendors)
// Update analytics
updateAnalyticsVendors(consentedVendors: consentedVendors)
// Update UI elements
updateVendorBasedUI(consentedVendors: consentedVendors)
}// Set up event listener for consent changes
AxeptioEventListener *eventListener = [[AxeptioEventListener alloc] init];
[eventListener setOnConsentChanged:^{
// Refresh vendor consent states when user changes preferences
[self updateVendorBasedFeatures];
}];
[eventListener setOnPopupClosedEvent:^{
// Update UI or services after popup is closed
[self refreshVendorStates];
}];
[Axeptio.shared setEventListener:eventListener];
- (void)updateVendorBasedFeatures {
NSArray<NSNumber *> *consentedVendors = [Axeptio.shared getConsentedVendors];
// Update ad serving
[self updateAdConfigurationWithConsentedVendors:consentedVendors];
// Update analytics
[self updateAnalyticsVendorsWithConsentedVendors:consentedVendors];
// Update UI elements
[self updateVendorBasedUIWithConsentedVendors:consentedVendors];
}// Get detailed consent debug information
let debugInfo = Axeptio.shared.getConsentDebugInfo(preferenceKey: nil)
print("Consent Debug Info: \(debugInfo)")
// Get debug info for specific preference
let specificDebugInfo = Axeptio.shared.getConsentDebugInfo(preferenceKey: "IABTCF_VendorConsents")
print("Vendor Consents Debug: \(specificDebugInfo)")-
Vendor Count Mismatch: If the number of consented + refused vendors doesn't match the total, check for:
- Timing issues during consent processing
- Vendors that haven't been explicitly consented or refused
- Edge cases in vendor ID ranges
-
Missing Vendor Consent: If a vendor appears in
getVendorConsents()but not ingetConsentedVendors()orgetRefusedVendors():- Verify the vendor is part of your TCF configuration
- Check if consent was collected properly
- Review the TCF string data in UserDefaults
-
Performance Considerations:
- Cache vendor consent states when possible
- Use
isVendorConsented()for single vendor checks - Monitor consent changes with event listeners rather than polling
The vendor APIs work with standard IAB TCF data stored in UserDefaults:
// Access raw TCF data for advanced use cases
let tcfString = UserDefaults.standard.string(forKey: "IABTCF_TCString")
let vendorConsents = UserDefaults.standard.string(forKey: "IABTCF_VendorConsents")
let vendorLegitimateInterests = UserDefaults.standard.string(forKey: "IABTCF_VendorLegitimateInterests")
// The Axeptio APIs provide a higher-level interface to this data
// But you can access the raw data when needed for compliance reportingFor a complete implementation example with UI, debugging, and real-time monitoring, refer to the VendorConsentViewController.swift in the sample application.
The Axeptio SDK provides various events to notify your application when the user interacts with the consent management platform (CMP). By subscribing to these events, you can track consent status changes, consent popup visibility, and updates to Google Consent Mode. This section explains how to subscribe to and handle these events.
-
onPopupClosedEvent
This event is triggered when the consent popup is closed. You can use this event to perform actions after the consent popup is dismissed, such as storing consent status or updating app behavior based on user preferences. -
onConsentChanged
This event is triggered when the user gives or updates their consent. It allows you to handle the changes in user consent status, enabling you to take appropriate actions in your app. -
onGoogleConsentModeUpdate
This event is triggered when the Google Consent V2 status is updated. It allows you to react to changes in Google’s consent mode, which can affect tracking behaviors and user data processing preferences.
To handle events in Swift, you need to create an AxeptioEventListener instance and set event handlers for the desired events.
let axeptioEventListener = AxeptioEventListener()
// Handle popup closed event
axeptioEventListener.onPopupClosedEvent = {
// Actions to take when the consent popup is closed
// Retrieve consents from UserDefaults
// Check user preferences
// Run external processes or services based on user consents
}
// Handle consent changed event
axeptioEventListener.onConsentChanged = {
// Actions to take when the user consent status changes
// For example, trigger analytics, update UI, or change app behavior
}
// Handle Google Consent Mode update event
axeptioEventListener.onGoogleConsentModeUpdate = { consents in
// Actions to take when the Google Consent V2 status is updated
// Example: Update tracking configuration based on new consent mode status
}
Axeptio.shared.setEventListener(axeptioEventListener)For Objective-C, you can set up the AxeptioEventListener and subscribe to the events similarly.
AxeptioEventListener *axeptioEventListener = [[AxeptioEventListener alloc] init];
// Handle popup closed event
[axeptioEventListener setOnPopupClosedEvent:^{
// Actions to take when the consent popup is closed
// For example, store consent data or update app behavior
}];
// Handle consent changed event
[axeptioEventListener setOnConsentChanged:^{
// Actions to take when the user changes their consent
// Example: Update app functionality based on new consent status
}];
// Handle Google Consent Mode update event
[axeptioEventListener setOnGoogleConsentModeUpdate:^(GoogleConsentV2 *consents) {
// Actions to take when the Google Consent V2 status is updated
// Example: Adjust app tracking based on Google's updated consent mode
}];
[Axeptio.shared setEventListener:axeptioEventListener];- Description: This event is triggered when the consent popup is closed, either by the user granting or denying consent.
- Use Case: You can use this event to perform any actions after the user has seen or interacted with the consent popup, such as storing consent preferences, updating the UI, or triggering other processes based on user consent.
- Description: This event is triggered when a user’s consent changes. This could happen when a user grants or revokes consent, or updates their consent preferences.
- Use Case: You can use this event to track changes in user consent status, update app behavior based on new consent, or trigger specific services according to user preferences.
- Description: This event is triggered when the Google Consent Mode is updated. It provides information on how Google’s consent management framework has changed, such as when a user grants or withdraws consent for Google’s tracking technologies.
- Use Case: If your app integrates with Google services (e.g., Google Analytics or AdSense), you can use this event to update your tracking configuration or handle user data processing preferences according to Google’s consent mode.
Ensure that the consent popup is shown at an appropriate time to avoid interrupting the user experience. Use onPopupClosedEvent to determine when the user has seen or interacted with the consent popup, and avoid displaying it again unnecessarily.
Consider how the onConsentChanged event integrates into your app’s data processing workflow. Ensure that your app adapts its behavior according to the user’s preferences, such as enabling/disabling tracking or collecting personal data.
Use the onGoogleConsentModeUpdate event to monitor and respond to changes in Google’s consent status. This ensures that your app aligns with Google’s tracking and data collection policies based on the user’s consent.
By using AxeptioEventListener to listen for consent-related events, you can effectively manage user consent in your app, ensure compliance with privacy regulations, and improve the user experience. The SDK triggers these events based on user actions, so you can tailor your app’s functionality to respect the user’s consent preferences.
Integrating Axeptio into your iOS app includes managing user consent and cookie configuration events. To facilitate this, the Axeptio SDK triggers events that can be received by the host app. In this section, we'll explore how to receive and manage these events, including options for handling them via callbacks, publishers (using Combine), and delegates.
Some of the events Axeptio can send include:
-
app:cookies:ready: Indicates that the SDK is ready to manage consent for cookies, with a payload describing the current state (e.g., whether the CMP is visible or not).
Example payload:
{
"name": "app:cookies:ready",
"payload": "{\"showCmp\":false,\"reason\":\"The subscription does not allow the use of the SDK app mode\"}"
}These events are sent by the system to notify the host app that the user has interacted with the consent system or that an action related to consent has been completed.
To ensure proper KPI attribution in the back office, the App SDK now adds a specific event_source value when emitting TCF events from the WebView.
sdk-app-tcf→ Used when TCF is loaded in a mobile app (via WebView)sdk-web-tcf→ Used when TCF is loaded on a websitesdk-app-brands→ Used when the brands widget is loaded in an appsdk-web→ Used for regular brands on the web
This change ensures that events triggered from the App SDK are not incorrectly counted under Web KPIs.
No additional configuration is needed on your side if you are using the official SDK integration.
-->
This steps explains how to integrate Google Consent Mode v2 with the Axeptio SDK for managing user consent within your iOS application. It covers Firebase Analytics integration and provides code examples in both Swift and Objective-C.
Before starting the integration, ensure that:
-
Firebase Analytics is already added to your iOS project.
-
You have integrated the Axeptio SDK.
When user consent is collected through your Consent Management Platform (CMP), the Axeptio SDK triggers the necessary events and updates Firebase Analytics' consent states accordingly. This ensures that your app remains compliant with privacy regulations, especially when using services like Google Analytics or AdSense.
The integration allows the app to send consent preferences to both Google and Firebase systems. The Google Consent Mode is updated whenever the user modifies their consent preferences via the CMP, and this information is sent to Firebase for analytics tracking.
You need to listen for consent updates that come from the user interaction with the Axeptio SDK. These events will notify your application when a user's consent preferences change, especially regarding Google-related services like Google Analytics, Ad Storage, and others.
- The Axeptio SDK will automatically set the
IABTCF_EnableAdvertiserConsentModekey inUserDefaultstotrueonce the user has consented to advertising data collection.
The Google Consent Mode v2 categorizes consent statuses into different types like analyticsStorage, adStorage, and adPersonalization. You must map these consent statuses to the corresponding Firebase Analytics consent models. This ensures that Firebase respects the user’s privacy choices.
Once the Google Consent update is received from the Axeptio SDK, you must update the consent statuses in Firebase Analytics. Use the setConsent() method provided by Firebase to sync the user’s preferences.
The Axeptio SDK triggers events, allowing you to listen for changes in Google’s consent status. You can then map the updates and forward the consent status to Firebase Analytics.
// Set up the listener for Google Consent Mode updates
axeptioEventListener.onGoogleConsentModeUpdate = { consents in
// Mapping Axeptio consent statuses to Firebase Analytics consent types
Analytics.setConsent([
.analyticsStorage: consents.analyticsStorage == GoogleConsentStatus.granted ? ConsentStatus.granted : ConsentStatus.denied,
.adStorage: consents.adStorage == GoogleConsentStatus.denied ? ConsentStatus.granted : ConsentStatus.denied,
.adUserData: consents.adUserData == GoogleConsentStatus.denied ? ConsentStatus.granted : ConsentStatus.denied,
.adPersonalization: consents.adPersonalization == GoogleConsentStatus.denied ? ConsentStatus.granted : ConsentStatus.denied
])
}// Set up the listener for Google Consent Mode updates
[axeptioEventListener setOnGoogleConsentModeUpdate:^(GoogleConsentV2 *consents) {
// Mapping Axeptio consent statuses to Firebase Analytics consent types
[FIRAnalytics setConsent:@{
FIRConsentTypeAnalyticsStorage : [consents analyticsStorage] ? FIRConsentStatusGranted : FIRConsentStatusDenied,
FIRConsentTypeAdStorage : [consents adStorage] ? FIRConsentStatusGranted : FIRConsentStatusDenied,
FIRConsentTypeAdUserData : [consents adUserData] ? FIRConsentStatusGranted : FIRConsentStatusDenied,
FIRConsentTypeAdPersonalization : [consents adPersonalization] ? FIRConsentStatusGranted : FIRConsentStatusDenied
}];
}];- Analytics Storage: Consent for storing analytics data.
- Ad Storage: Consent for storing advertising-related data.
- Ad User Data: Consent for processing user data for ads.
- Ad Personalization: Consent for personalizing ads based on user data.
The GoogleConsentStatus enum defines whether consent is granted (.granted) or denied (.denied). This mapping ensures that Firebase Analytics is aware of user preferences for analytics and ads storage.
Ensure that the consent popup is shown at the appropriate time in your app's flow to avoid disrupting the user experience. The onPopupClosedEvent will notify you once the user has interacted with the consent popup, whether they grant or deny consent.
Track changes in user consent preferences with the onConsentChanged event. This allows your app to react dynamically to changes and adjust its data collection and processing accordingly.
The onGoogleConsentModeUpdate event informs you of changes in Google’s consent status. It is essential to ensure your app stays aligned with Google's tracking and data collection policies by updating Firebase Analytics’ consent preferences when this event occurs.
By integrating Google Consent Mode and Firebase Analytics, you are ensuring that your app complies with privacy regulations like the GDPR and CCPA. Both systems will respect the user’s preferences, ensuring data is only processed in accordance with the user’s consent.
Integrating Google Consent Mode v2 with the Axeptio SDK provides a seamless way to manage user consent preferences across both Google and Firebase systems. By properly handling consent updates and syncing with Firebase Analytics, your app will remain compliant with privacy laws while respecting user preferences. Use the provided event listener and consent mapping techniques to ensure that both Google and Firebase follow the same consent flow.
This steps explains how to integrate Google AdMob with the Axeptio SDK in your iOS app to manage user consent and comply with privacy regulations like GDPR and CCPA.
Before you begin, ensure that you have the following:
- Axeptio SDK integrated into your iOS project (refer to the Axeptio SDK Documentation).
- Google AdMob SDK integrated into your project (refer to the Google AdMob SDK Documentation).
- Firebase Analytics SDK integrated into your project (optional but recommended for tracking consent across both platforms).
Follow the instructions from the Google AdMob SDK Documentation to integrate AdMob into your app.
- Use CocoaPods to install AdMob:
pod 'Google-Mobile-Ads-SDK'To comply with user consent for ad serving, you must listen for consent updates through the Axeptio SDK and pass the consent status to AdMob.
When the user grants consent through the Axeptio SDK, the onGoogleConsentModeUpdate event will be triggered. You need to map the consent information to AdMob's consent system.
Axeptio provides a callback for consent updates which you can use to manage AdMob consent.
In your app, set up an event listener to capture the consent updates and propagate them to AdMob.
import GoogleMobileAds
import Axeptio
// Set up event listener
let axeptioEventListener = AxeptioEventListener()
axeptioEventListener.onGoogleConsentModeUpdate = { consents in
// Map Axeptio consent data to Google AdMob consent settings
let adConsent = GADConsentStatus.granted
if consents.adStorage == .denied {
adConsent = .denied
}
// Update AdMob consent information
GADMobileAds.sharedInstance().requestConfiguration.tag(forUnderAgeOfConsent: adConsent)
// Optionally, trigger other actions based on consent status
}
Axeptio.shared.setEventListener(axeptioEventListener)#import <GoogleMobileAds/GoogleMobileAds.h>
#import <Axeptio/Axeptio.h>
// Set up event listener
AxeptioEventListener *axeptioEventListener = [[AxeptioEventListener alloc] init];
[axeptioEventListener setOnGoogleConsentModeUpdate:^(GoogleConsentV2 *consents) {
// Map Axeptio consent data to Google AdMob consent settings
GADConsentStatus adConsent = GADConsentStatusGranted;
if (consents.adStorage == GoogleConsentStatusDenied) {
adConsent = GADConsentStatusDenied;
}
// Update AdMob consent information
[[GADMobileAds sharedInstance].requestConfiguration setTagForUnderAgeOfConsent:adConsent];
// Optionally, trigger other actions based on consent status
}];
[Axeptio.shared setEventListener:axeptioEventListener];Google AdMob provides a setting to handle whether personalized ads can be shown. You can use the onGoogleConsentModeUpdate event to manage this setting.
axeptioEventListener.onGoogleConsentModeUpdate = { consents in
// Check if personalized ads are allowed
let adPersonalizationConsent = consents.adPersonalization == .granted ? GADConsentStatusGranted : GADConsentStatusDenied
GADMobileAds.sharedInstance().requestConfiguration.tagForUnderAgeOfConsent(adPersonalizationConsent)
}[axeptioEventListener setOnGoogleConsentModeUpdate:^(GoogleConsentV2 *consents) {
// Check if personalized ads are allowed
GADConsentStatus adPersonalizationConsent = consents.adPersonalization == GoogleConsentStatusGranted ? GADConsentStatusGranted : GADConsentStatusDenied;
[[GADMobileAds sharedInstance].requestConfiguration setTagForUnderAgeOfConsent:adPersonalizationConsent];
}];If you're using Firebase Analytics to track user consent and activities, make sure you sync the Google Consent Mode with Firebase Analytics as well.
axeptioEventListener.onGoogleConsentModeUpdate = { consents in
Analytics.setConsent([
.analyticsStorage: consents.analyticsStorage == GoogleConsentStatus.granted ? ConsentStatus.granted : ConsentStatus.denied,
.adStorage: consents.adStorage == GoogleConsentStatus.denied ? ConsentStatus.granted : ConsentStatus.denied,
.adUserData: consents.adUserData == GoogleConsentStatus.denied ? ConsentStatus.granted : ConsentStatus.denied,
.adPersonalization: consents.adPersonalization == GoogleConsentStatus.denied ? ConsentStatus.granted : ConsentStatus.denied
])
}[axeptioEventListener setOnGoogleConsentModeUpdate:^(GoogleConsentV2 *consents) {
[FIRAnalytics setConsent:@{
FIRConsentTypeAnalyticsStorage : [consents analyticsStorage] ? FIRConsentStatusGranted : FIRConsentStatusDenied,
FIRConsentTypeAdStorage : [consents adStorage] ? FIRConsentStatusGranted : FIRConsentStatusDenied,
FIRConsentTypeAdUserData : [consents adUserData] ? FIRConsentStatusGranted : FIRConsentStatusDenied,
FIRConsentTypeAdPersonalization : [consents adPersonalization] ? FIRConsentStatusGranted : FIRConsentStatusDenied
}];
}];To ensure a smooth user experience and proper handling of consent status, you need to listen for consent changes and update AdMob settings accordingly.
- onPopupClosedEvent: Use this event to check the user's final consent choice.
- onConsentChanged: React to changes in user consent dynamically.
-
1. Popup Visibility Ensure that the consent popup is shown at the appropriate time in your app’s flow to avoid disrupting the user experience. The
onPopupClosedEventwill notify you once the user has interacted with the consent popup, whether they grant or deny consent. -
2. User Consent Flow Track changes in user consent preferences with the
onConsentChangedevent. This allows your app to react dynamically to changes and adjust its data collection and processing accordingly. -
3. Google Consent Mode Updates The
onGoogleConsentModeUpdateevent informs you of changes in Google’s consent status. It is essential to ensure your app stays aligned with Google’s tracking and data collection policies by updating AdMob’s consent preferences when this event occurs. -
4. Compliance with Privacy Regulations By integrating Google Consent Mode with the Axeptio SDK, you ensure that your app complies with privacy regulations like GDPR and CCPA. Both systems will respect the user’s preferences, ensuring data is only processed in accordance with the user’s consent.
By integrating Google AdMob with the Axeptio SDK, you enable your iOS app to manage user consent preferences across both systems seamlessly. This integration helps your app remain compliant with privacy laws while offering a personalized advertising experience. Use the provided event listeners and consent mapping techniques to ensure that user preferences are respected and stored correctly across both Google and Axeptio systems.
For more detailed information, you can visit the Axeptio documentation. We hope this guide helps you get started with the Axeptio iOS SDK. Good luck with your integration, and thank you for choosing Axeptio!