aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Auth/Source/FIRAuthDefaultUIDelegate.m
diff options
context:
space:
mode:
Diffstat (limited to 'Firebase/Auth/Source/FIRAuthDefaultUIDelegate.m')
-rw-r--r--Firebase/Auth/Source/FIRAuthDefaultUIDelegate.m15
1 files changed, 13 insertions, 2 deletions
diff --git a/Firebase/Auth/Source/FIRAuthDefaultUIDelegate.m b/Firebase/Auth/Source/FIRAuthDefaultUIDelegate.m
index a00d0e9..e5aa7f4 100644
--- a/Firebase/Auth/Source/FIRAuthDefaultUIDelegate.m
+++ b/Firebase/Auth/Source/FIRAuthDefaultUIDelegate.m
@@ -16,6 +16,8 @@
#import "FIRAuthDefaultUIDelegate.h"
+#import <FirebaseCore/FIRAppEnvironmentUtil.h>
+
NS_ASSUME_NONNULL_BEGIN
@interface FIRAuthDefaultUIDelegate ()
@@ -58,8 +60,17 @@ NS_ASSUME_NONNULL_BEGIN
}
+ (id<FIRAuthUIDelegate>)defaultUIDelegate {
- UIViewController *topViewController =
- [UIApplication sharedApplication].keyWindow.rootViewController;
+ // iOS App extensions should not call [UIApplication sharedApplication], even if UIApplication
+ // responds to it.
+ static Class applicationClass = nil;
+ if (![FIRAppEnvironmentUtil isAppExtension]) {
+ Class cls = NSClassFromString(@"UIApplication");
+ if (cls && [cls respondsToSelector:NSSelectorFromString(@"sharedApplication")]) {
+ applicationClass = cls;
+ }
+ }
+ UIApplication *application = [applicationClass sharedApplication];
+ UIViewController *topViewController = application.keyWindow.rootViewController;
while (true){
if (topViewController.presentedViewController) {
topViewController = topViewController.presentedViewController;