Skip to content
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

🐞Type 'WorkmanagerPlugin' has no member 'registerBGProcessingTask' and Type 'WorkmanagerPlugin' has no member 'registerPeriodicTask' #551

Open
4 tasks done
Brechard opened this issue Apr 24, 2024 · 17 comments
Labels
bug Something isn't working

Comments

@Brechard
Copy link

Brechard commented Apr 24, 2024

  • I have read the README
  • I have done the setup for Android
  • I have done the setup for iOS
  • I have ran the sample app and it does not work there

Version

Technology Version
Workmanager version 0.5.2
Xcode version 15.3
Swift version 5.10
iOS deployment target 12

Describe the error

I was following the setup for iOs and when reaching the "You MUST amend your AppDelegate.swift and Info.plist file to register your task ID." I receive those errors in Xcode.

I have cloned this repo and the same errors show on the example (on the flutter side there are 4 errors like: error: The method 'registerProcessingTask' isn't defined for the type 'Workmanager'. (undefined_method at [workmanager_example] lib/main.dart:266)

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
• Flutter version 3.19.6 on channel stable at ~/software/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (7 days ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at ~/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: ~/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] Android Studio (version 2023.3)
• Android Studio at ~/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.88.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.84.0

[✓] Connected device (4 available)
• Pixel 8 (mobile) • 39011FDJH007KM • android-arm64 • Android 14 (API 34)
• iPhone 15 Pro (mobile) • 195714BD-9F6E-47A9-9886-313A3A97FC68 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.62

[✓] Network resources
• All expected network resources are available.

@Brechard Brechard added the bug Something isn't working label Apr 24, 2024
@Cmk427
Copy link

Cmk427 commented Apr 25, 2024

You may try to change the branch of the package in pubspec.yaml file:

  workmanager:
    git:
      url: https://github.com/absar/flutter_workmanager.git
      ref: ios-bg-tasks-enh-final

It may help you to solve your issue at this moment.

@joonne
Copy link

joonne commented May 7, 2024

The above solution seems to work, I'm now able to build the app and triggering the background task from the debugger works. Could we get a comment whether this is the "correct" solution for making this plugin work on iOS at the moment?

@nk4n01
Copy link

nk4n01 commented May 8, 2024

I got the same error !!

@razumeiko
Copy link

Don't you think that it's weird? The official git link is https://github.com/fluttercommunity/flutter_workmanager
but you are pulling code from https://github.com/absar/flutter_workmanager.git who knows what he could code there.

@joonne
Copy link

joonne commented May 10, 2024

I could have elaborated a bit, those changes from https://github.com/absar/flutter_workmanager.git are actually in main already and waiting to be released: b783000 👍

(or that is how I understood the situation)

@dario-digregorio
Copy link

dario-digregorio commented May 16, 2024

I spend too much time figuring out why the described setup is not working with my project until I realized that the link to the iOS Setup brings you to the GitHub Repo, has a different version than the one that is published on pub.dev 🥲
So for others that are struggling use the right version in your pubspec.yml and read the Readme's from that commit b783000.

Pubspec

  workmanager:
    git:
      url: https://github.com/fluttercommunity/flutter_workmanager.git
      ref: b783000

@Kurokirisu
Copy link

Kurokirisu commented May 21, 2024

Pubspec

  workmanager:
    git:
      url: https://github.com/fluttercommunity/flutter_workmanager.git
      ref: b783000

I am now using this version instead of the 0.5.2 version and at first it worked fine, but now I get an error on Android:

  • What went wrong:
    Execution failed for task ':app:checkDebugDuplicateClasses'.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class androidx.work.OneTimeWorkRequestKt found in modules work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1) and work-runtime-ktx-2.7.0-runtime (androidx.work:work-runtime-ktx:2.7.0)
Duplicate class androidx.work.PeriodicWorkRequestKt found in modules work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1) and work-runtime-ktx-2.7.0-runtime (androidx.work:work-runtime-ktx:2.7.0)

I really need the periodic tasks to work on iOS, so I hope someone can help me with this since they don't work in the 0.5.2 version.

@ghufrankhan
Copy link

Pubspec

  workmanager:
    git:
      url: https://github.com/fluttercommunity/flutter_workmanager.git
      ref: b783000

I am now using this version instead of the 0.5.2 version and at first it worked fine, but now I get an error on Android:

  • What went wrong:
    Execution failed for task ':app:checkDebugDuplicateClasses'.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class androidx.work.OneTimeWorkRequestKt found in modules work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1) and work-runtime-ktx-2.7.0-runtime (androidx.work:work-runtime-ktx:2.7.0)
