biscotti_cmp 1.1.3 copy "biscotti_cmp: ^1.1.3" to clipboard
biscotti_cmp: ^1.1.3 copied to clipboard

Biscotti CMP Flutter SDK — native consent management with IAB TCF 2.3 compliance.

example/README.md

Biscotti CMP — Flutter integration example #

Minimal, verified integration of the biscotti_cmp package. The API names below match the package source 1:1 (lib/src/biscotti_cmp.dart).

Requirements: Flutter ≥ 3.16 · Dart ≥ 3.2 · iOS deployment target ≥ 12.0 (App Tracking Transparency features require iOS 14+) · Android minSdk 21.

This is the Flutter SDK (self-contained Dart plugin). Do not also add the native iOS Swift package (BiscottiCMP / SPM) or pod 'BiscottiCMP' — the Flutter package brings its own iOS/Android platform side.

1. Add the package #

flutter pub add biscotti_cmp
# pubspec.yaml
dependencies:
  biscotti_cmp: ^1.1.3

2. iOS setup #

cd ios && pod install

In ios/Podfile make sure the platform line is present:

platform :ios, '12.0'

The SDK integrates App Tracking Transparency. If you request tracking authorization (typical when you collect marketing consent), you must add the usage description to ios/Runner/Info.plist — otherwise the app crashes when ATT is requested:

<key>NSUserTrackingUsageDescription</key>
<string>We ask permission to personalize content and ads.</string>

3. Initialize #

import 'package:flutter/material.dart';
import 'package:biscotti_cmp/biscotti_cmp.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await BiscottiCMP.instance.configure(
    websiteId: 'YOUR_WEBSITE_ID',   // from the Biscotti CMP dashboard
    // apiKey: 'OPTIONAL',          // only needed for server-side consent sync
  );

  runApp(const MyApp());
}

showConsentDialog needs a BuildContext:

WidgetsBinding.instance.addPostFrameCallback((_) {
  BiscottiCMP.instance.showConsentDialog(context);
});

4a. Temporarily disable IAB TCF for the mobile app #

Create a separate Mobile App property in the Biscotti dashboard, disable IAB TCF on that child property, and use its own website ID in configure(). The SDK then keeps category consent active but generates no TC String and removes all IABTCF_* storage keys. Do not reuse the website ID of a TCF-enabled web banner.

BiscottiCMP.instance.registerSDK(
  name: 'firebase_analytics',
  category: ConsentCategory.analytics, // essential | functional | analytics | marketing
  initializer: () {
    // Runs only after the user grants the "analytics" category.
  },
);
final marketingOk = BiscottiCMP.instance.hasConsent(ConsentCategory.marketing); // sync
final token = BiscottiCMP.instance.getConsentToken();                            // sync, for server verification

// React to changes:
BiscottiCMP.instance.onConsentChanged.listen((state) {
  // state.categories, state.tcString, ...
});

Optional — request ATT explicitly (iOS only; returns null on Android):

final status = await ATTService().requestTracking();

API reference (as implemented) #

Member Signature Notes
BiscottiCMP.instance singleton entry point
configure(...) Future<void> configure({required String websiteId, String? apiKey}) async
showConsentDialog(context) Future<void> needs BuildContext
hasConsent(category) bool synchronous
getConsentState() ConsentState? synchronous
getConsentToken() String? synchronous
registerSDK(...) void registerSDK({required String name, required ConsentCategory category, required VoidCallback initializer, VoidCallback? teardown}) consent-gated init
onConsentChanged Stream<ConsentState> reactive
getATTStatus() Future<ATTStatus?> iOS only

ConsentCategory: essential, functional, analytics, marketing.

0
likes
150
points
208
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Biscotti CMP Flutter SDK — native consent management with IAB TCF 2.3 compliance.

Repository (GitHub)
View/report issues

Topics

#consent #gdpr #privacy #tcf #cmp

License

MIT (license)

Dependencies

flutter

More

Packages that depend on biscotti_cmp

Packages that implement biscotti_cmp