Skip to content

A comprehensive Flutter application demonstrating iOS Live Activities integration with Dynamic Island support and Method Channels communication. This project showcases real-time delivery tracking with seamless iOS native integration.

Notifications You must be signed in to change notification settings

Raks-Javac/iOs-Live-Activity-Flutter-Implementation--Dynamic-Island-And-Method-Channels-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iOS Dynamic Island Live Activities - Flutter Implementation

A comprehensive Flutter application demonstrating iOS Live Activities integration with Dynamic Island support and Method Channels communication. This project showcases real-time delivery tracking with seamless iOS native integration.

� Screenshots

App Interface & Live Activities Demo

Main App Interface Live Activity Started Progress Updates

Dynamic Island Integration

Dynamic Island Compact View Dynamic Island Expanded View

Demo Video

Live Activity Demo

�📱 Features

  • Live Activities Integration: Real-time delivery progress updates on iOS Lock Screen
  • Dynamic Island Support: Interactive content in the iPhone 14 Pro+ Dynamic Island
  • Method Channels Communication: Bidirectional Flutter-iOS native communication
  • Real-time Updates: Progress tracking with live data synchronization
  • Clean Architecture: Well-structured codebase with proper separation of concerns
  • Professional UI: Modern Flutter interface with smooth animations

🚀 Demo

The app simulates a delivery tracking system with:

  • Progress bar showing delivery completion percentage
  • Real-time countdown timer (ETA)
  • Start/Stop Live Activity controls
  • Dynamic Island compact, expanded, and minimal views
  • Lock screen notifications with live updates

