aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Xiangtian Dai <xiangtian@google.com>2017-10-19 08:58:36 -0700
committerGravatar GitHub <noreply@github.com>2017-10-19 08:58:36 -0700
commita9585971c35799b06501fe5bba1cf584d000d27b (patch)
treec9baa39d180d72ee1095b638d0cab0ca8550b290
parent024788e38a5e506cf4861aa66afda2bc3b9115e1 (diff)
Silences unguarded availability warnings in Auth. (#389)
Also fixes a crash in the Auth sample app in an error case. This addresses *Auth* part of #385 .
-rw-r--r--Example/Auth/Sample/MainViewController.m4
-rw-r--r--Firebase/Auth/Source/FIRAuthAppDelegateProxy.m17
-rw-r--r--Firebase/Auth/Source/FIRAuthURLPresenter.m7
3 files changed, 26 insertions, 2 deletions
diff --git a/Example/Auth/Sample/MainViewController.m b/Example/Auth/Sample/MainViewController.m
index e885e5a..5e739b7 100644
--- a/Example/Auth/Sample/MainViewController.m
+++ b/Example/Auth/Sample/MainViewController.m
@@ -2537,7 +2537,9 @@ static NSDictionary<NSString *, NSString *> *parseURL(NSString *urlString) {
if (error) {
[self logFailure:@"failed to send verification code" error:error];
[self showMessagePrompt:error.localizedDescription];
- completion(error);
+ if (completion) {
+ completion(error);
+ }
return;
}
[self logSuccess:@"Code sent"];
diff --git a/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m b/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m
index 8899407..8b8e1bb 100644
--- a/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m
+++ b/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m
@@ -40,6 +40,21 @@ static id noop(id object, SEL cmd, ...) {
}
#endif
+/** @fn isIOS9orLater
+ @brief Checks whether the iOS version is 9 or later.
+ @returns Whether the iOS version is 9 or later.
+ */
+static BOOL isIOS9orLater() {
+#if defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0)
+ if (@available(iOS 9.0, *)) {
+ return YES;
+ }
+ return NO;
+#else
+ return &UIApplicationOpenURLOptionsAnnotationKey; // the constant is only available on iOS 9+
+#endif
+}
+
@implementation FIRAuthAppDelegateProxy {
/** @var _appDelegate
@brief The application delegate whose method is being swizzled.
@@ -119,7 +134,7 @@ static id noop(id object, SEL cmd, ...) {
SEL openURLOptionsSelector = @selector(application:openURL:options:);
SEL openURLAnnotationSelector = @selector(application:openURL:sourceApplication:annotation:);
SEL handleOpenURLSelector = @selector(application:handleOpenURL:);
- if (&UIApplicationOpenURLOptionsAnnotationKey && // the constant is only available on iOS 9+
+ if (isIOS9orLater() &&
([_appDelegate respondsToSelector:openURLOptionsSelector] ||
(![_appDelegate respondsToSelector:openURLAnnotationSelector] &&
![_appDelegate respondsToSelector:handleOpenURLSelector]))) {
diff --git a/Firebase/Auth/Source/FIRAuthURLPresenter.m b/Firebase/Auth/Source/FIRAuthURLPresenter.m
index 919aee1..5526a85 100644
--- a/Firebase/Auth/Source/FIRAuthURLPresenter.m
+++ b/Firebase/Auth/Source/FIRAuthURLPresenter.m
@@ -30,6 +30,11 @@ NS_ASSUME_NONNULL_BEGIN
FIRAuthWebViewControllerDelegate>
@end
+// Disable unguarded availability warnings because SFSafariViewController is been used throughout
+// the code, including as an iVar, which cannot be simply excluded by @available check.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunguarded-availability"
+
@implementation FIRAuthURLPresenter {
/** @var _isPresenting
@brief Whether or not some web-based content is being presented.
@@ -176,6 +181,8 @@ NS_ASSUME_NONNULL_BEGIN
}
}
+#pragma clang diagnostic pop // ignored "-Wunguarded-availability"
+
@end
NS_ASSUME_NONNULL_END