Skip to content

feat: derive Google Ads consent from a TCF CMP [LIN-2078] - #39

Open
Shofiya2003 wants to merge 1 commit into
mainfrom
lin-2078-flutter-tcf-consent
Open

feat: derive Google Ads consent from a TCF CMP [LIN-2078]#39
Shofiya2003 wants to merge 1 commit into
mainfrom
lin-2078-flutter-tcf-consent

Conversation

@Shofiya2003

@Shofiya2003 Shofiya2003 commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Adds enableTCFConsentCollection to the Flutter SDK, matching the native iOS SDK and the React Native wrapper. Apps using an IAB TCF v2.2/v2.3 Consent Management Platform can let the SDK read the CMP's IABTCF_* keys instead of mirroring every consent change through setConsent by hand. Anything set explicitly with setConsent still wins, per signal, so an app can let the CMP supply most of the state and override one field.

await LinkRunner().enableTCFConsentCollection(true);
await LinkRunner().init('YOUR_PROJECT_TOKEN');

iOS only, and why the gate is in Dart

The native Android SDK has no TCF support, so the Android side of the plugin has no handler for this method. Reaching it would throw MissingPluginException in the caller's app, which the existing on PlatformException catch would not swallow. The Dart layer returns early on any non-iOS platform, which is what the React Native wrapper does with Platform.OS. A no-op Android handler was the alternative, but it would imply Android support that does not exist.

The iOS handler is deliberately not gated on isInitialized. The flag is meant to be set before init so the first payload already carries the CMP's values, and LinkrunnerKit resolves consent per payload rather than snapshotting it at init.

Changes

  • lib/linkrunner.dart: public enableTCFConsentCollection([bool enabled = true]) with the platform gate
  • lib/linkrunner_native_bridge.dart: method channel call
  • ios/Classes/SwiftLinkrunnerPlugin.swift: enableTCFConsentCollection case and handler
  • test/tcf_consent_collection_test.dart: covers the forwarded flag, the default, the disable path, and that Android sends nothing
  • Version 4.2.0 across pubspec.yaml, the podspec and the hardcoded packageVersion

Testing

flutter test passes (6 tests). flutter analyze reports only the 15 pre-existing constant_identifier_names infos in lr_capture_payment.dart and lr_consent.dart, none from the changed files.

Follow-up

The public docs list Flutter as setConsent only. That page should be updated once 4.2.0 is published to pub.dev.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added optional iOS support for collecting Google Ads consent from IAB TCF v2.2/v2.3 consent management platforms.
    • Added an API to enable or disable TCF consent collection, with collection enabled by default.
    • Explicit consent settings continue to take precedence over TCF-derived consent.
  • Bug Fixes

    • Non-iOS platforms now safely ignore the iOS-only consent collection setting.
  • Documentation

    • Added release notes for version 4.2.0.

Adds enableTCFConsentCollection to the Flutter SDK, matching the native iOS SDK
and the React Native wrapper. Apps using an IAB TCF v2.2/v2.3 Consent Management
Platform can now let the SDK read the CMP's IABTCF_* keys instead of mirroring
every consent change through setConsent by hand.

Anything set explicitly with setConsent still wins, per signal, so an app can let
the CMP supply most of the state and override one field.

iOS only. The native Android SDK has no TCF support, so the Android side of the
plugin has no handler for this method and reaching it would throw
MissingPluginException in the caller's app. The Dart layer returns early on any
non-iOS platform, which is what the React Native wrapper does with Platform.OS,
rather than adding a no-op handler that would imply Android support.

The iOS handler is deliberately not gated on isInitialized: the flag is meant to
be set before init so the first payload already carries the CMP's values, and the
native SDK resolves consent per payload rather than snapshotting it.

Version 4.2.0 (new public API), with pubspec.yaml, the podspec and the hardcoded
packageVersion kept in step.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0082ec12-ff9d-4916-bc5d-378ce03b98da

📥 Commits

Reviewing files that changed from the base of the PR and between 993ba23 and 2e99a5a.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • ios/Classes/SwiftLinkrunnerPlugin.swift
  • ios/linkrunner.podspec
  • lib/linkrunner.dart
  • lib/linkrunner_native_bridge.dart
  • pubspec.yaml
  • test/tcf_consent_collection_test.dart

📝 Walkthrough

Walkthrough

Adds an opt-in iOS TCF consent-collection API, forwards the setting through Flutter and the native method channel, validates native arguments, adds platform-specific tests, and updates package versions and changelog documentation.

Changes

TCF consent collection

Layer / File(s) Summary
Dart API and method-channel bridge
lib/linkrunner.dart, lib/linkrunner_native_bridge.dart, test/tcf_consent_collection_test.dart
Adds the public API, restricts native calls to iOS, forwards the enabled state, logs bridge outcomes, and tests enabled, default, disabled, and Android no-op behavior.
iOS method-channel SDK wiring
ios/Classes/SwiftLinkrunnerPlugin.swift
Handles enableTCFConsentCollection, rejects invalid or missing boolean arguments, and invokes the SDK without requiring initialization.
Version and changelog updates
pubspec.yaml, ios/linkrunner.podspec, CHANGELOG.md
Bumps package versions to 4.2.0 and documents TCF consent collection behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FlutterApp
  participant LinkRunner
  participant MethodChannel
  participant SwiftLinkrunnerPlugin
  participant LinkrunnerSDK

  FlutterApp->>LinkRunner: enableTCFConsentCollection(enabled)
  LinkRunner->>MethodChannel: Invoke native method
  MethodChannel->>SwiftLinkrunnerPlugin: Pass enabled argument
  SwiftLinkrunnerPlugin->>LinkrunnerSDK: Enable or disable TCF collection
  SwiftLinkrunnerPlugin-->>FlutterApp: Return success
Loading

Suggested reviewers: chetanbhosale

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding TCF CMP-based Google Ads consent derivation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lin-2078-flutter-tcf-consent

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant