Skip to content

Commit 8ff0f88

Browse files
fix(messaging, ios): register app delegate with google utilities for swizzling (#13525)
1 parent 7376043 commit 8ff0f88

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,4 @@ firebase-debug.log
8080
firestore-debug.log
8181
database-debug.log
8282
ui-debug.log
83-
84-
**/.build/**/*
83+
**/.build/**/*

packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ API_AVAILABLE(ios(10.0))
4343
@interface FLTFirebaseMessagingPlugin : FLTFirebasePlugin <FlutterPlugin,
4444
FLTFirebasePlugin,
4545
FIRMessagingDelegate,
46+
UIApplicationDelegate,
4647
UNUserNotificationCenterDelegate>
4748
#else
4849
@interface FLTFirebaseMessagingPlugin

packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ - (void)application_onDidFinishLaunchingNotification:(nonnull NSNotification *)n
225225
_initialNotificationGathered = YES;
226226
[self initialNotificationCallback];
227227

228-
#if TARGET_OS_OSX
229-
// For macOS we use swizzling to intercept as addApplicationDelegate does not exist on the macOS
230-
// registrar Flutter implementation.
231228
[GULAppDelegateSwizzler registerAppDelegateInterceptor:self];
232229
[GULAppDelegateSwizzler proxyOriginalDelegateIncludingAPNSMethods];
233230

@@ -246,7 +243,11 @@ - (void)application_onDidFinishLaunchingNotification:(nonnull NSNotification *)n
246243
didReceiveRemoteNotificationWithCompletionSEL,
247244
method_getImplementation(donorMethod), method_getTypeEncoding(donorMethod));
248245
}
249-
#else
246+
#if !TARGET_OS_OSX
247+
// `[_registrar addApplicationDelegate:self];` alone doesn't work for notifications to be received
248+
// without the above swizzling This commit:
249+
// https://github.com/google/GoogleUtilities/pull/162/files#diff-6bb6d1c46632fc66405a524071cc4baca5fc6a1a6c0eefef81d8c3e2c89cbc13L520-L533
250+
// broke notifications which was released with firebase-ios-sdk v11.0.0
250251
[_registrar addApplicationDelegate:self];
251252
#endif
252253

0 commit comments

Comments
 (0)