📋 Requirements

  • iOS: 16.1+ (for Live Activities support)
  • Device: Physical iPhone (Live Activities don't work in Simulator)
  • Dynamic Island: iPhone 14 Pro/Pro Max or newer (for Dynamic Island features)
  • Development:
    • Xcode 15+
    • Flutter 3.5+
    • Dart SDK 3.5+

🏗️ Project Structure

lib/
├── main.dart                    # Main app with delivery demo UI
├── model/
│   └── delivery.dart           # Delivery data model
└── service/
    └── delivery_service.dart   # Method channel service layer

ios/
├── Runner/
│   └── AppDelegate.swift       # Method channel handlers & Live Activity management
└── DeliveryLiveActivityE/      # Widget Extension Target
    ├── DeliveryLiveActivityE.swift           # Widget configuration
    ├── DeliveryLiveActivityELiveActivity.swift # Live Activity UI definitions
    └── DeliveryLiveActivityEBundle.swift     # Widget bundle

🛠️ Implementation Details

Flutter Layer

1. Data Model (lib/model/delivery.dart)

class Delivery {
  int minutesToDelivery;
  int progress;
  
  Map<String, dynamic> toJson() => {
    'minutesToDelivery': minutesToDelivery,
    'progress': progress,
  };
}

2. Service Layer (lib/service/delivery_service.dart)

  • Method Channel: com.example.ios_dybamic_island_flutter
  • Methods:
    • startNotifications: Initialize Live Activity
    • updateNotifications: Update progress in real-time
    • finishDeliveryNotification: Complete delivery
    • endNotifications: Cancel Live Activity

3. UI Layer (lib/main.dart)

  • Progress tracking with animated linear progress indicator
  • Timer-based updates (1-second intervals)
  • Start/Stop Live Activity controls
  • Real-time ETA display

iOS Native Layer

1. AppDelegate Integration (ios/Runner/AppDelegate.swift)

  • ActivityKit Framework: iOS 16.1+ Live Activities support
  • Method Channel Handler: Processes Flutter method calls
  • Activity Management: Start, update, and end Live Activities
  • Error Handling: Comprehensive error management

2. Live Activity Attributes (DeliveryLiveActivityEAttributes)

struct ContentState: Codable, Hashable {
    var progress: Double      // Delivery progress (0-100)
    var minutesToDelivery: Int // ETA in minutes
}

3. Dynamic Island UI (DeliveryLiveActivityELiveActivity.swift)

  • Compact Leading: "ETA" label
  • Compact Trailing: Progress percentage
  • Minimal View: Minutes remaining
  • Expanded View:
    • Leading region: "Leading" text
    • Trailing region: "Trailing" text
    • Bottom region: Full progress and ETA details

4. Lock Screen UI

  • Delivery progress percentage and ETA
  • Cyan background with black text
  • System action foreground color customization

🔧 Setup Instructions

1. Clone and Install Dependencies

git clone <repository-url>
cd ios_dybamic_island_flutter
flutter pub get

2. iOS Configuration

The Widget Extension target DeliveryLiveActivityE is already configured with:

  • Bundle ID: Properly set for App Store distribution
  • Deployment Target: iOS 16.1+
  • Capabilities: Live Activities enabled
  • Info.plist: Widget extension configuration

3. Build and Run

# Open iOS project
open ios/Runner.xcworkspace

# Run on physical device (required for Live Activities)
flutter run --debug

📱 Usage

  1. Launch App: Open on a physical iPhone with iOS 16.1+
  2. Start Activity: Tap "Start Live Activity" button
  3. Monitor Progress:
    • Watch the in-app progress bar
    • Check Dynamic Island (iPhone 14 Pro+)
    • View Lock Screen notification
  4. Real-time Updates: Progress updates every second
  5. Complete/Cancel: Use "End Live Activity" to stop

🎨 UI Components

Flutter App Interface

  • Progress Indicator: Animated linear progress bar
  • ETA Display: Real-time countdown
  • Control Buttons: Start/Stop with icons
  • Material Design: Modern UI with proper theming

Dynamic Island States

  • Minimal: Shows minutes remaining (e.g., "5mins")
  • Compact: ETA label + progress percentage
  • Expanded: Full delivery details with regions

Lock Screen Widget

  • Progress percentage and ETA
  • Consistent branding with app theme
  • Clear, readable information display

🔄 Method Channel Communication

Flutter → iOS Methods

Method Parameters Description
startNotifications {progress: Double, minutesToDelivery: Int} Initialize Live Activity
updateNotifications {progress: Double, minutesToDelivery: Int} Update activity state
finishDeliveryNotification None Complete delivery
endNotifications None Cancel activity

Error Handling

  • Platform exception catching
  • Invalid argument validation
  • Activity authorization checks
  • Graceful failure management

🧪 Testing

Live Activities Testing

  • Physical Device: Required for Live Activities
  • iOS Version: Verify iOS 16.1+ compatibility
  • Permissions: Check Live Activities are enabled in Settings
  • Background: Test updates when app is backgrounded

Dynamic Island Testing

  • Device: Requires iPhone 14 Pro/Pro Max or newer
  • States: Test minimal, compact, and expanded views
  • Interactions: Verify tap actions work correctly

📂 File Structure Details

Key Flutter Files

  • main.dart: Demo app with timer-based progress simulation
  • delivery.dart: Simple data model with JSON serialization
  • delivery_service.dart: Method channel abstraction layer

Key iOS Files

  • AppDelegate.swift: Method channel handling and Activity lifecycle
  • DeliveryLiveActivityELiveActivity.swift: Dynamic Island and Lock Screen UI
  • DeliveryLiveActivityE.swift: Widget timeline provider
  • DeliveryLiveActivityEBundle.swift: Widget bundle configuration

🚨 Important Notes

  1. Physical Device Required: Live Activities cannot be tested in iOS Simulator
  2. iOS Version: Minimum iOS 16.1 required for Live Activities
  3. Dynamic Island: Only available on iPhone 14 Pro models and newer
  4. Permissions: Users must grant Live Activities permission
  5. Background Updates: Activities can update even when app is closed
  6. Battery Impact: Live Activities are optimized for minimal battery usage

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test on physical iOS device
  5. Submit a pull request

📄 License

This project is available under the MIT License. See LICENSE file for details.

🙋‍♂️ Author

Created with ❤️ by Kudus Rufai


Note: This implementation serves as a foundation for integrating Live Activities in Flutter apps. Customize the UI, data models, and update frequencies according to your specific use case.

About

A comprehensive Flutter application demonstrating iOS Live Activities integration with Dynamic Island support and Method Channels communication. This project showcases real-time delivery tracking with seamless iOS native integration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published