Skip to content

Commit 134fcb9

Browse files
committed
fix: compilation errors in iOS and Android after Pigeon migration
- Fix Swift compilation error in iOS BackgroundWorker by replacing non-existent mapKeys with proper Dictionary conversion - Add missing getCallbackHandle static method to Android SharedPreferenceHelper - Verify both iOS and Android builds compile successfully
1 parent 147e977 commit 134fcb9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class SharedPreferenceHelper(
1919
private const val SHARED_PREFS_FILE_NAME = "flutter_workmanager_plugin"
2020
private const val CALLBACK_DISPATCHER_HANDLE_KEY =
2121
"dev.fluttercommunity.workmanager.CALLBACK_DISPATCHER_HANDLE_KEY"
22+
23+
fun getCallbackHandle(context: Context): Long {
24+
val preferences = context.getSharedPreferences(SHARED_PREFS_FILE_NAME, Context.MODE_PRIVATE)
25+
return preferences.getLong(CALLBACK_DISPATCHER_HANDLE_KEY, -1L)
26+
}
2227
}
2328

2429
private val preferences: SharedPreferences

workmanager_apple/ios/Classes/BackgroundWorker.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ class BackgroundWorker {
121121
let taskName = self.backgroundMode.onResultSendArguments["\(WorkmanagerPlugin.identifier).DART_TASK"] ?? ""
122122

123123
// Convert inputData to the format expected by Pigeon
124-
let pigeonInputData = self.inputData?.mapKeys { $0 as String? }.mapValues { $0 as Any? }
124+
var pigeonInputData: [String?: Any?]? = nil
125+
if let inputData = self.inputData {
126+
pigeonInputData = Dictionary(uniqueKeysWithValues: inputData.map { ($0.key as String?, $0.value as Any?) })
127+
}
125128

126129
// Execute the task
127130
flutterApi?.executeTask(taskName: taskName, inputData: pigeonInputData) { taskResult in

0 commit comments

Comments
 (0)