Reputation: 11
I'm trying to integrate WorkManager in iOS (it already works for me on android)
When I run the project, it gives me the following error: `Type 'WorkmanagerPlugin' has no member 'registerBGProcessingTask' /Users/user/Desktop/Projects/project/ios/Runner/AppDelegate.swift:23:22
Could not build the application for the simulator. Error launching application on iPhone 15 Pro.`
I have read the official documentation of the plugin and I have read several examples of integration by iOS, I have also seen its examples of integration in the plugin repository and I have followed the steps but unlike Android on iOS it has not worked for me.
mi AppDelegate.swift
import UIKit
import Flutter
import FirebaseCore
import workmanager
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
WorkmanagerPlugin.setPluginRegistrantCallback { registry in
GeneratedPluginRegistrant.register(with: registry)
}
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "task-identifier")
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
I have reviewed the issues in the repository and researched more about the problem but none of the solutions given in these have worked for me...
Try adding this line as suggested by the operating documentation on iOS but the problem persists...
WorkmanagerPlugin.setPluginRegistrantCallback { registry in
GeneratedPluginRegistrant.register(with: registry)
}
my flutter doctor output
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.4.1 23E224 darwin-arm64 (Rosetta), locale es-419)
• Flutter version 3.16.5 on channel stable at /Users/user/src/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 78666c8dc5 (hace 5 meses), 2023-12-19 16:14:14 -0800
• Engine revision 3f3e560236
• Dart version 3.2.3
• DevTools version 2.28.4
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/user/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/user/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.14.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.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.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.88.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.86.0
[✓] Connected device (3 available)
• iPhone 15 Pro (mobile) • 432CF0CD-9CFD-4C42-B733-0667B0C187C7 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
(Rosetta)
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.118
[✓] Network resources
• All expected network resources are available.
• No issues found!
I have tried reinstalling the YouTube pods and guides but the problem is always the same, although I have not tried with a physical device, I don't know if it is an emulator problem although I don't think so since they used it in the guides...
Upvotes: 1
Views: 898