| .. | .. |
|---|
| 1 | 1 | import Flutter |
|---|
| 2 | 2 | import UIKit |
|---|
| 3 | +import UserNotifications |
|---|
| 3 | 4 | |
|---|
| 4 | 5 | @main |
|---|
| 5 | 6 | @objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { |
|---|
| .. | .. |
|---|
| 13 | 14 | func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { |
|---|
| 14 | 15 | GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) |
|---|
| 15 | 16 | } |
|---|
| 17 | + |
|---|
| 18 | + // Forward APNs token registration to the push plugin |
|---|
| 19 | + override func application( |
|---|
| 20 | + _ application: UIApplication, |
|---|
| 21 | + didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data |
|---|
| 22 | + ) { |
|---|
| 23 | + super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) |
|---|
| 24 | + } |
|---|
| 25 | + |
|---|
| 26 | + override func application( |
|---|
| 27 | + _ application: UIApplication, |
|---|
| 28 | + didFailToRegisterForRemoteNotificationsWithError error: Error |
|---|
| 29 | + ) { |
|---|
| 30 | + super.application(application, didFailToRegisterForRemoteNotificationsWithError: error) |
|---|
| 31 | + } |
|---|
| 32 | + |
|---|
| 33 | + // Forward notification presentation (foreground) |
|---|
| 34 | + override func userNotificationCenter( |
|---|
| 35 | + _ center: UNUserNotificationCenter, |
|---|
| 36 | + willPresent notification: UNNotification, |
|---|
| 37 | + withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void |
|---|
| 38 | + ) { |
|---|
| 39 | + super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler) |
|---|
| 40 | + } |
|---|
| 41 | + |
|---|
| 42 | + // Forward notification tap |
|---|
| 43 | + override func userNotificationCenter( |
|---|
| 44 | + _ center: UNUserNotificationCenter, |
|---|
| 45 | + didReceive response: UNNotificationResponse, |
|---|
| 46 | + withCompletionHandler completionHandler: @escaping () -> Void |
|---|
| 47 | + ) { |
|---|
| 48 | + super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler) |
|---|
| 49 | + } |
|---|
| 16 | 50 | } |
|---|