MissingPluginException when run in ios
Closed this issue · 1 comments
March-mitsuki commented
Hello, thank you for maintaining this package. I encountered this error while using it on iOS, but everything is fine on macOS.
I'm using this package together with flutter_local_notifications and timezone.
All I did was install the package and use the code from the example. Do I need to set up anything extra?
platform: ios (iphone 14 simulator)
error: MissingPluginException (MissingPluginException(No implementation found for method getLocalTimezone on channel flutter_timezone))
my code:
String? osTimezoneName;
Future<void> configureLocalTimeZone() async {
if (Platform.isWindows) {
throw UnimplementedError('Windows not supported');
}
tz.initializeTimeZones();
osTimezoneName = await FlutterTimezone.getLocalTimezone();
tz.setLocalLocation(tz.getLocation(osTimezoneName!));
}
AppDelegate.swift
import UIKit
import Flutter
import flutter_local_notifications
@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
}
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
March-mitsuki commented
I found out that I simply forgot to add GeneratedPluginRegistrant.register(with: self)
to AppDelegate.swift
, my mistake.