diff --git a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m index b1ea455daaa1..d3b455936acb 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m @@ -221,46 +221,22 @@ - (void)application_onDidFinishLaunchingNotification:(nonnull NSNotification *)n // Set UNUserNotificationCenter but preserve original delegate if necessary. if (@available(iOS 10.0, macOS 10.14, *)) { - BOOL shouldReplaceDelegate = YES; UNUserNotificationCenter *notificationCenter = [UNUserNotificationCenter currentNotificationCenter]; if (notificationCenter.delegate != nil) { -#if !TARGET_OS_OSX - // If the App delegate exists and it conforms to UNUserNotificationCenterDelegate then we - // don't want to replace it on iOS as the earlier call to `[_registrar - // addApplicationDelegate:self];` will automatically delegate calls to this plugin. If we - // replace it, it will cause a stack overflow as our original delegate forwarding handler - // below causes an infinite loop of forwarding. See - // https://github.com/FirebaseExtended/flutterfire/issues/4026. - if ([GULApplication sharedApplication].delegate != nil && - [[GULApplication sharedApplication].delegate - conformsToProtocol:@protocol(UNUserNotificationCenterDelegate)]) { - // Note this one only executes if Firebase swizzling is **enabled**. - shouldReplaceDelegate = NO; - } -#endif - - if (shouldReplaceDelegate) { _originalNotificationCenterDelegate = notificationCenter.delegate; _originalNotificationCenterDelegateRespondsTo.openSettingsForNotification = (unsigned int)[_originalNotificationCenterDelegate respondsToSelector:@selector(userNotificationCenter:openSettingsForNotification:)]; - _originalNotificationCenterDelegateRespondsTo.willPresentNotification = - (unsigned int)[_originalNotificationCenterDelegate - respondsToSelector:@selector(userNotificationCenter: - willPresentNotification:withCompletionHandler:)]; _originalNotificationCenterDelegateRespondsTo.didReceiveNotificationResponse = (unsigned int)[_originalNotificationCenterDelegate respondsToSelector:@selector(userNotificationCenter: didReceiveNotificationResponse:withCompletionHandler:)]; - } } - if (shouldReplaceDelegate) { __strong FLTFirebasePlugin *strongSelf = self; notificationCenter.delegate = strongSelf; - } } // We automatically register for remote notifications as @@ -1024,4 +1000,4 @@ - (NSDictionary *)NSDictionaryForNSError:(NSError *)error { }; } -@end +@end \ No newline at end of file