-
Notifications
You must be signed in to change notification settings - Fork 354
feat: 0.8.0 - Federated architecture migration with community bugfixes #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
e8f9d39
feat: Bugfix release 0.7.1 with multiple contributor fixes
ened 6fbdff9
fix: Update Package.swift to remove archived flutter/engine dependency
ened e1b44b0
fix: Remove premature SPM implementation to avoid file duplication
ened fcb6452
feat: Migrate to federated plugin architecture for v0.8.0
ened 6e39275
fix: Remove duplicated files and fix federated package issues
ened 3621eb0
chore: Replace be.tramckrijte namespace with dev.fluttercommunity
ened 6bfdf51
fix: Update GitHub Actions for federated architecture
ened 6a7999b
fix: Restore Dart unit tests and fix generator issues
ened d32ab57
fix: Complete namespace migration and fix iOS module import
ened db90e79
style: Apply dart formatter to all packages
ened 33614ba
fix: Remove ios_backup directory causing Swift lint failures
ened 3ef530c
debug: Add detailed git diff output to format_dart workflow
ened ecaab1e
feat: Complete federated plugin architecture with comprehensive tests
ened 844c27f
fix: Simplify format_dart CI check to properly detect formatting issues
ened 0e8bbfc
fix: Add flutter pub get before dart format to resolve dependencies
ened fa90c25
feat: Update pubspec files for publishable packages
ened d35e4d4
fix: Add melos bootstrap to analysis workflow and fix example dependency
ened 96f16d7
fix: Make initialDelaySeconds optional in iOS registerOneOffTask
ened b14ae1c
remove version in example/pubspec
ened 1f3d7e5
fix dart not found
ened 27e94ce
feat: Add LICENSE and README files for all published packages
ened 6de804f
fix: Improve federated plugin documentation and melos CI setup
ened f26832c
fix: Resolve drive_android test failures and integration test logic eβ¦
ened 24714c7
fix: Replace melos bootstrap with manual dependency resolution in anaβ¦
ened c38f5ea
fix: Replace manual melos setup with official melos-action
ened 64999b6
debug: Add comprehensive debugging to analysis workflow
ened 3f3e018
fix: Update analysis workflow for federated plugin architecture
ened fc18018
docs: Add CHANGELOG.md files to all federated plugin packages
ened 994e80e
fix: only run pub publish analysis for now
ened 20e6632
chore: Upgrade to Flutter 3.32 and flutter_lints 6.0.0
ened e4867b3
chore: Update Android emulator tests to use API level 35
ened 846f8ac
fix: Fix Android test compilation issues
ened d4d838a
fix: do not double build
ened 4b70405
fix: Correct native Android test command in CI
ened 5df937e
chore: Remove test_pana folder
ened a8a8dd5
Revert "fix: do not double build"
ened 7ef8194
fix: Handle missing isInDebugMode parameter in Android task registration
ened 07ba57f
perf: Add Android emulator caching to improve CI performance
ened 2d89760
try in one line
ened cd19b48
fix: Handle inputData Map properly and add comprehensive integration β¦
ened 94be83b
refactor: Remove JSON conversion and use native Map transfer
ened 5020f6a
fix: iOS compilation error and remove verbose flags
ened 2f2b0a7
fix: Update enum values to camelCase for Dart conventions
ened 662d4ba
fix: Resolve iOS build failure and integration test method names
ened 0fa0f3b
style: Apply dart format to ensure consistent code style
ened 7183db1
style: Apply ktlint formatting to Kotlin code
ened b371433
fix: Remove accidentally committed ktlint binary
ened 17d4f22
fix: Add enum mapping for camelCase Dart values to Android enum names
ened 1dfddf4
style: Apply ktlint formatting to when statement indentation
ened 7d67007
fix: Separate expedited job test from regular constraint test
ened 920c80e
docs: Update CHANGELOGs and READMEs for v0.8.0 release
ened cfa147f
fix: Improve input data handling and background channel initialization
ened 0d09c0e
test: Add integration tests for data transfer and retry functionality
ened da8e9a4
fix: ios tests
ened fab7de4
refactor: Rename workmanager_ios to workmanager_apple
ened 79f73a1
last renames
ened 231a448
Fixed the analysis
ened 2b19081
keep onResultSend method
ened File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSPrivacyAccessedAPITypes</key> | ||
<array> | ||
<dict> | ||
<key>NSPrivacyAccessedAPITypeReasons</key> | ||
<array> | ||
<string>CA92.1</string> | ||
</array> | ||
<key>NSPrivacyAccessedAPIType</key> | ||
<string>NSPrivacyAccessedAPICategoryUserDefaults</string> | ||
</dict> | ||
</array> | ||
<key>NSPrivacyCollectedDataTypes</key> | ||
<array/> | ||
<key>NSPrivacyTrackingDomains</key> | ||
<array/> | ||
<key>NSPrivacyTracking</key> | ||
<false/> | ||
</dict> | ||
</plist> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// swift-tools-version: 5.9 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "workmanager", | ||
platforms: [ | ||
.iOS("13.0") | ||
], | ||
products: [ | ||
.library(name: "workmanager", targets: ["workmanager"]) | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/flutter/engine", from: "0.0.0") | ||
], | ||
targets: [ | ||
.target( | ||
name: "workmanager", | ||
dependencies: [ | ||
.product(name: "Flutter", package: "engine") | ||
], | ||
resources: [ | ||
.process("Resources") | ||
] | ||
) | ||
] | ||
) |
40 changes: 40 additions & 0 deletions
40
workmanager/ios/workmanager/Sources/workmanager/BackgroundTaskOperation.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// BackgroundTaskOperation.swift | ||
// workmanager | ||
// | ||
// Created by Sebastian Roth on 10/06/2021. | ||
// | ||
|
||
import Foundation | ||
|
||
class BackgroundTaskOperation: Operation { | ||
|
||
private let identifier: String | ||
private let flutterPluginRegistrantCallback: FlutterPluginRegistrantCallback? | ||
private let inputData: String | ||
private let backgroundMode: BackgroundMode | ||
|
||
init(_ identifier: String, | ||
inputData: String, | ||
flutterPluginRegistrantCallback: FlutterPluginRegistrantCallback?, | ||
backgroundMode: BackgroundMode) { | ||
self.identifier = identifier | ||
self.inputData = inputData | ||
self.flutterPluginRegistrantCallback = flutterPluginRegistrantCallback | ||
self.backgroundMode = backgroundMode | ||
} | ||
|
||
override func main() { | ||
let semaphore = DispatchSemaphore(value: 0) | ||
let worker = BackgroundWorker(mode: self.backgroundMode, | ||
inputData: self.inputData, | ||
flutterPluginRegistrantCallback: self.flutterPluginRegistrantCallback) | ||
DispatchQueue.main.async { | ||
worker.performBackgroundRequest { _ in | ||
semaphore.signal() | ||
} | ||
} | ||
|
||
semaphore.wait() | ||
} | ||
} |
140 changes: 140 additions & 0 deletions
140
workmanager/ios/workmanager/Sources/workmanager/BackgroundWorker.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
// | ||
// BackgroundWorker.swift | ||
// workmanager | ||
// | ||
// Created by Sebastian Roth on 10/06/2021. | ||
// | ||
|
||
import Foundation | ||
|
||
enum BackgroundMode { | ||
case backgroundFetch | ||
case backgroundProcessingTask(identifier: String) | ||
case backgroundPeriodicTask(identifier: String) | ||
case backgroundOneOffTask(identifier: String) | ||
|
||
var flutterThreadlabelPrefix: String { | ||
switch self { | ||
case .backgroundFetch: | ||
return "\(SwiftWorkmanagerPlugin.identifier).BackgroundFetch" | ||
case .backgroundProcessingTask: | ||
return "\(SwiftWorkmanagerPlugin.identifier).BackgroundProcessingTask" | ||
case .backgroundPeriodicTask: | ||
return "\(SwiftWorkmanagerPlugin.identifier).BackgroundPeriodicTask" | ||
case .backgroundOneOffTask: | ||
return "\(SwiftWorkmanagerPlugin.identifier).OneOffTask" | ||
} | ||
} | ||
|
||
var onResultSendArguments: [String: String] { | ||
switch self { | ||
case .backgroundFetch: | ||
return ["\(SwiftWorkmanagerPlugin.identifier).DART_TASK": "iOSPerformFetch"] | ||
case let .backgroundProcessingTask(identifier): | ||
return ["\(SwiftWorkmanagerPlugin.identifier).DART_TASK": identifier] | ||
case let .backgroundPeriodicTask(identifier): | ||
return ["\(SwiftWorkmanagerPlugin.identifier).DART_TASK": identifier] | ||
case let .backgroundOneOffTask(identifier): | ||
return ["\(SwiftWorkmanagerPlugin.identifier).DART_TASK": identifier] | ||
} | ||
} | ||
} | ||
|
||
class BackgroundWorker { | ||
|
||
let backgroundMode: BackgroundMode | ||
let flutterPluginRegistrantCallback: FlutterPluginRegistrantCallback? | ||
let inputData: String | ||
|
||
init(mode: BackgroundMode, inputData: String, flutterPluginRegistrantCallback: FlutterPluginRegistrantCallback?) { | ||
backgroundMode = mode | ||
self.inputData = inputData | ||
self.flutterPluginRegistrantCallback = flutterPluginRegistrantCallback | ||
} | ||
|
||
private struct BackgroundChannel { | ||
static let name = "\(SwiftWorkmanagerPlugin.identifier)/background_channel_work_manager" | ||
static let initialized = "backgroundChannelInitialized" | ||
static let onResultSendCommand = "onResultSend" | ||
} | ||
|
||
/// The result is discardable due to how [BackgroundTaskOperation] works. | ||
@discardableResult | ||
func performBackgroundRequest(_ completionHandler: @escaping (UIBackgroundFetchResult) -> Void) -> Bool { | ||
guard let callbackHandle = UserDefaultsHelper.getStoredCallbackHandle(), | ||
let flutterCallbackInformation = FlutterCallbackCache.lookupCallbackInformation(callbackHandle) | ||
else { | ||
logError("[\(String(describing: self))] \(WMPError.workmanagerNotInitialized.message)") | ||
completionHandler(.failed) | ||
return false | ||
} | ||
|
||
let taskSessionStart = Date() | ||
let taskSessionIdentifier = UUID() | ||
|
||
let debugHelper = DebugNotificationHelper(taskSessionIdentifier) | ||
debugHelper.showStartFetchNotification( | ||
startDate: taskSessionStart, | ||
callBackHandle: callbackHandle, | ||
callbackInfo: flutterCallbackInformation | ||
) | ||
|
||
var flutterEngine: FlutterEngine? = FlutterEngine( | ||
name: backgroundMode.flutterThreadlabelPrefix, | ||
project: nil, | ||
allowHeadlessExecution: true | ||
) | ||
|
||
flutterEngine!.run( | ||
withEntrypoint: flutterCallbackInformation.callbackName, | ||
libraryURI: flutterCallbackInformation.callbackLibraryPath | ||
) | ||
flutterPluginRegistrantCallback?(flutterEngine!) | ||
|
||
var backgroundMethodChannel: FlutterMethodChannel? = FlutterMethodChannel( | ||
name: BackgroundChannel.name, | ||
binaryMessenger: flutterEngine!.binaryMessenger | ||
) | ||
|
||
func cleanupFlutterResources() { | ||
flutterEngine?.destroyContext() | ||
backgroundMethodChannel = nil | ||
flutterEngine = nil | ||
} | ||
|
||
backgroundMethodChannel?.setMethodCallHandler { call, result in | ||
switch call.method { | ||
case BackgroundChannel.initialized: | ||
result(true) // Agree to Flutter's method invocation | ||
var arguments = self.backgroundMode.onResultSendArguments | ||
if self.inputData != "" { | ||
arguments = arguments.merging(["be.tramckrijte.workmanager.INPUT_DATA": self.inputData]) { current, _ in current } | ||
} | ||
|
||
backgroundMethodChannel?.invokeMethod( | ||
BackgroundChannel.onResultSendCommand, | ||
arguments: arguments, | ||
result: { flutterResult in | ||
cleanupFlutterResources() | ||
let taskSessionCompleter = Date() | ||
let result: UIBackgroundFetchResult = (flutterResult as? Bool ?? false) ? .newData : .failed | ||
let taskDuration = taskSessionCompleter.timeIntervalSince(taskSessionStart) | ||
logInfo("[\(String(describing: self))] \(#function) -> performBackgroundRequest.\(result) (finished in \(taskDuration.formatToSeconds()))") | ||
|
||
debugHelper.showCompletedFetchNotification( | ||
completedDate: taskSessionCompleter, | ||
result: result, | ||
elapsedTime: taskDuration | ||
) | ||
completionHandler(result) | ||
}) | ||
default: | ||
result(WMPError.unhandledMethod(call.method).asFlutterError) | ||
cleanupFlutterResources() | ||
completionHandler(UIBackgroundFetchResult.failed) | ||
} | ||
} | ||
|
||
return true | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.