feat: expose BGHealthResearchTask through public Dart API#664
Closed
jduhamel wants to merge 5 commits intofluttercommunity:mainfrom
Closed
feat: expose BGHealthResearchTask through public Dart API#664jduhamel wants to merge 5 commits intofluttercommunity:mainfrom
jduhamel wants to merge 5 commits intofluttercommunity:mainfrom
Conversation
Add support for BGHealthResearchTask, a background task type specifically designed for HealthKit research operations. Changes: - Added backgroundHealthResearchTask case to BackgroundMode enum - Implemented handleHealthResearchTask handler for task execution - Added registerHealthResearchTask @objc method for AppDelegate registration - Added scheduleHealthResearchTask for task scheduling - Added HealthResearchTaskRequest to Pigeon API - Updated generated Pigeon files for iOS, Android, and Dart Requirements: - iOS 15.0 or later - com.apple.developer.healthkit.background-delivery entitlement
…utter compatibility - Move Package.swift to ios/workmanager_apple/ subdirectory (Flutter SPM requirement) - Rename product from 'workmanager_apple' to 'workmanager-apple' (Flutter naming convention) - Add missing UIKit import in Extensions.swift for UIBackgroundFetchResult - Move Sources, Resources, Assets to correct subdirectory This fixes Swift Package Manager integration with Flutter's SPM plugin system, which expects: 1. Package.swift at ios/<plugin_name>/Package.swift 2. Product names with hyphens (e.g., 'workmanager-apple' not 'workmanager_apple') Without these fixes, Flutter falls back to CocoaPods instead of using SPM.
## Problem The current Quick Start guide shows task identifiers that don't match between Dart and iOS native code, which causes `BGTaskSchedulerErrorDomain Code 3` errors on iOS. **Current Issue:** - Info.plist: `com.yourapp.processing_task` - AppDelegate: `com.yourapp.processing_task` - Dart code: `"data_sync"` ❌ (doesn't match!) This mismatch prevents iOS background tasks from being scheduled successfully. ## Solution Update documentation to show that **all three locations must use the same identifier**: - Info.plist: `com.yourapp.processing_task` - AppDelegate: `com.yourapp.processing_task` - Dart code: `com.yourapp.processing_task` ✅ ## Testing Tested on iOS 26 with BGTaskScheduler - background tasks now schedule successfully without Code 3 errors.
…gging ## Problem The iOS Notification Debug Handler section is incomplete - it's missing the `userNotificationCenter` override that's required to show notifications when the app is in foreground. Without this, debug notifications don't appear during development. ## Solution Added complete iOS setup showing: - Notification permission request - Delegate assignment - Critical `userNotificationCenter` override ## Testing Tested on iOS 26. Debug notifications now appear correctly.
Thread registerHealthResearchTask() through the federated plugin architecture: platform interface, Apple implementation, Android UnsupportedError, and public Workmanager facade. Also fix missing registerHealthResearchTask override in Android Kotlin WorkmanagerPlugin (required by Pigeon-generated interface).
|
To view this pull requests documentation preview, visit the following URL: docs.page/fluttercommunity/flutter_workmanager~664 Documentation is deployed and generated using docs.page. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
registerHealthResearchTask()through the federated plugin architecture (platform interface → Apple impl → Android UnsupportedError → public Workmanager facade)registerHealthResearchTaskoverride in Android KotlinWorkmanagerPlugin(required by Pigeon-generatedWorkmanagerHostApiinterface added in 85b94bc)Builds on 85b94bc which added the native iOS implementation and Pigeon bindings but did not expose the feature through the Dart API.
Breaking Changes
None — additive API only.
Files Changed
workmanager_platform_interface/.../workmanager_platform_interface.dartworkmanager_apple/lib/workmanager_apple.dartworkmanager_android/lib/workmanager_android.dartUnsupportedErrorWorkmanagerPlugin.ktUnsupportedOperationExceptionstubworkmanager/lib/src/workmanager_impl.dartworkmanager_apple/test/,workmanager/test/