I’m growing a Flutter iOS app that integrates Firebase, Google Maps, and Push Notifications. Nevertheless, when I attempt to run the app on an iPhone SE (third era) simulator utilizing flutter run, I get the next Swift compiler errors:
Swift Compiler Error (Xcode): Overriding declaration requires an ‘override’ key phrase
Swift Compiler Error (Xcode): Overriding declaration requires an ‘override’ key phrase
Swift Compiler Error (Xcode): Redundant conformance of ‘AppDelegate’ to protocol
‘UNUserNotificationCenterDelegate’
import Flutter
import UIKit
import FirebaseCore
import GoogleMaps
import FirebaseMessaging
import UserNotifications
@principal
@objc class AppDelegate: FlutterAppDelegate {
override func utility(
_ utility: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Configure Firebase
FirebaseApp.configure()
// Present Google Maps API Key
GMSServices.provideAPIKey("api_key")
// Register for push notifications
registerForPushNotifications(utility)
GeneratedPluginRegistrant.register(with: self)
return tremendous.utility(utility,
didFinishLaunchingWithOptions: launchOptions)
}
/// Register for push notifications
non-public func registerForPushNotifications(_ utility:
UIApplication) {
UNUserNotificationCenter.present().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge,
.sound]
UNUserNotificationCenter.present().requestAuthorization(choices:
authOptions) { granted, error in
if let error = error {
print("Error requesting notifications permission: (error)")
}
}
utility.registerForRemoteNotifications()
}
/// Set APNs token for Firebase Messaging
override func utility(
_ utility: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken:
Knowledge
) {
Messaging.messaging().apnsToken = deviceToken
tremendous.utility(utility,
didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
}
// MARK: - UNUserNotificationCenterDelegate
extension AppDelegate: UNUserNotificationCenterDelegate {
// Deal with foreground push notifications
func userNotificationCenter(
_ heart: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping
(UNNotificationPresentationOptions) -> Void
) {
completionHandler([.alert, .badge, .sound])
}
// Deal with background & terminated state push notification faucet
func userNotificationCenter(
_ heart: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
completionHandler()
}
}
What I Have Tried
I tried the next steps to scrub and rebuild the venture:
flutter clear
rm -rf ios/Pods ios/Podfile.lock
flutter pub get
cd ios
pod set up –repo-update
cd ..
flutter run
However the challenge nonetheless persists.
How can I repair the “Overriding declaration requires an ‘override’ key phrase” and “Redundant conformance of ‘AppDelegate’ to protocol ‘UNUserNotificationCenterDelegate'” errors?
Am I implementing UNUserNotificationCenterDelegate incorrectly in Swift?
Are there any extra Flutter iOS configurations I have to verify?