aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m
diff options
context:
space:
mode:
authorGravatar Zsika Phillip <protocol86@users.noreply.github.com>2018-05-30 17:59:18 -0700
committerGravatar Paul Beusterien <paulbeusterien@google.com>2018-05-30 17:59:18 -0700
commit312bc00e37735a39e29226b466dbf377297b58cb (patch)
treef42b29149c880a77e445afe3f7d7f94df6d91902 /Firebase/Auth/Source/FIRAuthAppDelegateProxy.m
parentf6096cf378570d08fa9a5e6660675010ee140b90 (diff)
App extension check (#1358)
Diffstat (limited to 'Firebase/Auth/Source/FIRAuthAppDelegateProxy.m')
-rw-r--r--Firebase/Auth/Source/FIRAuthAppDelegateProxy.m14
1 files changed, 13 insertions, 1 deletions
diff --git a/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m b/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m
index f13e94f..3289b4e 100644
--- a/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m
+++ b/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m
@@ -16,6 +16,8 @@
#import "FIRAuthAppDelegateProxy.h"
+#import <FirebaseCore/FIRAppEnvironmentUtil.h>
+
#import <objc/runtime.h>
NS_ASSUME_NONNULL_BEGIN
@@ -200,8 +202,18 @@ static BOOL isIOS9orLater() {
+ (nullable instancetype)sharedInstance {
static dispatch_once_t onceToken;
static FIRAuthAppDelegateProxy *_Nullable sharedInstance;
+ // 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];
dispatch_once(&onceToken, ^{
- sharedInstance = [[self alloc] initWithApplication:[UIApplication sharedApplication]];
+ sharedInstance = [[self alloc] initWithApplication:application];
});
return sharedInstance;
}