Duplicate class androidx.work.PeriodicWorkRequestKt found in modules work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1) and work-runtime-ktx-2.7.0-runtime (androidx.work:work-runtime-ktx:2.7.0)

I really need the periodic tasks to work on iOS, so I hope someone can help me with this since they don't work in the 0.5.2 version.

Hi, try adding this line inside the dependencies array found in /android/app/build.gradle:

implementation("androidx.work:work-runtime-ktx:2.8.1")

@Wegi
Copy link

Wegi commented Jun 20, 2024

Anything to help this fixed version being released on pub.dev?

kyle-is-loading-please-wait referenced this issue Jul 9, 2024
…inBackgroundTask, printScheduledTasks (#511)

* fix:Update Workmanager iOS because no callback in Background on iOS real device, added 30sec BGAppRefresh, Updated example #396

* added permissionhandler an requests for iOS
added alert and MaterialApp to workmanager when no iOS permissions activated

* fixed errormessage on xcode

* feat:Added check for background refresh permissions #441

* text to display task event dates (show prefs) added.

* fixed workmanager iOS Part
fixed BGProcessing
fixed inputdata in callback on task
clarified timings

* fixed warning dead code and ! check

* improved Task description (hints)

* Update README.md

* Update README.md

* Update README.md

* Format readme iOS examples

* Improve code documentation

* Cleanups in SwiftWorkmanagerPlugin.swift
* Use logInfo instead of prints and NSLog
* Log unnecessary logs only in debug mode
* Remove unnecessary logs
* Remove isInitalized flag in SwiftWorkmanagerPlugin which was not set to true anywhere

* * iOS, Rename registeriOSBackgroundProcessingTask to a generic name registerProcessingTask to be consistent with rest of the plugin and possible future Android implementation
* iOS, Rename wrongly named startOnOffTask to startOneOffTask

* * Cleanup code to make it more close to original plugin so that change size is reduced and it will make it easy to review
* Change new task identifier to be consistent with existing ones e.g. instead of app.workmanager... use be.tramckrijte...
* Documentation update
* Remove unnecessary logs, comments etc which were added in PRs which were not merged, and cleanup unnecessary code
* Revert using a custom log helper OS file to use the plugins existing shared prefs
* Bump example flutter sdk to < 4 instead of < 3

* Add task identifiers to iOS AppRefresh and ProcessingTask so that user can define task names instead of using hardcoded names

* * iOS AppRefresh task interval should be 15 minutes
* Documentation update

* Initialize should not auto open App settings if background refresh permission is not assigned.
Initialize should return result

* Continue work on task identifiers for iOS AppRefresh and ProcessingTask.
* Temporarily commented old iOS background fetch

* Fix extra commas on iOS

* New iOS feature printScheduledTasks to print details of un-executed scheduled tasks. To be used during development/debugging.
Format readme to improve readability

* iOS Periodic and processing tasks will be immediately scheduled, instead of waiting for App to go to background. Since doing on backgrounding will keep on changing earliest begin date.
* Add printScheduledTasks to example app
* Format example code

* Option to set frequency for iOS periodic tasks in AppDelegate.swift
* Add initialDelay support for Workmanager.registerProcessingTask
* Remove unnecessary WorkmanagerPlugin.registerBGProcessingTask calls from AppDelegate.swift
* Cleanup unused params from Workmanager.registerProcessingTask
* Update readme and iOS setup as per new iOS developments
* Create migration steps for iOS Workmanager.registerOneOffTask to Workmanager.registerProcessingTask

* Update iOS docs

* TODO for cleanups later

---------

Co-authored-by: Lars Huth <[email protected]>
Co-authored-by: xunreal75 <[email protected]>
Co-authored-by: Ioseph Magno <[email protected]>
Co-authored-by: delfme <[email protected]>
@csarigumba
Copy link

Can we release this in pub.dev already?

@jbmangold
Copy link

Just so this isn't marked as stale, are there plans to release this version to pub.dev?

@darul9061
Copy link

This needs to be released to pub.dev

@lisovyk
Copy link

lisovyk commented Sep 11, 2024

Hello @ened ! Could you leave us a short comment here? Many people are waiting for at least some info here

@aidarbye
Copy link

aidarbye commented Oct 7, 2024

still waiting

@Hactieuho
Copy link

still waiting

Keep waiting

@EdwardRodr1guez
Copy link

still fucking waiting

@chihuy105
Copy link

waiting still fucking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests