From 8ff0f88c512a0dde16f5906c36259b911e0d5de7 Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Wed, 23 Oct 2024 12:43:28 +0100 Subject: [PATCH] fix(messaging, ios): register app delegate with google utilities for swizzling (#13525) --- .gitignore | 3 +-- .../ios/Classes/FLTFirebaseMessagingPlugin.h | 1 + .../ios/Classes/FLTFirebaseMessagingPlugin.m | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 83e5a5f4244f..c3c1ec7a8e53 100644 --- a/.gitignore +++ b/.gitignore @@ -80,5 +80,4 @@ firebase-debug.log firestore-debug.log database-debug.log ui-debug.log - -**/.build/**/* +**/.build/**/* diff --git a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.h b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.h index 144343e830fd..2c2ea7cea636 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.h +++ b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.h @@ -43,6 +43,7 @@ API_AVAILABLE(ios(10.0)) @interface FLTFirebaseMessagingPlugin : FLTFirebasePlugin #else @interface FLTFirebaseMessagingPlugin diff --git a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m index 67ee0ab23997..4a80cfd1a537 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m @@ -225,9 +225,6 @@ - (void)application_onDidFinishLaunchingNotification:(nonnull NSNotification *)n _initialNotificationGathered = YES; [self initialNotificationCallback]; -#if TARGET_OS_OSX - // For macOS we use swizzling to intercept as addApplicationDelegate does not exist on the macOS - // registrar Flutter implementation. [GULAppDelegateSwizzler registerAppDelegateInterceptor:self]; [GULAppDelegateSwizzler proxyOriginalDelegateIncludingAPNSMethods]; @@ -246,7 +243,11 @@ - (void)application_onDidFinishLaunchingNotification:(nonnull NSNotification *)n didReceiveRemoteNotificationWithCompletionSEL, method_getImplementation(donorMethod), method_getTypeEncoding(donorMethod)); } -#else +#if !TARGET_OS_OSX + // `[_registrar addApplicationDelegate:self];` alone doesn't work for notifications to be received + // without the above swizzling This commit: + // https://github.com/google/GoogleUtilities/pull/162/files#diff-6bb6d1c46632fc66405a524071cc4baca5fc6a1a6c0eefef81d8c3e2c89cbc13L520-L533 + // broke notifications which was released with firebase-ios-sdk v11.0.0 [_registrar addApplicationDelegate:self]; #endif