Created
February 6, 2025 20:57
-
-
Save knaeckeKami/4bf416ac0a1c6659e9c3c161bfffca45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@UIApplicationMain | |
@objc class AppDelegate: FlutterAppDelegate, OrientationDelegate { | |
var lastNotificationData: [AnyHashable: Any]? | |
var isChannelInitialized = false | |
... | |
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { | |
let userInfo = response.notification.request.content.userInfo | |
// Send the notification data to Flutter | |
if(!isChannelInitialized) { | |
// If the channel isn't initialized yet, save the notification data | |
self.lastNotificationData = userInfo | |
} else if let controller = (UIApplication.shared.delegate as? AppDelegate)?.window?.rootViewController as? FlutterViewController { | |
let channel = FlutterMethodChannel(name: "com.helloinside.glucose/notification", binaryMessenger: controller.binaryMessenger) | |
channel.invokeMethod("onNotificationTap", arguments: userInfo) { result in | |
print("Method call result: \(result)") | |
} | |
} else { | |
// If we can't get the FlutterViewController, save the notification data | |
self.lastNotificationData = userInfo | |
} | |
completionHandler() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment