Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<UNUserNotificationCenterDelegate> *strongSelf = self;
notificationCenter.delegate = strongSelf;
}
}

// We automatically register for remote notifications as
Expand Down Expand Up @@ -1024,4 +1000,4 @@ - (NSDictionary *)NSDictionaryForNSError:(NSError *)error {
};
}

@end
@end