43 lines
1.2 KiB
Swift
43 lines
1.2 KiB
Swift
import Flutter
|
|
import UIKit
|
|
import UserNotifications
|
|
import Firebase
|
|
|
|
@main
|
|
@objc class AppDelegate: FlutterAppDelegate {
|
|
override func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
) -> Bool {
|
|
|
|
FirebaseApp.configure()
|
|
|
|
// Set notification delegate so notifications show in foreground & background
|
|
UNUserNotificationCenter.current().delegate = self
|
|
|
|
GeneratedPluginRegistrant.register(with: self)
|
|
|
|
return super.application(
|
|
application,
|
|
didFinishLaunchingWithOptions: launchOptions
|
|
)
|
|
}
|
|
|
|
// Called when a notification is delivered while app is in foreground
|
|
override func userNotificationCenter(
|
|
_ center: UNUserNotificationCenter,
|
|
willPresent notification: UNNotification,
|
|
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
|
|
) {
|
|
completionHandler([.banner, .badge, .sound])
|
|
}
|
|
|
|
// Called when user taps a notification
|
|
override func userNotificationCenter(
|
|
_ center: UNUserNotificationCenter,
|
|
didReceive response: UNNotificationResponse,
|
|
withCompletionHandler completionHandler: @escaping () -> Void
|
|
) {
|
|
completionHandler()
|
|
}
|
|
} |