Skip to content

Commit ac2b658

Browse files
enedclaude
andcommitted
fix: Android initialization bug and iOS 14 availability annotations
- Fix Android PlatformException on first run after initialize (fixes #645) - Update currentDispatcherHandle when initialize() is called - Add validation for callback handle - Add iOS 14.0 availability annotation to LoggingDebugHandler (fixes #641) - Prevents build errors when os.Logger is used - Update documentation with iOS 14.0 minimum deployment target requirement (fixes #639) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 83f0f7c commit ac2b658

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

docs/quickstart.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ flutter pub get
2323
Android works automatically - no additional setup required! ✅
2424

2525
### iOS
26+
27+
<Warning>
28+
**iOS Minimum Deployment Target:** iOS 14.0 or later is required. Update your project's deployment target in Xcode:
29+
1. Open `ios/Runner.xcodeproj` in Xcode
30+
2. Select the Runner target
31+
3. Set "Minimum Deployments" to iOS 14.0 or later
32+
4. Or edit `ios/Runner.xcodeproj/project.pbxproj` and set `IPHONEOS_DEPLOYMENT_TARGET = 14.0;`
33+
</Warning>
34+
2635
iOS requires a 5-minute setup in Xcode. Choose your approach based on your needs:
2736

2837
#### Option A: Periodic Tasks (Recommended for most use cases)

workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,20 @@ class WorkmanagerPlugin :
4747
callback: (Result<Unit>) -> Unit,
4848
) {
4949
try {
50-
preferenceManager.saveCallbackDispatcherHandleKey(request.callbackHandle)
50+
val handle = request.callbackHandle
51+
52+
// Validate the handle
53+
if (handle <= 0L) {
54+
callback(Result.failure(Exception("Invalid callback handle provided to initialize")))
55+
return
56+
}
57+
58+
// Save to SharedPreferences
59+
preferenceManager.saveCallbackDispatcherHandleKey(handle)
60+
61+
// Update the local variable to match
62+
currentDispatcherHandle = handle
63+
5164
callback(Result.success(Unit))
5265
} catch (e: Exception) {
5366
callback(Result.failure(e))

workmanager_apple/ios/Sources/workmanager_apple/LoggingDebugHandler.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import os
33

44
/**
55
* A debug handler that outputs debug information to iOS's unified logging system.
6+
* Note: This class requires iOS 14.0 or later due to the use of os.Logger.
67
*/
8+
@available(iOS 14.0, *)
79
public class LoggingDebugHandler: WorkmanagerDebug {
810
private let logger = os.Logger(subsystem: "dev.fluttercommunity.workmanager", category: "debug")
911

0 commit comments

Comments
 (0)