diff options
author | Xiangtian Dai <xiangtian@google.com> | 2017-10-19 08:58:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-19 08:58:36 -0700 |
commit | a9585971c35799b06501fe5bba1cf584d000d27b (patch) | |
tree | c9baa39d180d72ee1095b638d0cab0ca8550b290 /Firebase/Auth | |
parent | 024788e38a5e506cf4861aa66afda2bc3b9115e1 (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 .
Diffstat (limited to 'Firebase/Auth')
-rw-r--r-- | Firebase/Auth/Source/FIRAuthAppDelegateProxy.m | 17 | ||||
-rw-r--r-- | Firebase/Auth/Source/FIRAuthURLPresenter.m | 7 |
2 files changed, 23 insertions, 1 deletions
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 |