Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ private const val INIT_REQUIRED =
"You have not properly initialized the Flutter WorkManager Package. " +
"You should ensure you have called the 'initialize' function first!"

private const val INIT_FAILED =
"Workmanager.initialize failed because 'callbackHandle' was invalid."

/**
* Pigeon-based implementation of WorkmanagerHostApi for Android.
* Replaces the manual method channel and data extraction approach.
Expand Down Expand Up @@ -47,7 +50,14 @@ class WorkmanagerPlugin :
callback: (Result<Unit>) -> Unit,
) {
try {
preferenceManager.saveCallbackDispatcherHandleKey(request.callbackHandle)
val handle = request.callbackHandle
if (handle <= 0L) {
callback(Result.failure(Exception(INIT_FAILED)))
return
}

preferenceManager.saveCallbackDispatcherHandleKey(handle)
currentDispatcherHandle = handle
callback(Result.success(Unit))
} catch (e: Exception) {
callback(Result.failure(e))
Expand Down