# Mobile SDKs - @breakpilot/consent-sdk

## Übersicht

Die Mobile SDKs bieten native Integration für iOS, Android und Flutter.

## SDK Übersicht

| Platform | Sprache | Min Version | Status |
|----------|---------|-------------|--------|
| iOS | Swift 5.9+ | iOS 15.0+ | 📋 Spec |
| Android | Kotlin | API 26+ | 📋 Spec |
| Flutter | Dart 3.0+ | Flutter 3.16+ | 📋 Spec |

## Architektur

```
Mobile SDK
├── Core (shared)
│   ├── ConsentManager
│   ├── ConsentStorage (Keychain/SharedPrefs)
│   ├── API Client
│   └── Device Fingerprint
├── UI Components
│   ├── ConsentBanner
│   ├── ConsentSettings
│   └── ConsentGate
└── Platform-specific
    ├── iOS: SwiftUI + UIKit
    ├── Android: Jetpack Compose + XML
    └── Flutter: Widgets
```

## Feature-Parität mit Web SDK

| Feature | iOS | Android | Flutter |
|---------|-----|---------|---------|
| Consent Storage | Keychain | SharedPrefs | SecureStorage |
| Banner UI | SwiftUI | Compose | Widget |
| Settings Modal | ✓ | ✓ | ✓ |
| Category Control | ✓ | ✓ | ✓ |
| Vendor Control | ✓ | ✓ | ✓ |
| Offline Support | ✓ | ✓ | ✓ |
| Google Consent Mode | ✓ | ✓ | ✓ |
| ATT Integration | ✓ | - | ✓ (iOS) |
| TCF 2.2 | ✓ | ✓ | ✓ |

## Installation

### iOS (Swift Package Manager)

```swift
// Package.swift
dependencies: [
    .package(url: "https://github.com/breakpilot/consent-sdk-ios.git", from: "1.0.0")
]
```

### Android (Gradle)

```kotlin
// build.gradle.kts
dependencies {
    implementation("com.breakpilot:consent-sdk:1.0.0")
}
```

### Flutter

```yaml
# pubspec.yaml
dependencies:
  breakpilot_consent_sdk: ^1.0.0
```

## Quick Start

### iOS

```swift
import BreakpilotConsentSDK

// AppDelegate.swift
ConsentManager.shared.configure(
    apiEndpoint: "https://consent.example.com/api/v1",
    siteId: "site_abc123"
)

// ContentView.swift (SwiftUI)
struct ContentView: View {
    @EnvironmentObject var consent: ConsentManager

    var body: some View {
        VStack {
            if consent.hasConsent(.analytics) {
                AnalyticsView()
            }
        }
        .consentBanner()
    }
}
```

### Android

```kotlin
import com.breakpilot.consent.ConsentManager
import com.breakpilot.consent.ui.ConsentBanner

// Application.kt
class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        ConsentManager.configure(
            context = this,
            apiEndpoint = "https://consent.example.com/api/v1",
            siteId = "site_abc123"
        )
    }
}

// MainActivity.kt (Jetpack Compose)
@Composable
fun MainScreen() {
    val consent = ConsentManager.current

    if (consent.hasConsent(ConsentCategory.ANALYTICS)) {
        AnalyticsComponent()
    }

    ConsentBanner()
}
```

### Flutter

```dart
import 'package:breakpilot_consent_sdk/consent_sdk.dart';

// main.dart
void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await ConsentManager.configure(
    apiEndpoint: 'https://consent.example.com/api/v1',
    siteId: 'site_abc123',
  );

  runApp(MyApp());
}

// Widget
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ConsentProvider(
      child: MaterialApp(
        home: Scaffold(
          body: Column(
            children: [
              ConsentGate(
                category: ConsentCategory.analytics,
                child: AnalyticsWidget(),
                placeholder: Text('Analytics nicht aktiviert'),
              ),
            ],
          ),
          bottomSheet: ConsentBanner(),
        ),
      ),
    );
  }
}
```

## Dateien

Siehe die einzelnen Platform-SDKs:

- [iOS SDK Spec](./ios/README.md)
- [Android SDK Spec](./android/README.md)
- [Flutter SDK Spec](./flutter/README.md)
