diff --git a/FirebaseAuth.podspec b/FirebaseAuth.podspec index b4c3331124b..87a89205d75 100644 --- a/FirebaseAuth.podspec +++ b/FirebaseAuth.podspec @@ -53,6 +53,7 @@ supports email and password accounts, as well as several 3rd party authenticatio s.dependency 'GoogleUtilities/AppDelegateSwizzler', '~> 7.4' s.dependency 'GoogleUtilities/Environment', '~> 7.4' s.dependency 'GTMSessionFetcher/Core', '~> 1.5' + s.dependency 'GoogleMulticastAppDelegate', '~> 7.5' s.test_spec 'unit' do |unit_tests| unit_tests.scheme = { :code_coverage => true } diff --git a/FirebaseAuth/Sources/Auth/FIRAuth.m b/FirebaseAuth/Sources/Auth/FIRAuth.m index f11fe1ce537..ef38f8e1df7 100644 --- a/FirebaseAuth/Sources/Auth/FIRAuth.m +++ b/FirebaseAuth/Sources/Auth/FIRAuth.m @@ -77,7 +77,14 @@ #import "FirebaseAuth/Sources/SystemService/FIRAuthAppCredentialManager.h" #import "FirebaseAuth/Sources/SystemService/FIRAuthNotificationManager.h" #import "FirebaseAuth/Sources/Utilities/FIRAuthURLPresenter.h" -#endif + +#if SWIFT_PACKAGE +@import GoogleUtilities_MulticastAppDelegate; +#else // SWIFT_PACKAGE +#import +#endif // SWIFT_PACKAGE + +#endif // TARGET_OS_IOS NS_ASSUME_NONNULL_BEGIN @@ -482,7 +489,14 @@ - (nullable instancetype)initWithAPIKey:(NSString *)APIKey appName:(NSString *)a } UIApplication *application = [applicationClass sharedApplication]; - [GULAppDelegateSwizzler proxyOriginalDelegateIncludingAPNSMethods]; + // Use Multicast App Delegate when available but fallback to App Delegate Swizzler for backward compatibility. + id multicastDelegate = + [GULMulticastAppDelegate installedMulticastDelegate]; + if (multicastDelegate == nil) { + FIRLogInfo(kFIRLoggerAuth, @"I-AUT000018", @"Multicast App delegate was not detected. Make sure app events forwarding is configured manually for you app. "); + [GULAppDelegateSwizzler proxyOriginalDelegateIncludingAPNSMethods]; + } + [GULSceneDelegateSwizzler proxyOriginalSceneDelegate]; #endif // TARGET_OS_IOS @@ -540,7 +554,11 @@ - (nullable instancetype)initWithAPIKey:(NSString *)APIKey appName:(NSString *)a initWithApplication:application appCredentialManager:strongSelf->_appCredentialManager]; - [GULAppDelegateSwizzler registerAppDelegateInterceptor:strongSelf]; + if (multicastDelegate != nil) { + [multicastDelegate addInterceptor:strongSelf]; + } else { + [GULAppDelegateSwizzler registerAppDelegateInterceptor:strongSelf]; + } #if ((TARGET_OS_IOS || TARGET_OS_TV) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000)) if (@available(iOS 13, tvos 13, *)) { [GULSceneDelegateSwizzler registerSceneDelegateInterceptor:strongSelf]; diff --git a/Package.swift b/Package.swift index 665bc6ffd09..9f9c9170eb0 100644 --- a/Package.swift +++ b/Package.swift @@ -153,7 +153,7 @@ let package = Package( .package( name: "GoogleUtilities", url: "https://github.com/google/GoogleUtilities.git", - "7.4.0" ..< "8.0.0" + .branch("mm/app-delegate-sample") ), .package( name: "GTMSessionFetcher", @@ -372,6 +372,7 @@ let package = Package( dependencies: [ "FirebaseCore", .product(name: "GULAppDelegateSwizzler", package: "GoogleUtilities"), + .product(name: "GULMulticastAppDelegate", package: "GoogleUtilities"), .product(name: "GULEnvironment", package: "GoogleUtilities"), .product(name: "GTMSessionFetcherCore", package: "GTMSessionFetcher"), ],