I am trying to use workmanager: ^0.2.0 plugin for the background process inside the flutter project. While running the application in iOS, it throws an error as below, But in Android plugin is working seamlessly
MissingPluginException(No implementation found for method initialize on channel be.tramckrijte.workmanager/foreground_channel_work_manager)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)
<asynchronous suspension>
#1 Workmanager.initialize (package:workmanager/src/workmanager.dart:100:30)
#2 main (package:worksample/main.dart:29:15)
I manually registered the Workmanager plugin inside the AppDelegate.swift code, still it doesn’t autogenerating plugin registration code inside GeneratedPluginRegistrant.m class file.
Below are my code snippets,
import UIKit
import Flutter
import workmanager
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15))
UNUserNotificationCenter.current().delegate = self
WorkmanagerPlugin.setPluginRegistrantCallback { registry in
AppDelegate.registerPlugins(with: registry)
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
static func registerPlugins(with registry: FlutterPluginRegistry) {
GeneratedPluginRegistrant.register(with: registry)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert)
}
}
WorkManager plugin is missed in the below generated file
//
// Generated file. Do not edit.
//
#import "GeneratedPluginRegistrant.h"
#if __has_include(<flutter_native_timezone/FlutterNativeTimezonePlugin.h>)
#import <flutter_native_timezone/FlutterNativeTimezonePlugin.h>
#else
@import flutter_native_timezone;
#endif
#if __has_include(<shared_preferences/FLTSharedPreferencesPlugin.h>)
#import <shared_preferences/FLTSharedPreferencesPlugin.h>
#else
@import shared_preferences;
#endif
@implementation GeneratedPluginRegistrant
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[FlutterNativeTimezonePlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterNativeTimezonePlugin"]];
[FLTSharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTSharedPreferencesPlugin"]];
}
@end
How can I resolve this issue?